- sprintf(cur, "%d(%s) ", ptr[i].val, GETOPERAND(query) + ptr[i].distance );
+ sprintf(cur, "%d(%s) ", ptr[i].val, GETOPERAND(query) + ptr[i].distance);
#include "utils/pg_locale.h"
-#include /* tolower */
-#include "txtidx.h"
-#include "query.h"
+#include /* tolower */
+#include "txtidx.h"
+#include "query.h"
#include "deflex.h"
#include "parser.h"
#include "morph.h"
PG_FUNCTION_INFO_V1(txtidx_in);
-Datum txtidx_in(PG_FUNCTION_ARGS);
+Datum txtidx_in(PG_FUNCTION_ARGS);
+
PG_FUNCTION_INFO_V1(txtidx_out);
-Datum txtidx_out(PG_FUNCTION_ARGS);
+Datum txtidx_out(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(txt2txtidx);
-Datum txt2txtidx(PG_FUNCTION_ARGS);
+Datum txt2txtidx(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(tsearch);
-Datum tsearch(PG_FUNCTION_ARGS);
+Datum tsearch(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(txtidxsize);
-Datum txtidxsize(PG_FUNCTION_ARGS);
+Datum txtidxsize(PG_FUNCTION_ARGS);
/*
* in/out text index type
*/
static char *BufferStr;
static int
-compareentry( const void * a, const void * b ) {
- if ( ((WordEntry*)a)->len == ((WordEntry*)b)->len ) {
- return strncmp(
- &BufferStr[((WordEntry*)a)->pos],
- &BufferStr[((WordEntry*)b)->pos],
- ((WordEntry*)b)->len );
+compareentry(const void *a, const void *b)
+{
+ if (((WordEntry *) a)->len == ((WordEntry *) b)->len)
+ {
+ return strncmp(
+ &BufferStr[((WordEntry *) a)->pos],
+ &BufferStr[((WordEntry *) b)->pos],
+ ((WordEntry *) b)->len);
}
- return ( ((WordEntry*)a)->len > ((WordEntry*)b)->len ) ? 1 : -1;
+ return (((WordEntry *) a)->len > ((WordEntry *) b)->len) ? 1 : -1;
}
static int
-uniqueentry( WordEntry* a, int4 l, char *buf, int4 *outbuflen ) {
- WordEntry *ptr, *res;
+uniqueentry(WordEntry * a, int4 l, char *buf, int4 *outbuflen)
+{
+ WordEntry *ptr,
+ *res;
res = a;
*outbuflen = res->len;
- if ( l == 1 )
+ if (l == 1)
return l;
- ptr = a+1;
+ ptr = a + 1;
BufferStr = buf;
- qsort((void*)a, l, sizeof(int4), compareentry );
+ qsort((void *) a, l, sizeof(int4), compareentry);
*outbuflen = res->len;
- while (ptr - a < l) {
- if ( ! (ptr->len == res->len &&
- strncmp(&buf[ ptr->pos ], &buf[ res->pos ],res->len) == 0 ) ) {
+ while (ptr - a < l)
+ {
+ if (!(ptr->len == res->len &&
+ strncmp(&buf[ptr->pos], &buf[res->pos], res->len) == 0))
+ {
res++;
res->len = ptr->len;
res->pos = ptr->pos;
ptr++;
}
return res + 1 - a;
-}
+}
#define WAITWORD 1
-#define WAITENDWORD 2
+#define WAITENDWORD 2
#define WAITNEXTCHAR 3
#define WAITENDCMPLX 4
do { \
if ( state->curpos - state->word == state->len ) \
{ \
- int4 clen = state->curpos - state->word; \
- state->len *= 2; \
- state->word = (char*)repalloc( (void*)state->word, state->len ); \
- state->curpos = state->word + clen; \
- } \
+ int4 clen = state->curpos - state->word; \
+ state->len *= 2; \
+ state->word = (char*)repalloc( (void*)state->word, state->len ); \
+ state->curpos = state->word + clen; \
+ } \
} while (0)
int4
-gettoken_txtidx( TI_IN_STATE *state ) {
- int4 oldstate = 0;
+gettoken_txtidx(TI_IN_STATE * state)
+{
+ int4 oldstate = 0;
+
state->curpos = state->word;
state->state = WAITWORD;
- while( 1 ) {
- if ( state->state == WAITWORD ) {
- if ( *(state->prsbuf) == '\0' ) {
+ while (1)
+ {
+ if (state->state == WAITWORD)
+ {
+ if (*(state->prsbuf) == '\0')
return 0;
- } else if ( *(state->prsbuf) == '\'' ) {
- state->state = WAITENDCMPLX;
- } else if ( *(state->prsbuf) == '\\' ) {
+ else if (*(state->prsbuf) == '\'')
+ state->state = WAITENDCMPLX;
+ else if (*(state->prsbuf) == '\\')
+ {
state->state = WAITNEXTCHAR;
oldstate = WAITENDWORD;
- } else if ( state->oprisdelim && ISOPERATOR( *(state->prsbuf) ) ) {
+ }
+ else if (state->oprisdelim && ISOPERATOR(*(state->prsbuf)))
elog(ERROR, "Syntax error");
- } else if ( *(state->prsbuf) != ' ' ) {
+ else if (*(state->prsbuf) != ' ')
+ {
*(state->curpos) = *(state->prsbuf);
state->curpos++;
state->state = WAITENDWORD;
}
- } else if ( state->state == WAITNEXTCHAR ) {
- if ( *(state->prsbuf) == '\0' ) {
- elog(ERROR,"There is no escaped character");
- } else {
+ }
+ else if (state->state == WAITNEXTCHAR)
+ {
+ if (*(state->prsbuf) == '\0')
+ elog(ERROR, "There is no escaped character");
+ else
+ {
RESIZEPRSBUF;
*(state->curpos) = *(state->prsbuf);
state->curpos++;
state->state = oldstate;
}
- } else if ( state->state == WAITENDWORD ) {
- if ( *(state->prsbuf) == '\\' ) {
+ }
+ else if (state->state == WAITENDWORD)
+ {
+ if (*(state->prsbuf) == '\\')
+ {
state->state = WAITNEXTCHAR;
oldstate = WAITENDWORD;
- } else if ( *(state->prsbuf) == ' ' || *(state->prsbuf) == '\0' ||
- ( state->oprisdelim && ISOPERATOR( *(state->prsbuf) ) ) ) {
+ }
+ else if (*(state->prsbuf) == ' ' || *(state->prsbuf) == '\0' ||
+ (state->oprisdelim && ISOPERATOR(*(state->prsbuf))))
+ {
RESIZEPRSBUF;
- if ( state->curpos == state->word )
+ if (state->curpos == state->word)
elog(ERROR, "Syntax error");
*(state->curpos) = '\0';
return 1;
- } else {
+ }
+ else
+ {
RESIZEPRSBUF;
*(state->curpos) = *(state->prsbuf);
state->curpos++;
}
- } else if ( state->state == WAITENDCMPLX ) {
- if ( *(state->prsbuf) == '\'' ) {
+ }
+ else if (state->state == WAITENDCMPLX)
+ {
+ if (*(state->prsbuf) == '\'')
+ {
RESIZEPRSBUF;
*(state->curpos) = '\0';
- if ( state->curpos == state->word )
+ if (state->curpos == state->word)
elog(ERROR, "Syntax error");
state->prsbuf++;
return 1;
- } else if ( *(state->prsbuf) == '\\' ) {
+ }
+ else if (*(state->prsbuf) == '\\')
+ {
state->state = WAITNEXTCHAR;
oldstate = WAITENDCMPLX;
- } else if ( *(state->prsbuf) == '\0' ) {
- elog(ERROR,"Syntax error");
- } else {
+ }
+ else if (*(state->prsbuf) == '\0')
+ elog(ERROR, "Syntax error");
+ else
+ {
RESIZEPRSBUF;
*(state->curpos) = *(state->prsbuf);
state->curpos++;
}
- } else {
+ }
+ else
elog(ERROR, "Inner bug :(");
- }
state->prsbuf++;
}
}
Datum
-txtidx_in(PG_FUNCTION_ARGS) {
- char *buf = (char*)PG_GETARG_POINTER(0);
+txtidx_in(PG_FUNCTION_ARGS)
+{
+ char *buf = (char *) PG_GETARG_POINTER(0);
TI_IN_STATE state;
- WordEntry *arr;
- int4 len=0, totallen = 64;
- txtidx *in;
- char *tmpbuf, *cur;
- int4 i,buflen = 256;
+ WordEntry *arr;
+ int4 len = 0,
+ totallen = 64;
+ txtidx *in;
+ char *tmpbuf,
+ *cur;
+ int4 i,
+ buflen = 256;
state.prsbuf = buf;
- state.len=32;
- state.word = (char*)palloc( state.len );
+ state.len = 32;
+ state.word = (char *) palloc(state.len);
state.oprisdelim = false;
- arr = (WordEntry*)palloc( sizeof(WordEntry) * totallen );
- cur = tmpbuf = (char*)palloc( buflen );
- while( gettoken_txtidx( &state ) ) {
- if ( len == totallen ) {
+ arr = (WordEntry *) palloc(sizeof(WordEntry) * totallen);
+ cur = tmpbuf = (char *) palloc(buflen);
+ while (gettoken_txtidx(&state))
+ {
+ if (len == totallen)
+ {
totallen *= 2;
- arr = (WordEntry*)repalloc( (void*)arr, sizeof(int4)*totallen );
+ arr = (WordEntry *) repalloc((void *) arr, sizeof(int4) * totallen);
}
- while ( cur-tmpbuf + state.curpos - state.word >= buflen ) {
- int4 dist = cur-tmpbuf;
+ while (cur - tmpbuf + state.curpos - state.word >= buflen)
+ {
+ int4 dist = cur - tmpbuf;
+
buflen *= 2;
- tmpbuf = (char*)repalloc( (void*)tmpbuf, buflen );
- cur = tmpbuf+dist;
+ tmpbuf = (char *) repalloc((void *) tmpbuf, buflen);
+ cur = tmpbuf + dist;
}
- if ( state.curpos - state.word > 0xffff )
- elog(ERROR,"Word is too long");
+ if (state.curpos - state.word > 0xffff)
+ elog(ERROR, "Word is too long");
arr[len].len = state.curpos - state.word;
- if ( cur - tmpbuf > 0xffff )
- elog(ERROR,"Too long value");
+ if (cur - tmpbuf > 0xffff)
+ elog(ERROR, "Too long value");
arr[len].pos = cur - tmpbuf;
- memcpy( (void*)cur, (void*)state.word, arr[len].len );
+ memcpy((void *) cur, (void *) state.word, arr[len].len);
cur += arr[len].len;
len++;
}
pfree(state.word);
- if ( !len )
- elog(ERROR,"Void value");
+ if (!len)
+ elog(ERROR, "Void value");
- len = uniqueentry( arr, len, tmpbuf, &buflen );
- totallen = CALCDATASIZE( len, buflen );
- in = (txtidx*)palloc( totallen );
+ len = uniqueentry(arr, len, tmpbuf, &buflen);
+ totallen = CALCDATASIZE(len, buflen);
+ in = (txtidx *) palloc(totallen);
in->len = totallen;
in->size = len;
cur = STRPTR(in);
- for(i=0;i
- memcpy( (void*)cur, (void*)&tmpbuf[ arr[i].pos ], arr[i].len );
+ for (i = 0; i < len; i++)
+ {
+ memcpy((void *) cur, (void *) &tmpbuf[arr[i].pos], arr[i].len);
arr[i].pos = cur - STRPTR(in);
cur += arr[i].len;
}
pfree(tmpbuf);
- memcpy( (void*)ARRPTR(in), (void*)arr, sizeof(int4)*len );
- pfree( arr );
- PG_RETURN_POINTER( in );
+ memcpy((void *) ARRPTR(in), (void *) arr, sizeof(int4) * len);
+ pfree(arr);
+ PG_RETURN_POINTER(in);
}
Datum
-txtidxsize(PG_FUNCTION_ARGS) {
- txtidx *in=(txtidx*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0)));
- int4 ret = in->size;
- PG_FREE_IF_COPY(in,0);
- PG_RETURN_INT32( ret );
+txtidxsize(PG_FUNCTION_ARGS)
+{
+ txtidx *in = (txtidx *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0)));
+ int4 ret = in->size;
+
+ PG_FREE_IF_COPY(in, 0);
+ PG_RETURN_INT32(ret);
}
Datum
-txtidx_out(PG_FUNCTION_ARGS) {
- txtidx *out=(txtidx*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0)));
- char *outbuf;
- int4 i,j,lenbuf = STRSIZE(out) + 1 /* \0 */ + out->size*2 /* '' */ + out->size - 1 /* space */;
- WordEntry *ptr = ARRPTR(out);
- char *curin, *curout;
-
- curout = outbuf = (char*) palloc( lenbuf );
- for(i=0;isize;i++) {
+txtidx_out(PG_FUNCTION_ARGS)
+{
+ txtidx *out = (txtidx *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0)));
+ char *outbuf;
+ int4 i,
+ j,
+ lenbuf = STRSIZE(out) + 1 /* \0 */ + out->size * 2 /* '' */ + out->size - 1 /* space */ ;
+ WordEntry *ptr = ARRPTR(out);
+ char *curin,
+ *curout;
+
+ curout = outbuf = (char *) palloc(lenbuf);
+ for (i = 0; i < out->size; i++)
+ {
curin = STRPTR(out) + ptr->pos;
- if ( i!= 0 )
+ if (i != 0)
*curout++ = ' ';
*curout++ = '\'';
j = ptr->len;
- while( j-- ) {
- if ( *curin == '\'' ) {
- int4 pos = curout - outbuf;
- outbuf = (char*)repalloc((void*)outbuf, ++lenbuf );
+ while (j--)
+ {
+ if (*curin == '\'')
+ {
+ int4 pos = curout - outbuf;
+
+ outbuf = (char *) repalloc((void *) outbuf, ++lenbuf);
curout = outbuf + pos;
*curout++ = '\\';
}
*curout++ = '\'';
ptr++;
}
- outbuf[ lenbuf-1 ] = '\0';
- PG_FREE_IF_COPY(out,0);
- PG_RETURN_POINTER( outbuf );
+ outbuf[lenbuf - 1] = '\0';
+ PG_FREE_IF_COPY(out, 0);
+ PG_RETURN_POINTER(outbuf);
}
-typedef struct {
- uint16 len;
- char* word;
-} WORD;
+typedef struct
+{
+ uint16 len;
+ char *word;
+} WORD;
-typedef struct {
- WORD *words;
- int4 lenwords;
- int4 curwords;
-} PRSTEXT;
+typedef struct
+{
+ WORD *words;
+ int4 lenwords;
+ int4 curwords;
+} PRSTEXT;
/*
* Parse text to lexems
*/
static void
-parsetext( PRSTEXT *prs, char *buf, int4 buflen ) {
- int type,lenlemm;
- char *ptr,*ptrw;
- char *lemm;
-
- start_parse_str( buf, buflen );
- while( (type=tsearch_yylex()) != 0 ) {
- if ( prs->curwords == prs->lenwords ) {
+parsetext(PRSTEXT * prs, char *buf, int4 buflen)
+{
+ int type,
+ lenlemm;
+ char *ptr,
+ *ptrw;
+ char *lemm;
+
+ start_parse_str(buf, buflen);
+ while ((type = tsearch_yylex()) != 0)
+ {
+ if (prs->curwords == prs->lenwords)
+ {
prs->lenwords *= 2;
- prs->words = (WORD*)repalloc( (void*)prs->words, prs->lenwords * sizeof(WORD) );
+ prs->words = (WORD *) repalloc((void *) prs->words, prs->lenwords * sizeof(WORD));
}
- if ( tokenlen>0xffff ) {
+ if (tokenlen > 0xffff)
+ {
end_parse();
elog(ERROR, "Word is too long");
}
lenlemm = tokenlen;
- lemm = lemmatize( token, &lenlemm, type );
-
- if ( ! lemm )
+ lemm = lemmatize(token, &lenlemm, type);
+
+ if (!lemm)
continue;
- if ( lemm != token ) {
- prs->words[ prs->curwords ].len = lenlemm;
- prs->words[ prs->curwords ].word = lemm;
- } else {
- prs->words[ prs->curwords ].len = lenlemm;
- ptrw = prs->words[ prs->curwords ].word = (char*)palloc( lenlemm );
+ if (lemm != token)
+ {
+ prs->words[prs->curwords].len = lenlemm;
+ prs->words[prs->curwords].word = lemm;
+ }
+ else
+ {
+ prs->words[prs->curwords].len = lenlemm;
+ ptrw = prs->words[prs->curwords].word = (char *) palloc(lenlemm);
ptr = token;
- while( ptr-token < lenlemm ) {
- *ptrw = tolower( (unsigned char) *ptr );
- ptr++; ptrw++;
+ while (ptr - token < lenlemm)
+ {
+ *ptrw = tolower((unsigned char) *ptr);
+ ptr++;
+ ptrw++;
}
}
- prs->curwords++;
+ prs->curwords++;
}
end_parse();
}
static int
-compareWORD( const void * a, const void * b ) {
- if ( ((WORD*)a)->len == ((WORD*)b)->len )
- return strncmp(
- ((WORD*)a)->word,
- ((WORD*)b)->word,
- ((WORD*)b)->len );
- return ( ((WORD*)a)->len > ((WORD*)b)->len ) ? 1 : -1;
+compareWORD(const void *a, const void *b)
+{
+ if (((WORD *) a)->len == ((WORD *) b)->len)
+ return strncmp(
+ ((WORD *) a)->word,
+ ((WORD *) b)->word,
+ ((WORD *) b)->len);
+ return (((WORD *) a)->len > ((WORD *) b)->len) ? 1 : -1;
}
static int
-uniqueWORD( WORD* a, int4 l ) {
- WORD *ptr, *res;
+uniqueWORD(WORD * a, int4 l)
+{
+ WORD *ptr,
+ *res;
- if ( l == 1 )
+ if (l == 1)
return l;
res = a;
ptr = a + 1;
- qsort((void*)a, l, sizeof(WORD), compareWORD );
+ qsort((void *) a, l, sizeof(WORD), compareWORD);
- while (ptr - a < l) {
- if ( ! (ptr->len == res->len &&
- strncmp(ptr->word, res->word ,res->len) == 0 ) ) {
+ while (ptr - a < l)
+ {
+ if (!(ptr->len == res->len &&
+ strncmp(ptr->word, res->word, res->len) == 0))
+ {
res++;
- res->len = ptr->len;
+ res->len = ptr->len;
res->word = ptr->word;
- } else {
- pfree(ptr->word);
}
+ else
+ pfree(ptr->word);
ptr++;
}
return res + 1 - a;
-}
+}
/*
* make value of txtidx
*/
static txtidx *
-makevalue( PRSTEXT *prs ) {
- int4 i, lenstr=0, totallen;
- txtidx *in;
- WordEntry *ptr;
- char *str,*cur;
-
- prs->curwords = uniqueWORD( prs->words, prs->curwords );
+makevalue(PRSTEXT * prs)
+{
+ int4 i,
+ lenstr = 0,
+ totallen;
+ txtidx *in;
+ WordEntry *ptr;
+ char *str,
+ *cur;
+
+ prs->curwords = uniqueWORD(prs->words, prs->curwords);
+ for (i = 0; i < prs->curwords; i++)
lenstr += prs->words[i].len;
- totallen = CALCDATASIZE( prs->curwords, lenstr );
- in = (txtidx*)palloc( totallen );
+ totallen = CALCDATASIZE(prs->curwords, lenstr);
+ in = (txtidx *) palloc(totallen);
in->len = totallen;
in->size = prs->curwords;
ptr = ARRPTR(in);
cur = str = STRPTR(in);
- for(i=0;i
curwords;i++) {
+ for (i = 0; i < prs->curwords; i++)
+ {
ptr->len = prs->words[i].len;
- if ( cur-str > 0xffff )
- elog(ERROR,"Value is too big");
- ptr->pos = cur-str;
+ if (cur - str > 0xffff)
+ elog(ERROR, "Value is too big");
+ ptr->pos = cur - str;
ptr++;
- memcpy( (void*)cur, (void*)prs->words[i].word, prs->words[i].len );
+ memcpy((void *) cur, (void *) prs->words[i].word, prs->words[i].len);
pfree(prs->words[i].word);
- cur += prs->words[i].len;
+ cur += prs->words[i].len;
}
pfree(prs->words);
return in;
}
Datum
-txt2txtidx(PG_FUNCTION_ARGS) {
- text *in = (text*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0)));
- PRSTEXT prs;
- txtidx *out = NULL;
-
- prs.lenwords = 32;
- prs.curwords = 0;
- prs.words = (WORD*)palloc(sizeof(WORD)*prs.lenwords);
+txt2txtidx(PG_FUNCTION_ARGS)
+{
+ text *in = (text *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0)));
+ PRSTEXT prs;
+ txtidx *out = NULL;
+
+ prs.lenwords = 32;
+ prs.curwords = 0;
+ prs.words = (WORD *) palloc(sizeof(WORD) * prs.lenwords);
initmorph();
- parsetext( &prs, VARDATA(in), VARSIZE(in) - VARHDRSZ );
- PG_FREE_IF_COPY(in,0);
-
- if ( prs.curwords ) {
- out = makevalue( &prs );
- PG_RETURN_POINTER( out );
+ parsetext(&prs, VARDATA(in), VARSIZE(in) - VARHDRSZ);
+ PG_FREE_IF_COPY(in, 0);
+
+ if (prs.curwords)
+ {
+ out = makevalue(&prs);
+ PG_RETURN_POINTER(out);
}
pfree(prs.words);
PG_RETURN_NULL();
-}
+}
/*
* Trigger
*/
Datum
-tsearch(PG_FUNCTION_ARGS) {
+tsearch(PG_FUNCTION_ARGS)
+{
TriggerData *trigdata;
Trigger *trigger;
- Relation rel;
- HeapTuple rettuple = NULL;
- int numidxattr,i;
- PRSTEXT prs;
- Datum datum = (Datum)0;
+ Relation rel;
+ HeapTuple rettuple = NULL;
+ int numidxattr,
+ i;
+ PRSTEXT prs;
+ Datum datum = (Datum) 0;
if (!CALLED_AS_TRIGGER(fcinfo))
rettuple = trigdata->tg_trigtuple;
else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
rettuple = trigdata->tg_newtuple;
- else
+ else
elog(ERROR, "TSearch: Unknown event");
trigger = trigdata->tg_trigger;
rel = trigdata->tg_relation;
- if ( trigger->tgnargs < 2 )
- elog(ERROR,"TSearch: format tsearch(txtidx_field, text_field1,...)");
+ if (trigger->tgnargs < 2)
+ elog(ERROR, "TSearch: format tsearch(txtidx_field, text_field1,...)");
numidxattr = SPI_fnumber(rel->rd_att, trigger->tgargs[0]);
- if ( numidxattr < 0 )
- elog(ERROR,"TSearch: Can not find txtidx_field");
+ if (numidxattr < 0)
+ elog(ERROR, "TSearch: Can not find txtidx_field");
- prs.lenwords = 32;
- prs.curwords = 0;
- prs.words = (WORD*)palloc(sizeof(WORD)*prs.lenwords);
+ prs.lenwords = 32;
+ prs.curwords = 0;
+ prs.words = (WORD *) palloc(sizeof(WORD) * prs.lenwords);
initmorph();
- /* find all words in indexable column */
- for(i=1; itgnargs; i++) {
- int4 numattr;
- text *txt_toasted, *txt;
- bool isnull;
- Oid oidtype;
+ /* find all words in indexable column */
+ for (i = 1; i < trigger->tgnargs; i++)
+ {
+ int4 numattr;
+ text *txt_toasted,
+ *txt;
+ bool isnull;
+ Oid oidtype;
numattr = SPI_fnumber(rel->rd_att, trigger->tgargs[i]);
oidtype = SPI_gettypeid(rel->rd_att, numattr);
- if ( numattr<0 || ( ! ( oidtype==TEXTOID || oidtype==VARCHAROID ) ) ) {
+ if (numattr < 0 || (!(oidtype == TEXTOID || oidtype == VARCHAROID)))
+ {
elog(NOTICE, "TSearch: can not find field '%s'", trigger->tgargs[i]);
continue;
}
- txt_toasted = (text*)DatumGetPointer( SPI_getbinval(rettuple, rel->rd_att, numattr, &isnull ) );
- if ( isnull )
+ txt_toasted = (text *) DatumGetPointer(SPI_getbinval(rettuple, rel->rd_att, numattr, &isnull));
+ if (isnull)
continue;
- txt = (text*)DatumGetPointer( PG_DETOAST_DATUM( PointerGetDatum ( txt_toasted ) ) );
+ txt = (text *) DatumGetPointer(PG_DETOAST_DATUM(PointerGetDatum(txt_toasted)));
- parsetext( &prs, VARDATA(txt), VARSIZE(txt) - VARHDRSZ );
- if ( txt != txt_toasted )
+ parsetext(&prs, VARDATA(txt), VARSIZE(txt) - VARHDRSZ);
+ if (txt != txt_toasted)
pfree(txt);
}
/* make txtidx value */
- if (prs.curwords) {
- datum = PointerGetDatum( makevalue( &prs ) );
- rettuple = SPI_modifytuple( rel, rettuple, 1, &numidxattr,
- &datum, NULL );
+ if (prs.curwords)
+ {
+ datum = PointerGetDatum(makevalue(&prs));
+ rettuple = SPI_modifytuple(rel, rettuple, 1, &numidxattr,
+ &datum, NULL);
pfree(DatumGetPointer(datum));
- } else {
- char nulls = 'n';
- pfree( prs.words );
- rettuple = SPI_modifytuple( rel, rettuple, 1, &numidxattr,
- &datum, &nulls );
}
-
+ else
+ {
+ char nulls = 'n';
+
+ pfree(prs.words);
+ rettuple = SPI_modifytuple(rel, rettuple, 1, &numidxattr,
+ &datum, &nulls);
+ }
+
if (rettuple == NULL)
elog(ERROR, "TSearch: %d returned by SPI_modifytuple", SPI_result);
- return PointerGetDatum( rettuple );
+ return PointerGetDatum(rettuple);
}
-
#include "utils/builtins.h"
#include "storage/bufpage.h"
-typedef struct {
- uint16 len;
- uint16 pos;
-} WordEntry;
-
-typedef struct {
- int4 len;
- int4 size;
- char data[1];
-} txtidx;
-
-#define DATAHDRSIZE (sizeof(int4)*2)
-#define CALCDATASIZE(x, lenstr) ( x * sizeof(WordEntry) + DATAHDRSIZE + lenstr )
-#define ARRPTR(x) ( (WordEntry*) ( (char*)x + DATAHDRSIZE ) )
-#define STRPTR(x) ( (char*)x + DATAHDRSIZE + ( sizeof(WordEntry) * ((txtidx*)x)->size ) )
-#define STRSIZE(x) ( ((txtidx*)x)->len - DATAHDRSIZE - ( sizeof(WordEntry) * ((txtidx*)x)->size ) )
-
-typedef struct {
- char *prsbuf;
- char *word;
- char *curpos;
- int4 len;
- int4 state;
- bool oprisdelim;
-} TI_IN_STATE;
-
-int4 gettoken_txtidx( TI_IN_STATE *state );
-
+typedef struct
+{
+ uint16 len;
+ uint16 pos;
+} WordEntry;
+
+typedef struct
+{
+ int4 len;
+ int4 size;
+ char data[1];
+} txtidx;
+
+#define DATAHDRSIZE (sizeof(int4)*2)
+#define CALCDATASIZE(x, lenstr) ( x * sizeof(WordEntry) + DATAHDRSIZE + lenstr )
+#define ARRPTR(x) ( (WordEntry*) ( (char*)x + DATAHDRSIZE ) )
+#define STRPTR(x) ( (char*)x + DATAHDRSIZE + ( sizeof(WordEntry) * ((txtidx*)x)->size ) )
+#define STRSIZE(x) ( ((txtidx*)x)->len - DATAHDRSIZE - ( sizeof(WordEntry) * ((txtidx*)x)->size ) )
+
+typedef struct
+{
+ char *prsbuf;
+ char *word;
+ char *curpos;
+ int4 len;
+ int4 state;
+ bool oprisdelim;
+} TI_IN_STATE;
+
+int4 gettoken_txtidx(TI_IN_STATE * state);
#endif
-
int user_write_lock_oid(Oid oid);
int user_write_unlock_oid(Oid oid);
int user_unlock_all(void);
-
#endif
/*
/* passthrough functions (palloc is a macro) */
-static void *pgxml_palloc(size_t size)
+static void *
+pgxml_palloc(size_t size)
{
- return palloc(size);
+ return palloc(size);
}
-static void *pgxml_repalloc(void *ptr, size_t size)
+static void *
+pgxml_repalloc(void *ptr, size_t size)
{
- return repalloc(ptr,size);
+ return repalloc(ptr, size);
}
-static void pgxml_pfree(void *ptr)
+static void
+pgxml_pfree(void *ptr)
{
- return pfree(ptr);
+ return pfree(ptr);
}
-static void pgxml_mhs_init()
+static void
+pgxml_mhs_init()
{
- mhs.malloc_fcn = pgxml_palloc;
- mhs.realloc_fcn = pgxml_repalloc;
- mhs.free_fcn = pgxml_pfree;
+ mhs.malloc_fcn = pgxml_palloc;
+ mhs.realloc_fcn = pgxml_repalloc;
+ mhs.free_fcn = pgxml_pfree;
}
-static void pgxml_handler_init()
+static void
+pgxml_handler_init()
{
- /* This code should set up the relevant handlers from user-supplied
- settings. Quite how these settings are made is another matter :) */
+ /*
+ * This code should set up the relevant handlers from user-supplied
+ * settings. Quite how these settings are made is another matter :)
+ */
}
/* Returns true if document is well-formed */
Datum
pgxml_parse(PG_FUNCTION_ARGS)
{
- /* called as pgxml_parse(document) */
- XML_Parser p;
- text *t = PG_GETARG_TEXT_P(0); /*document buffer */
- int32 docsize = VARSIZE(t) - VARHDRSZ;
-
- pgxml_mhs_init();
-
- pgxml_handler_init();
-
- p = XML_ParserCreate_MM(NULL,&mhs,NULL);
- if (! p) {
- elog(ERROR, "pgxml: Could not create expat parser");
- PG_RETURN_NULL(); /* seems appropriate if we couldn't parse */
- }
-
- if (! XML_Parse(p, (char *)VARDATA(t) , docsize, 1)) {
- /* elog(NOTICE, "Parse error at line %d:%s",
- XML_GetCurrentLineNumber(p),
- XML_ErrorString(XML_GetErrorCode(p))); */
- XML_ParserFree(p);
- PG_RETURN_BOOL(false);
- }
-
- XML_ParserFree(p);
- PG_RETURN_BOOL(true);
+ /* called as pgxml_parse(document) */
+ XML_Parser p;
+ text *t = PG_GETARG_TEXT_P(0); /* document buffer */
+ int32 docsize = VARSIZE(t) - VARHDRSZ;
+
+ pgxml_mhs_init();
+
+ pgxml_handler_init();
+
+ p = XML_ParserCreate_MM(NULL, &mhs, NULL);
+ if (!p)
+ {
+ elog(ERROR, "pgxml: Could not create expat parser");
+ PG_RETURN_NULL(); /* seems appropriate if we couldn't parse */
+ }
+
+ if (!XML_Parse(p, (char *) VARDATA(t), docsize, 1))
+ {
+ /*
+ * elog(NOTICE, "Parse error at line %d:%s",
+ * XML_GetCurrentLineNumber(p),
+ * XML_ErrorString(XML_GetErrorCode(p)));
+ */
+ XML_ParserFree(p);
+ PG_RETURN_BOOL(false);
+ }
+
+ XML_ParserFree(p);
+ PG_RETURN_BOOL(true);
}
/* XPath handling functions */
/* XPath support here is for a very skeletal kind of XPath!
It was easy to program though... */
-/* This first is the core function that builds a result set. The
+/* This first is the core function that builds a result set. The
actual functions called by the user manipulate that result set
in various ways.
*/
-static XPath_Results *build_xpath_results(text *doc, text *pathstr)
+static XPath_Results *
+build_xpath_results(text *doc, text *pathstr)
{
- XPath_Results *xpr;
- char *res;
- pgxml_udata *udata;
- XML_Parser p;
- int32 docsize;
+ XPath_Results *xpr;
+ char *res;
+ pgxml_udata *udata;
+ XML_Parser p;
+ int32 docsize;
- xpr = (XPath_Results *) palloc((sizeof(XPath_Results)));
- memset((void *)xpr, 0, sizeof(XPath_Results));
- xpr->rescount=0;
+ xpr = (XPath_Results *) palloc((sizeof(XPath_Results)));
+ memset((void *) xpr, 0, sizeof(XPath_Results));
+ xpr->rescount = 0;
- docsize=VARSIZE(doc)-VARHDRSZ;
+ docsize = VARSIZE(doc) - VARHDRSZ;
- /* res isn't going to be the real return type, it is just a buffer */
+ /* res isn't going to be the real return type, it is just a buffer */
- res = (char *) palloc(docsize);
- memset((void *)res, 0, docsize);
+ res = (char *) palloc(docsize);
+ memset((void *) res, 0, docsize);
- xpr->resbuf = res;
+ xpr->resbuf = res;
- udata = (pgxml_udata *) palloc((sizeof(pgxml_udata)));
- memset((void *)udata,0,sizeof(pgxml_udata));
+ udata = (pgxml_udata *) palloc((sizeof(pgxml_udata)));
+ memset((void *) udata, 0, sizeof(pgxml_udata));
- udata->currentpath[0]='\0';
- udata->textgrab=0;
+ udata->currentpath[0] = '\0';
+ udata->textgrab = 0;
- udata->path= (char *) palloc(VARSIZE(pathstr));
- memcpy(udata->path, VARDATA(pathstr), VARSIZE(pathstr)-VARHDRSZ);
+ udata->path = (char *) palloc(VARSIZE(pathstr));
+ memcpy(udata->path, VARDATA(pathstr), VARSIZE(pathstr) - VARHDRSZ);
- udata->path[VARSIZE(pathstr)-VARHDRSZ]='\0';
+ udata->path[VARSIZE(pathstr) - VARHDRSZ] = '\0';
- udata->resptr = res;
- udata->reslen = 0;
+ udata->resptr = res;
+ udata->reslen = 0;
- udata->xpres = xpr;
+ udata->xpres = xpr;
- /* Now fire up the parser */
- pgxml_mhs_init();
+ /* Now fire up the parser */
+ pgxml_mhs_init();
- p = XML_ParserCreate_MM(NULL,&mhs,NULL);
- if (! p) {
- elog(ERROR, "pgxml: Could not create expat parser");
- pfree(xpr);
- pfree(udata->path);
- pfree(udata);
- pfree(res);
- return NULL;
- }
- XML_SetUserData(p, (void *)udata);
-
- /* Set the handlers */
-
- XML_SetElementHandler(p, pgxml_starthandler, pgxml_endhandler);
- XML_SetCharacterDataHandler(p, pgxml_charhandler);
-
- if (! XML_Parse(p, (char *)VARDATA(doc) , docsize, 1)) {
- /* elog(NOTICE, "Parse error at line %d:%s",
- XML_GetCurrentLineNumber(p),
- XML_ErrorString(XML_GetErrorCode(p))); */
- XML_ParserFree(p);
- pfree(xpr);
- pfree(udata->path);
- pfree(udata);
-
- return NULL;
- }
+ p = XML_ParserCreate_MM(NULL, &mhs, NULL);
+ if (!p)
+ {
+ elog(ERROR, "pgxml: Could not create expat parser");
+ pfree(xpr);
+ pfree(udata->path);
+ pfree(udata);
+ pfree(res);
+ return NULL;
+ }
+ XML_SetUserData(p, (void *) udata);
+
+ /* Set the handlers */
+
+ XML_SetElementHandler(p, pgxml_starthandler, pgxml_endhandler);
+ XML_SetCharacterDataHandler(p, pgxml_charhandler);
+
+ if (!XML_Parse(p, (char *) VARDATA(doc), docsize, 1))
+ {
+ /*
+ * elog(NOTICE, "Parse error at line %d:%s",
+ * XML_GetCurrentLineNumber(p),
+ * XML_ErrorString(XML_GetErrorCode(p)));
+ */
+ XML_ParserFree(p);
+ pfree(xpr);
+ pfree(udata->path);
+ pfree(udata);
+
+ return NULL;
+ }
- pfree(udata->path);
- pfree(udata);
- XML_ParserFree(p);
- return xpr;
+ pfree(udata->path);
+ pfree(udata);
+ XML_ParserFree(p);
+ return xpr;
}
Datum
pgxml_xpath(PG_FUNCTION_ARGS)
{
- /* called as pgxml_xpath(document,pathstr, index) for the moment*/
+ /* called as pgxml_xpath(document,pathstr, index) for the moment */
+
+ XPath_Results *xpresults;
+ text *restext;
- XPath_Results *xpresults;
- text *restext;
+ text *t = PG_GETARG_TEXT_P(0); /* document buffer */
+ text *t2 = PG_GETARG_TEXT_P(1);
+ int32 ind = PG_GETARG_INT32(2) - 1;
- text *t = PG_GETARG_TEXT_P(0); /*document buffer */
- text *t2= PG_GETARG_TEXT_P(1);
- int32 ind = PG_GETARG_INT32(2) - 1;
+ xpresults = build_xpath_results(t, t2);
- xpresults = build_xpath_results(t,t2);
+ /*
+ * This needs to be changed depending on the mechanism for returning
+ * our set of results.
+ */
- /* This needs to be changed depending on the mechanism for returning
- our set of results. */
+ if (xpresults == NULL) /* parse error (not WF or parser failure) */
+ PG_RETURN_NULL();
- if (xpresults==NULL) /*parse error (not WF or parser failure) */
- {
- PG_RETURN_NULL();
- }
+ if (ind >= (xpresults->rescount))
+ PG_RETURN_NULL();
- if (ind >= (xpresults->rescount))
- {
- PG_RETURN_NULL();
- }
-
- restext = (text *) palloc(xpresults->reslens[ind]+VARHDRSZ);
- memcpy(VARDATA(restext),xpresults->results[ind],xpresults->reslens[ind]);
+ restext = (text *) palloc(xpresults->reslens[ind] + VARHDRSZ);
+ memcpy(VARDATA(restext), xpresults->results[ind], xpresults->reslens[ind]);
- VARATT_SIZEP(restext) = xpresults->reslens[ind]+VARHDRSZ;
+ VARATT_SIZEP(restext) = xpresults->reslens[ind] + VARHDRSZ;
- pfree(xpresults->resbuf);
- pfree(xpresults);
+ pfree(xpresults->resbuf);
+ pfree(xpresults);
- PG_RETURN_TEXT_P(restext);
+ PG_RETURN_TEXT_P(restext);
}
-static void pgxml_pathcompare(void *userData)
+static void
+pgxml_pathcompare(void *userData)
{
- char *matchpos;
-
- matchpos=strstr(UD->currentpath, UD->path);
-
- if (matchpos == NULL) { /* Should we have more logic here ? */
- if (UD->textgrab) {
- UD->textgrab=0;
- pgxml_finalisegrabbedtext(userData);
- }
- return;
- }
- /* OK, we have a match of some sort. Now we need to check that
- our match is anchored to the *end* of the string AND
- that it is immediately preceded by a '/'*/
- /* This test wouldn't work if strlen (UD->path) overran the length
- of the currentpath, but that's not possible because we got a match! */
-
- if ((matchpos + strlen(UD->path))[0]=='\0')
- {
- if ((UD->path)[0]=='/') {
- if (matchpos == UD->currentpath) {
- UD->textgrab=1;
+ char *matchpos;
+
+ matchpos = strstr(UD->currentpath, UD->path);
+
+ if (matchpos == NULL)
+ { /* Should we have more logic here ? */
+ if (UD->textgrab)
+ {
+ UD->textgrab = 0;
+ pgxml_finalisegrabbedtext(userData);
+ }
+ return;
}
- } else {
- if ((matchpos-1)[0]=='/') {
- UD->textgrab=1;
+
+ /*
+ * OK, we have a match of some sort. Now we need to check that our
+ * match is anchored to the *end* of the string AND that it is
+ * immediately preceded by a '/'
+ */
+
+ /*
+ * This test wouldn't work if strlen (UD->path) overran the length of
+ * the currentpath, but that's not possible because we got a match!
+ */
+
+ if ((matchpos + strlen(UD->path))[0] == '\0')
+ {
+ if ((UD->path)[0] == '/')
+ {
+ if (matchpos == UD->currentpath)
+ UD->textgrab = 1;
+ }
+ else
+ {
+ if ((matchpos - 1)[0] == '/')
+ UD->textgrab = 1;
+ }
}
- }
- }
}
-static void pgxml_starthandler(void *userData, const XML_Char *name,
- const XML_Char **atts)
+static void
+pgxml_starthandler(void *userData, const XML_Char * name,
+ const XML_Char ** atts)
{
- char sepstr[]="/";
-
- if ((strlen(name)+strlen(UD->currentpath))>MAXPATHLENGTH-2) {
- elog(NOTICE,"Path too long");
- } else {
- strncat(UD->currentpath,sepstr,1);
- strcat(UD->currentpath, name);
- }
- if (UD->textgrab)
- {
- /* Depending on user preference, should we "reconstitute"
- the element into the result text?
- */
- } else {
- pgxml_pathcompare(userData);
- }
+ char sepstr[] = "/";
+
+ if ((strlen(name) + strlen(UD->currentpath)) > MAXPATHLENGTH - 2)
+ elog(NOTICE, "Path too long");
+ else
+ {
+ strncat(UD->currentpath, sepstr, 1);
+ strcat(UD->currentpath, name);
+ }
+ if (UD->textgrab)
+ {
+ /*
+ * Depending on user preference, should we "reconstitute" the
+ * element into the result text?
+ */
+ }
+ else
+ pgxml_pathcompare(userData);
}
-static void pgxml_endhandler(void *userData, const XML_Char *name)
+static void
+pgxml_endhandler(void *userData, const XML_Char * name)
{
- /* Start by removing the current element off the end of the
- currentpath */
-
- char *sepptr;
-
- sepptr=strrchr(UD->currentpath,'/');
- if (sepptr==NULL) {
- elog(ERROR,"There's a problem...");
- sepptr=UD->currentpath;
- }
- if (strcmp(name, sepptr+1) !=0) {
- elog(NOTICE,"Wanted [%s], got [%s]",sepptr,name);
- /* unmatched entry, so do nothing */
- } else {
- sepptr[0]='\0'; /* Chop that element off the end */
- }
-
- if (UD->textgrab) {
- pgxml_pathcompare(userData);
- }
+ /*
+ * Start by removing the current element off the end of the
+ * currentpath
+ */
+
+ char *sepptr;
+
+ sepptr = strrchr(UD->currentpath, '/');
+ if (sepptr == NULL)
+ {
+ elog(ERROR, "There's a problem...");
+ sepptr = UD->currentpath;
+ }
+ if (strcmp(name, sepptr + 1) != 0)
+ {
+ elog(NOTICE, "Wanted [%s], got [%s]", sepptr, name);
+ /* unmatched entry, so do nothing */
+ }
+ else
+ {
+ sepptr[0] = '\0'; /* Chop that element off the end */
+ }
+
+ if (UD->textgrab)
+ pgxml_pathcompare(userData);
}
-static void pgxml_charhandler(void *userData, const XML_Char *s, int len)
+static void
+pgxml_charhandler(void *userData, const XML_Char * s, int len)
{
- if (UD->textgrab) {
- if (len>0) {
- memcpy(UD->resptr,s,len);
- UD->resptr += len;
- UD->reslen += len;
- }
- }
+ if (UD->textgrab)
+ {
+ if (len > 0)
+ {
+ memcpy(UD->resptr, s, len);
+ UD->resptr += len;
+ UD->reslen += len;
+ }
+ }
}
+
/* Should I be using PG list types here? */
-static void pgxml_finalisegrabbedtext(void *userData)
+static void
+pgxml_finalisegrabbedtext(void *userData)
{
- /* In res/reslen, we have a single result. */
- UD->xpres->results[UD->xpres->rescount]= UD->resptr - UD->reslen;
- UD->xpres->reslens[UD->xpres->rescount]= UD->reslen;
- UD->reslen=0;
- UD->xpres->rescount++;
-
- /* This effectively concatenates all the results together but we
- do know where one ends and the next begins */
+ /* In res/reslen, we have a single result. */
+ UD->xpres->results[UD->xpres->rescount] = UD->resptr - UD->reslen;
+ UD->xpres->reslens[UD->xpres->rescount] = UD->reslen;
+ UD->reslen = 0;
+ UD->xpres->rescount++;
+
+ /*
+ * This effectively concatenates all the results together but we do
+ * know where one ends and the next begins
+ */
}
-
-
-
static void pgxml_pfree(void *ptr);
static void pgxml_mhs_init();
static void pgxml_handler_init();
-Datum pgxml_parse(PG_FUNCTION_ARGS);
-Datum pgxml_xpath(PG_FUNCTION_ARGS);
-static void pgxml_starthandler(void *userData, const XML_Char *name,
- const XML_Char **atts);
-static void pgxml_endhandler(void *userData, const XML_Char *name);
-static void pgxml_charhandler(void *userData, const XML_Char *s, int len);
+Datum pgxml_parse(PG_FUNCTION_ARGS);
+Datum pgxml_xpath(PG_FUNCTION_ARGS);
+static void pgxml_starthandler(void *userData, const XML_Char * name,
+ const XML_Char ** atts);
+static void pgxml_endhandler(void *userData, const XML_Char * name);
+static void pgxml_charhandler(void *userData, const XML_Char * s, int len);
static void pgxml_pathcompare(void *userData);
static void pgxml_finalisegrabbedtext(void *userData);
#define MAXRESULTS 100
-typedef struct {
- int rescount;
- char *results[MAXRESULTS];
- int32 reslens[MAXRESULTS];
- char *resbuf; /* pointer to the result buffer for pfree */
-} XPath_Results;
+typedef struct
+{
+ int rescount;
+ char *results[MAXRESULTS];
+ int32 reslens[MAXRESULTS];
+ char *resbuf; /* pointer to the result buffer for pfree */
+} XPath_Results;
-typedef struct {
- char currentpath[MAXPATHLENGTH];
- char *path;
- int textgrab;
- char *resptr;
- int32 reslen;
- XPath_Results *xpres;
-} pgxml_udata;
+typedef struct
+{
+ char currentpath[MAXPATHLENGTH];
+ char *path;
+ int textgrab;
+ char *resptr;
+ int32 reslen;
+ XPath_Results *xpres;
+} pgxml_udata;
#define UD ((pgxml_udata *) userData)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
static void *pgxml_palloc(size_t size);
static void *pgxml_repalloc(void *ptr, size_t size);
static void pgxml_pfree(void *ptr);
-static char *pgxml_pstrdup(const char* string);
+static char *pgxml_pstrdup(const char *string);
static void pgxml_parser_init();
-static xmlChar *pgxmlNodeSetToText(xmlNodeSetPtr nodeset, xmlDocPtr doc,
- xmlChar *toptagname, xmlChar *septagname,
+static xmlChar *pgxmlNodeSetToText(xmlNodeSetPtr nodeset, xmlDocPtr doc,
+ xmlChar * toptagname, xmlChar * septagname,
int format);
static xmlChar *pgxml_texttoxmlchar(text *textstring);
-Datum pgxml_parse(PG_FUNCTION_ARGS);
-Datum pgxml_xpath(PG_FUNCTION_ARGS);
+Datum pgxml_parse(PG_FUNCTION_ARGS);
+Datum pgxml_xpath(PG_FUNCTION_ARGS);
/* memory handling passthrough functions (e.g. palloc, pstrdup are
currently macros, and the others might become so...) */
-static void *pgxml_palloc(size_t size)
+static void *
+pgxml_palloc(size_t size)
{
- return palloc(size);
+ return palloc(size);
}
-static void *pgxml_repalloc(void *ptr, size_t size)
+static void *
+pgxml_repalloc(void *ptr, size_t size)
{
- return repalloc(ptr,size);
+ return repalloc(ptr, size);
}
-static void pgxml_pfree(void *ptr)
+static void
+pgxml_pfree(void *ptr)
{
- return pfree(ptr);
+ return pfree(ptr);
}
-static char *pgxml_pstrdup(const char *string)
+static char *
+pgxml_pstrdup(const char *string)
{
- return pstrdup(string);
+ return pstrdup(string);
}
-static void pgxml_parser_init()
+static void
+pgxml_parser_init()
{
- /* This code should also set parser settings from user-supplied
- info. Quite how these settings are made is another matter :) */
+ /*
+ * This code should also set parser settings from user-supplied info.
+ * Quite how these settings are made is another matter :)
+ */
- xmlMemSetup(pgxml_pfree, pgxml_palloc, pgxml_repalloc, pgxml_pstrdup);
- xmlInitParser();
+ xmlMemSetup(pgxml_pfree, pgxml_palloc, pgxml_repalloc, pgxml_pstrdup);
+ xmlInitParser();
}
Datum
pgxml_parse(PG_FUNCTION_ARGS)
{
- /* called as pgxml_parse(document) */
- xmlDocPtr doctree;
- text *t = PG_GETARG_TEXT_P(0); /*document buffer */
- int32 docsize = VARSIZE(t) - VARHDRSZ;
-
- pgxml_parser_init();
-
- doctree = xmlParseMemory((char *) VARDATA(t), docsize);
- if (doctree == NULL) {
- /* xmlCleanupParser(); */
- PG_RETURN_BOOL(false); /* i.e. not well-formed */
- }
- /* xmlCleanupParser(); */
- xmlFreeDoc(doctree);
- PG_RETURN_BOOL(true);
+ /* called as pgxml_parse(document) */
+ xmlDocPtr doctree;
+ text *t = PG_GETARG_TEXT_P(0); /* document buffer */
+ int32 docsize = VARSIZE(t) - VARHDRSZ;
+
+ pgxml_parser_init();
+
+ doctree = xmlParseMemory((char *) VARDATA(t), docsize);
+ if (doctree == NULL)
+ {
+ /* xmlCleanupParser(); */
+ PG_RETURN_BOOL(false); /* i.e. not well-formed */
+ }
+ /* xmlCleanupParser(); */
+ xmlFreeDoc(doctree);
+ PG_RETURN_BOOL(true);
}
-static xmlChar
-*pgxmlNodeSetToText(xmlNodeSetPtr nodeset,
- xmlDocPtr doc,
- xmlChar *toptagname,
- xmlChar *septagname,
- int format)
+static xmlChar
+*
+pgxmlNodeSetToText(xmlNodeSetPtr nodeset,
+ xmlDocPtr doc,
+ xmlChar * toptagname,
+ xmlChar * septagname,
+ int format)
{
- /* Function translates a nodeset into a text representation */
- /* iterates over each node in the set and calls xmlNodeDump to write
- it to an xmlBuffer -from which an xmlChar * string is returned. */
- /* each representation is surrounded by ... */
- /* if format==0, add a newline between nodes?? */
-
- xmlBufferPtr buf;
- xmlChar *result;
- int i;
-
- buf =xmlBufferCreate();
-
- if ((toptagname != NULL) && (xmlStrlen(toptagname)>0)) {
- xmlBufferWriteChar(buf,"<");
- xmlBufferWriteCHAR(buf,toptagname);
- xmlBufferWriteChar(buf,">");
- }
- if (nodeset != NULL) {
- for (i=0; i < nodeset->nodeNr; i++) {
- if ((septagname != NULL) && (xmlStrlen(septagname)>0)) {
- xmlBufferWriteChar(buf,"<");
- xmlBufferWriteCHAR(buf,septagname);
- xmlBufferWriteChar(buf,">");
- }
- xmlNodeDump(buf, doc, nodeset->nodeTab[i],1,(format==2));
-
- if ((septagname != NULL) && (xmlStrlen(septagname)>0)) {
- xmlBufferWriteChar(buf,"");
- xmlBufferWriteCHAR(buf,septagname);
- xmlBufferWriteChar(buf,">");
- }
- if (format) {
- xmlBufferWriteChar(buf,"\n");
- }
- }
- }
-
- if ((toptagname != NULL) && (xmlStrlen(toptagname)>0)) {
- xmlBufferWriteChar(buf,"");
- xmlBufferWriteCHAR(buf,toptagname);
- xmlBufferWriteChar(buf,">");
- }
- result = xmlStrdup(buf->content);
- xmlBufferFree(buf);
- return result;
+ /* Function translates a nodeset into a text representation */
+
+ /*
+ * iterates over each node in the set and calls xmlNodeDump to write
+ * it to an xmlBuffer -from which an xmlChar * string is returned.
+ */
+ /* each representation is surrounded by ... */
+ /* if format==0, add a newline between nodes?? */
+
+ xmlBufferPtr buf;
+ xmlChar *result;
+ int i;
+
+ buf = xmlBufferCreate();
+
+ if ((toptagname != NULL) && (xmlStrlen(toptagname) > 0))
+ {
+ xmlBufferWriteChar(buf, "<");
+ xmlBufferWriteCHAR(buf, toptagname);
+ xmlBufferWriteChar(buf, ">");
+ }
+ if (nodeset != NULL)
+ {
+ for (i = 0; i < nodeset->nodeNr; i++)
+ {
+ if ((septagname != NULL) && (xmlStrlen(septagname) > 0))
+ {
+ xmlBufferWriteChar(buf, "<");
+ xmlBufferWriteCHAR(buf, septagname);
+ xmlBufferWriteChar(buf, ">");
+ }
+ xmlNodeDump(buf, doc, nodeset->nodeTab[i], 1, (format == 2));
+
+ if ((septagname != NULL) && (xmlStrlen(septagname) > 0))
+ {
+ xmlBufferWriteChar(buf, "");
+ xmlBufferWriteCHAR(buf, septagname);
+ xmlBufferWriteChar(buf, ">");
+ }
+ if (format)
+ xmlBufferWriteChar(buf, "\n");
+ }
+ }
+
+ if ((toptagname != NULL) && (xmlStrlen(toptagname) > 0))
+ {
+ xmlBufferWriteChar(buf, "");
+ xmlBufferWriteCHAR(buf, toptagname);
+ xmlBufferWriteChar(buf, ">");
+ }
+ result = xmlStrdup(buf->content);
+ xmlBufferFree(buf);
+ return result;
}
-static xmlChar *pgxml_texttoxmlchar(text *textstring) {
- xmlChar *res;
- int32 txsize;
-
- txsize=VARSIZE(textstring)-VARHDRSZ;
- res = (xmlChar *) palloc(txsize+1);
- memcpy((char *)res, VARDATA(textstring), txsize);
- res[txsize]='\0';
- return res;
+static xmlChar *
+pgxml_texttoxmlchar(text *textstring)
+{
+ xmlChar *res;
+ int32 txsize;
+
+ txsize = VARSIZE(textstring) - VARHDRSZ;
+ res = (xmlChar *) palloc(txsize + 1);
+ memcpy((char *) res, VARDATA(textstring), txsize);
+ res[txsize] = '\0';
+ return res;
}
Datum
pgxml_xpath(PG_FUNCTION_ARGS)
{
- xmlDocPtr doctree;
- xmlXPathContextPtr ctxt;
- xmlXPathObjectPtr res;
- xmlChar *xpath, *xpresstr, *toptag, *septag;
- xmlXPathCompExprPtr comppath;
-
- int32 docsize,ressize;
- text *t, *xpres;
-
- t = PG_GETARG_TEXT_P(0); /*document buffer */
- xpath = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(1)); /* XPath expression */
- toptag = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(2));
- septag = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(3));
-
- docsize = VARSIZE(t) - VARHDRSZ;
-
- pgxml_parser_init();
-
- doctree = xmlParseMemory((char *) VARDATA(t), docsize);
- if (doctree == NULL) { /* not well-formed */
- PG_RETURN_NULL();
- }
-
- ctxt = xmlXPathNewContext(doctree);
- ctxt->node = xmlDocGetRootElement(doctree);
-
- /* compile the path */
- comppath = xmlXPathCompile(xpath);
- if (comppath == NULL) {
- elog(NOTICE, "XPath syntax error");
- xmlFreeDoc(doctree);
- pfree((void *) xpath);
- PG_RETURN_NULL();
- }
-
- /* Now evaluate the path expression. */
- res = xmlXPathCompiledEval(comppath,ctxt);
- xmlXPathFreeCompExpr(comppath);
-
- if (res==NULL) {
- xmlFreeDoc(doctree);
- pfree((void *)xpath);
- PG_RETURN_NULL(); /* seems appropriate */
- }
- /* now we dump this node, ?surrounding by tags? */
- /* To do this, we look first at the type */
- switch(res->type) {
- case XPATH_NODESET:
- xpresstr = pgxmlNodeSetToText(res->nodesetval,
- doctree,
- toptag, septag, 0);
- break;
- case XPATH_STRING:
- xpresstr = xmlStrdup(res->stringval);
- break;
- default:
- elog(NOTICE,"Unsupported XQuery result: %d",res->type);
- xpresstr = xmlStrdup("");
- }
-
-
- /* Now convert this result back to text */
- ressize = strlen(xpresstr);
- xpres = (text *) palloc(ressize+VARHDRSZ);
- memcpy(VARDATA(xpres),xpresstr,ressize);
- VARATT_SIZEP(xpres)=ressize + VARHDRSZ;
-
- /* Free various storage */
- xmlFreeDoc(doctree);
- pfree((void *) xpath);
- xmlFree(xpresstr);
-
- PG_RETURN_TEXT_P(xpres);
+ xmlDocPtr doctree;
+ xmlXPathContextPtr ctxt;
+ xmlXPathObjectPtr res;
+ xmlChar *xpath,
+ *xpresstr,
+ *toptag,
+ *septag;
+ xmlXPathCompExprPtr comppath;
+
+ int32 docsize,
+ ressize;
+ text *t,
+ *xpres;
+
+ t = PG_GETARG_TEXT_P(0); /* document buffer */
+ xpath = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(1)); /* XPath expression */
+ toptag = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(2));
+ septag = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(3));
+
+ docsize = VARSIZE(t) - VARHDRSZ;
+
+ pgxml_parser_init();
+
+ doctree = xmlParseMemory((char *) VARDATA(t), docsize);
+ if (doctree == NULL)
+ { /* not well-formed */
+ PG_RETURN_NULL();
+ }
+
+ ctxt = xmlXPathNewContext(doctree);
+ ctxt->node = xmlDocGetRootElement(doctree);
+
+ /* compile the path */
+ comppath = xmlXPathCompile(xpath);
+ if (comppath == NULL)
+ {
+ elog(NOTICE, "XPath syntax error");
+ xmlFreeDoc(doctree);
+ pfree((void *) xpath);
+ PG_RETURN_NULL();
+ }
+
+ /* Now evaluate the path expression. */
+ res = xmlXPathCompiledEval(comppath, ctxt);
+ xmlXPathFreeCompExpr(comppath);
+
+ if (res == NULL)
+ {
+ xmlFreeDoc(doctree);
+ pfree((void *) xpath);
+ PG_RETURN_NULL(); /* seems appropriate */
+ }
+ /* now we dump this node, ?surrounding by tags? */
+ /* To do this, we look first at the type */
+ switch (res->type)
+ {
+ case XPATH_NODESET:
+ xpresstr = pgxmlNodeSetToText(res->nodesetval,
+ doctree,
+ toptag, septag, 0);
+ break;
+ case XPATH_STRING:
+ xpresstr = xmlStrdup(res->stringval);
+ break;
+ default:
+ elog(NOTICE, "Unsupported XQuery result: %d", res->type);
+ xpresstr = xmlStrdup("");
+ }
+
+
+ /* Now convert this result back to text */
+ ressize = strlen(xpresstr);
+ xpres = (text *) palloc(ressize + VARHDRSZ);
+ memcpy(VARDATA(xpres), xpresstr, ressize);
+ VARATT_SIZEP(xpres) = ressize + VARHDRSZ;
+
+ /* Free various storage */
+ xmlFreeDoc(doctree);
+ pfree((void *) xpath);
+ xmlFree(xpresstr);
+
+ PG_RETURN_TEXT_P(xpres);
}
-
-
-
-
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.73 2001/08/23 23:06:37 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.74 2001/10/25 05:49:20 momjian Exp $
*
* NOTES
* The old interface functions have been converted to macros
}
else
{
-
/*
* there's a null somewhere in the tuple
*/
(HeapTupleNoNulls(tuple) || !att_isnull(j, bp)) &&
(HeapTupleAllFixed(tuple) || att[j]->attlen > 0)); j++)
{
-
/*
* Fix me when going to a machine with more than a four-byte
* word!
nulls[i] = ' ';
}
}
-
#endif
/* ----------------
*
* This routine forms a HeapTuple by copying the given structure (tuple
* data) and adding a generic header. Note that the tuple data is
- * presumed to contain no null fields. It is typically only useful
+ * presumed to contain no null fields. It is typically only useful
* for null-free system tables.
* ----------------
*/
td->t_hoff = hoff;
td->t_natts = natts;
- td->t_infomask = HEAP_XMAX_INVALID; /* XXX sufficient? */
+ td->t_infomask = HEAP_XMAX_INVALID; /* XXX sufficient? */
memcpy((char *) td + hoff, structure, structlen);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.54 2001/03/22 06:16:06 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.55 2001/10/25 05:49:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifdef TOAST_INDEX_HACK
Datum untoasted_value[INDEX_MAX_KEYS];
bool untoasted_free[INDEX_MAX_KEYS];
-
#endif
if (numberOfAttributes > INDEX_MAX_KEYS)
for (; j <= attnum; j++)
{
-
/*
* Fix me when going to a machine with more than a four-byte
* word!
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.59 2001/03/22 06:16:06 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.60 2001/10/25 05:49:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
continue;
if (OidIsValid(thisState->typoutput))
{
-
/*
* If we have a toasted datum, forcibly detoast it here to
* avoid memory leakage inside the type's output routine.
if (getTypeOutputInfo(typeinfo->attrs[i]->atttypid,
&typoutput, &typelem, &typisvarlena))
{
-
/*
* If we have a toasted datum, forcibly detoast it here to
* avoid memory leakage inside the type's output routine.
/* send # of bytes, and opaque data */
if (thisState->typisvarlena)
{
-
/*
* If we have a toasted datum, must detoast before sending.
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.75 2001/06/25 21:11:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.76 2001/10/25 05:49:20 momjian Exp $
*
* NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be
Form_pg_attribute attr2 = tupdesc2->attrs[i];
/*
- * We do not need to check every single field here: we can disregard
- * attrelid, attnum (it was used to place the row in the attrs array)
- * and everything derived from the column datatype.
+ * We do not need to check every single field here: we can
+ * disregard attrelid, attnum (it was used to place the row in the
+ * attrs array) and everything derived from the column datatype.
*/
if (strcmp(NameStr(attr1->attname), NameStr(attr2->attname)) != 0)
return false;
0, 0, 0);
if (!HeapTupleIsValid(tuple))
{
-
/*
* here type info does not exist yet so we just fill the attribute
* with dummy information and return false.
typenameTypeId(typename),
atttypmod, attdim, attisset))
{
-
/*
* if TupleDescInitEntry() fails, it means there is no type in
* the system catalogs. So now we check if the type name
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.84 2001/10/06 23:21:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.85 2001/10/25 05:49:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* group flags ( in gistSplit ) */
#define LEFT_ADDED 0x01
-#define RIGHT_ADDED 0x02
+#define RIGHT_ADDED 0x02
#define BOTH_ADDED ( LEFT_ADDED | RIGHT_ADDED )
/*
* This defines only for shorter code, used in gistgetadjusted
* and gistadjsubkey only
*/
-#define FILLITEM(evp, isnullkey, okey, okeyb, rkey, rkeyb) do { \
- if ( isnullkey ) { \
- gistentryinit((evp), rkey, r, (Page) NULL , \
- (OffsetNumber) 0, rkeyb, FALSE); \
- } else { \
- gistentryinit((evp), okey, r, (Page) NULL, \
- (OffsetNumber) 0, okeyb, FALSE); \
- } \
+#define FILLITEM(evp, isnullkey, okey, okeyb, rkey, rkeyb) do { \
+ if ( isnullkey ) { \
+ gistentryinit((evp), rkey, r, (Page) NULL , \
+ (OffsetNumber) 0, rkeyb, FALSE); \
+ } else { \
+ gistentryinit((evp), okey, r, (Page) NULL, \
+ (OffsetNumber) 0, okeyb, FALSE); \
+ } \
} while(0)
#define FILLEV(isnull1, key1, key1b, isnull2, key2, key2b) do { \
- FILLITEM(*ev0p, isnull1, key1, key1b, key2, key2b); \
- FILLITEM(*ev1p, isnull2, key2, key2b, key1, key1b); \
+ FILLITEM(*ev0p, isnull1, key1, key1b, key2, key2b); \
+ FILLITEM(*ev1p, isnull2, key2, key2b, key1, key1b); \
} while(0);
/* Working state for gistbuild and its callback */
/* non-export function prototypes */
static void gistbuildCallback(Relation index,
- HeapTuple htup,
- Datum *attdata,
- char *nulls,
- bool tupleIsAlive,
- void *state);
+ HeapTuple htup,
+ Datum *attdata,
+ char *nulls,
+ bool tupleIsAlive,
+ void *state);
static void gistdoinsert(Relation r,
IndexTuple itup,
InsertIndexResult *res,
IndexTuple oldtup,
IndexTuple addtup,
GISTSTATE *giststate);
-static int gistfindgroup( GISTSTATE *giststate,
- GISTENTRY *valvec, GIST_SPLITVEC * spl );
+static int gistfindgroup(GISTSTATE *giststate,
+ GISTENTRY *valvec, GIST_SPLITVEC *spl);
static void gistadjsubkey(Relation r,
- IndexTuple *itup, int *len,
- GIST_SPLITVEC *v,
- GISTSTATE *giststate);
-static IndexTuple gistFormTuple( GISTSTATE *giststate,
- Relation r, Datum attdata[], int datumsize[], bool isnull[] );
+ IndexTuple *itup, int *len,
+ GIST_SPLITVEC *v,
+ GISTSTATE *giststate);
+static IndexTuple gistFormTuple(GISTSTATE *giststate,
+ Relation r, Datum attdata[], int datumsize[], bool isnull[]);
static IndexTuple *gistSplit(Relation r,
Buffer buffer,
IndexTuple *itup,
IndexTuple it,
GISTSTATE *giststate);
static void gistdelete(Relation r, ItemPointer tid);
+
#ifdef GIST_PAGEADDITEM
static IndexTuple gist_tuple_replacekey(Relation r,
GISTENTRY entry, IndexTuple t);
GISTENTRY *e, Datum k,
Relation r, Page pg,
OffsetNumber o, int b, bool l, bool isNull);
-static void gistDeCompressAtt( GISTSTATE *giststate, Relation r,
- IndexTuple tuple, Page p, OffsetNumber o,
- GISTENTRY attdata[], bool decompvec[], bool isnull[] );
-static void gistFreeAtt( Relation r, GISTENTRY attdata[], bool decompvec[] );
-static void gistpenalty( GISTSTATE *giststate, int attno,
+static void gistDeCompressAtt(GISTSTATE *giststate, Relation r,
+ IndexTuple tuple, Page p, OffsetNumber o,
+ GISTENTRY attdata[], bool decompvec[], bool isnull[]);
+static void gistFreeAtt(Relation r, GISTENTRY attdata[], bool decompvec[]);
+static void gistpenalty(GISTSTATE *giststate, int attno,
GISTENTRY *key1, bool isNull1,
- GISTENTRY *key2, bool isNull2,
- float *penalty );
+ GISTENTRY *key2, bool isNull2,
+ float *penalty);
+
#undef GISTDEBUG
#ifdef GISTDEBUG
/* do the heap scan */
reltuples = IndexBuildHeapScan(heap, index, indexInfo,
- gistbuildCallback, (void *) &buildstate);
+ gistbuildCallback, (void *) &buildstate);
/* okay, all heap tuples are indexed */
UpdateStats(irelid, buildstate.indtuples);
}
- freeGISTstate( &buildstate.giststate );
+ freeGISTstate(&buildstate.giststate);
#ifdef GISTDEBUG
gist_dumptree(index, 0, GISTP_ROOT, 0);
#endif
bool tupleIsAlive,
void *state)
{
- GISTBuildState *buildstate = (GISTBuildState *) state;
+ GISTBuildState *buildstate = (GISTBuildState *) state;
IndexTuple itup;
bool compvec[INDEX_MAX_KEYS];
GISTENTRY tmpcentry;
int i;
- /* GiST cannot index tuples with leading NULLs */
- if ( nulls[0] == 'n' )
- return;
+ /* GiST cannot index tuples with leading NULLs */
+ if (nulls[0] == 'n')
+ return;
/* immediately compress keys to normalize */
for (i = 0; i < buildstate->numindexattrs; i++)
{
- if ( nulls[i]=='n' ) {
+ if (nulls[i] == 'n')
+ {
attdata[i] = (Datum) 0;
compvec[i] = FALSE;
- } else {
+ }
+ else
+ {
gistcentryinit(&buildstate->giststate, i, &tmpcentry, attdata[i],
- (Relation) NULL, (Page) NULL, (OffsetNumber) 0,
- -1 /* size is currently bogus */ , TRUE, FALSE);
+ (Relation) NULL, (Page) NULL, (OffsetNumber) 0,
+ -1 /* size is currently bogus */ , TRUE, FALSE);
if (attdata[i] != tmpcentry.key &&
- !( isAttByVal(&buildstate->giststate, i)))
+ !(isAttByVal(&buildstate->giststate, i)))
compvec[i] = TRUE;
else
compvec[i] = FALSE;
/*
* Since we already have the index relation locked, we call
- * gistdoinsert directly. Normal access method calls dispatch
- * through gistinsert, which locks the relation for write. This
- * is the right thing to do if you're inserting single tups, but
- * not when you're initializing the whole index at once.
+ * gistdoinsert directly. Normal access method calls dispatch through
+ * gistinsert, which locks the relation for write. This is the right
+ * thing to do if you're inserting single tups, but not when you're
+ * initializing the whole index at once.
*/
gistdoinsert(index, itup, NULL, &buildstate->giststate);
Datum *datum = (Datum *) PG_GETARG_POINTER(1);
char *nulls = (char *) PG_GETARG_POINTER(2);
ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3);
+
#ifdef NOT_USED
Relation heapRel = (Relation) PG_GETARG_POINTER(4);
#endif
/*
* Since GIST is not marked "amconcurrent" in pg_am, caller should
- * have acquired exclusive lock on index relation. We need no locking
+ * have acquired exclusive lock on index relation. We need no locking
* here.
*/
- /* GiST cannot index tuples with leading NULLs */
- if ( nulls[0] == 'n' ) {
+ /* GiST cannot index tuples with leading NULLs */
+ if (nulls[0] == 'n')
+ {
res = NULL;
PG_RETURN_POINTER(res);
- }
+ }
initGISTstate(&giststate, r);
/* immediately compress keys to normalize */
for (i = 0; i < r->rd_att->natts; i++)
{
- if ( nulls[i]=='n' ) {
+ if (nulls[i] == 'n')
+ {
datum[i] = (Datum) 0;
compvec[i] = FALSE;
- } else {
+ }
+ else
+ {
gistcentryinit(&giststate, i, &tmpentry, datum[i],
- (Relation) NULL, (Page) NULL, (OffsetNumber) 0,
- -1 /* size is currently bogus */ , TRUE, FALSE );
- if (datum[i] != tmpentry.key && !( isAttByVal( &giststate, i)))
+ (Relation) NULL, (Page) NULL, (OffsetNumber) 0,
+ -1 /* size is currently bogus */ , TRUE, FALSE);
+ if (datum[i] != tmpentry.key && !(isAttByVal(&giststate, i)))
compvec[i] = TRUE;
else
compvec[i] = FALSE;
if (compvec[i] == TRUE)
pfree(DatumGetPointer(datum[i]));
pfree(itup);
- freeGISTstate( &giststate );
+ freeGISTstate(&giststate);
PG_RETURN_POINTER(res);
}
* offset for insertion
*/
datum = index_getattr(itup, 1, r->rd_att, &IsNull);
- gistdentryinit(giststate, 0,dentry, datum,
+ gistdentryinit(giststate, 0, dentry, datum,
(Relation) 0, (Page) 0,
(OffsetNumber) InvalidOffsetNumber,
- ATTSIZE( datum, r, 1, IsNull ),
+ ATTSIZE(datum, r, 1, IsNull),
FALSE, IsNull);
- gistcentryinit(giststate, 0,&tmpcentry, dentry->key, r, page,
+ gistcentryinit(giststate, 0, &tmpcentry, dentry->key, r, page,
offsetNumber, dentry->bytes, FALSE);
*newtup = gist_tuple_replacekey(r, tmpcentry, itup);
retval = PageAddItem(page, (Item) *newtup, IndexTupleSize(*newtup),
/* be tidy */
if (DatumGetPointer(tmpcentry.key) != NULL &&
tmpcentry.key != dentry->key &&
- tmpcentry.key != datum )
+ tmpcentry.key != datum)
pfree(DatumGetPointer(tmpcentry.key));
return (retval);
}
if (!(ret & SPLITED))
{
IndexTuple newtup = gistgetadjusted(r, oldtup, (*itup)[0], giststate);
+
if (!newtup)
{
/* not need to update key */
if (gistnospace(page, (*itup), *len))
{
/* no space for insertion */
- IndexTuple *itvec, *newitup;
- int tlen,oldlen;
+ IndexTuple *itvec,
+ *newitup;
+ int tlen,
+ oldlen;
ret |= SPLITED;
itvec = gistreadbuffer(r, buffer, &tlen);
(opaque->flags & F_LEAF) ? res : NULL); /* res only for
* inserting in leaf */
ReleaseBuffer(buffer);
- do
- pfree( (*itup)[ oldlen-1 ] );
- while ( (--oldlen) > 0 );
+ do
+ pfree((*itup)[oldlen - 1]);
+ while ((--oldlen) > 0);
pfree((*itup));
pfree(itvec);
*itup = newitup;
* parent
*/
IndexTuple newtup = gistunion(r, (*itup), *len, giststate);
- ItemPointerSet(&(newtup->t_tid), blkno, 1);
+
+ ItemPointerSet(&(newtup->t_tid), blkno, 1);
for (i = 0; i < *len; i++)
pfree((*itup)[i]);
{
OffsetNumber l = InvalidOffsetNumber;
int i;
+
#ifdef GIST_PAGEADDITEM
GISTENTRY tmpdentry;
IndexTuple newtup;
- bool IsNull;
+ bool IsNull;
#endif
for (i = 0; i < len; i++)
{
off, LP_USED, &tmpdentry, &newtup);
off = OffsetNumberNext(off);
if (DatumGetPointer(tmpdentry.key) != NULL &&
- tmpdentry.key != index_getattr(itup[i], 1, r->rd_att, &IsNull))
+ tmpdentry.key != index_getattr(itup[i], 1, r->rd_att, &IsNull))
pfree(DatumGetPointer(tmpdentry.key));
if (itup[i] != newtup)
pfree(newtup);
#else
l = PageAddItem(page, (Item) itup[i], IndexTupleSize(itup[i]),
- off, LP_USED);
+ off, LP_USED);
if (l == InvalidOffsetNumber)
elog(ERROR, "gist: failed to add index item to %s",
RelationGetRelationName(r));
*len = maxoff;
itvec = palloc(sizeof(IndexTuple) * maxoff);
for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
- itvec[i-1] = (IndexTuple) PageGetItem(p, PageGetItemId(p, i));
+ itvec[i - 1] = (IndexTuple) PageGetItem(p, PageGetItemId(p, i));
return itvec;
}
* return union of itup vector
*/
static IndexTuple
-gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate) {
+gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
+{
Datum attr[INDEX_MAX_KEYS];
- bool whatfree[INDEX_MAX_KEYS];
+ bool whatfree[INDEX_MAX_KEYS];
char isnull[INDEX_MAX_KEYS];
bytea *evec;
Datum datum;
int datumsize,
- i,j;
+ i,
+ j;
GISTENTRY centry[INDEX_MAX_KEYS];
- bool *needfree;
- IndexTuple newtup;
- bool IsNull;
- int reallen;
+ bool *needfree;
+ IndexTuple newtup;
+ bool IsNull;
+ int reallen;
- needfree = (bool *) palloc((( len==1 ) ? 2 : len ) * sizeof(bool));
- evec = (bytea *) palloc((( len==1 ) ? 2 : len ) * sizeof(GISTENTRY) + VARHDRSZ);
+ needfree = (bool *) palloc(((len == 1) ? 2 : len) * sizeof(bool));
+ evec = (bytea *) palloc(((len == 1) ? 2 : len) * sizeof(GISTENTRY) + VARHDRSZ);
- for (j = 0; j < r->rd_att->natts; j++) {
- reallen=0;
- for (i = 0; i < len; i++) {
- datum = index_getattr(itvec[i], j+1, giststate->tupdesc, &IsNull);
- if ( IsNull ) continue;
+ for (j = 0; j < r->rd_att->natts; j++)
+ {
+ reallen = 0;
+ for (i = 0; i < len; i++)
+ {
+ datum = index_getattr(itvec[i], j + 1, giststate->tupdesc, &IsNull);
+ if (IsNull)
+ continue;
gistdentryinit(giststate, j,
&((GISTENTRY *) VARDATA(evec))[reallen],
datum,
- (Relation) NULL, (Page) NULL, (OffsetNumber) NULL,
- ATTSIZE( datum, giststate->tupdesc, j+1, IsNull ), FALSE, IsNull);
- if ( (!isAttByVal(giststate,j)) &&
- ((GISTENTRY *) VARDATA(evec))[reallen].key != datum )
+ (Relation) NULL, (Page) NULL, (OffsetNumber) NULL,
+ ATTSIZE(datum, giststate->tupdesc, j + 1, IsNull), FALSE, IsNull);
+ if ((!isAttByVal(giststate, j)) &&
+ ((GISTENTRY *) VARDATA(evec))[reallen].key != datum)
needfree[reallen] = TRUE;
else
needfree[reallen] = FALSE;
reallen++;
}
- if ( reallen == 0 ) {
+ if (reallen == 0)
+ {
attr[j] = (Datum) 0;
isnull[j] = 'n';
whatfree[j] = FALSE;
- } else {
- if ( reallen == 1 ) {
+ }
+ else
+ {
+ if (reallen == 1)
+ {
VARATT_SIZEP(evec) = 2 * sizeof(GISTENTRY) + VARHDRSZ;
- gistentryinit(((GISTENTRY *) VARDATA(evec))[1],
- ((GISTENTRY *) VARDATA(evec))[0].key, r, (Page) NULL,
- (OffsetNumber) 0, ((GISTENTRY *) VARDATA(evec))[0].bytes, FALSE);
+ gistentryinit(((GISTENTRY *) VARDATA(evec))[1],
+ ((GISTENTRY *) VARDATA(evec))[0].key, r, (Page) NULL,
+ (OffsetNumber) 0, ((GISTENTRY *) VARDATA(evec))[0].bytes, FALSE);
- } else {
- VARATT_SIZEP(evec) = reallen * sizeof(GISTENTRY) + VARHDRSZ;
}
+ else
+ VARATT_SIZEP(evec) = reallen * sizeof(GISTENTRY) + VARHDRSZ;
datum = FunctionCall2(&giststate->unionFn[j],
- PointerGetDatum(evec),
- PointerGetDatum(&datumsize));
-
+ PointerGetDatum(evec),
+ PointerGetDatum(&datumsize));
+
for (i = 0; i < reallen; i++)
- if ( needfree[i] )
+ if (needfree[i])
pfree(DatumGetPointer(((GISTENTRY *) VARDATA(evec))[i].key));
gistcentryinit(giststate, j, ¢ry[j], datum,
- (Relation) NULL, (Page) NULL, (OffsetNumber) NULL,
- datumsize, FALSE, FALSE);
+ (Relation) NULL, (Page) NULL, (OffsetNumber) NULL,
+ datumsize, FALSE, FALSE);
isnull[j] = ' ';
- attr[j] = centry[j].key;
- if ( !isAttByVal( giststate, j ) ) {
+ attr[j] = centry[j].key;
+ if (!isAttByVal(giststate, j))
+ {
whatfree[j] = TRUE;
- if ( centry[j].key != datum )
+ if (centry[j].key != datum)
pfree(DatumGetPointer(datum));
- } else
+ }
+ else
whatfree[j] = FALSE;
}
}
newtup = (IndexTuple) index_formtuple(giststate->tupdesc, attr, isnull);
for (j = 0; j < r->rd_att->natts; j++)
- if ( whatfree[j] )
+ if (whatfree[j])
pfree(DatumGetPointer(attr[j]));
return newtup;
bytea *evec;
Datum datum;
int datumsize;
- bool result, neednew = false;
+ bool result,
+ neednew = false;
char isnull[INDEX_MAX_KEYS],
whatfree[INDEX_MAX_KEYS];
Datum attr[INDEX_MAX_KEYS];
bool olddec[INDEX_MAX_KEYS],
adddec[INDEX_MAX_KEYS];
bool oldisnull[INDEX_MAX_KEYS],
- addisnull[INDEX_MAX_KEYS];
+ addisnull[INDEX_MAX_KEYS];
IndexTuple newtup = NULL;
- int j;
+ int j;
evec = (bytea *) palloc(2 * sizeof(GISTENTRY) + VARHDRSZ);
VARATT_SIZEP(evec) = 2 * sizeof(GISTENTRY) + VARHDRSZ;
ev0p = &((GISTENTRY *) VARDATA(evec))[0];
ev1p = &((GISTENTRY *) VARDATA(evec))[1];
-
- gistDeCompressAtt( giststate, r, oldtup, (Page) NULL,
- (OffsetNumber) 0, oldatt, olddec, oldisnull);
- gistDeCompressAtt( giststate, r, addtup, (Page) NULL,
- (OffsetNumber) 0, addatt, adddec, addisnull);
+ gistDeCompressAtt(giststate, r, oldtup, (Page) NULL,
+ (OffsetNumber) 0, oldatt, olddec, oldisnull);
+
+ gistDeCompressAtt(giststate, r, addtup, (Page) NULL,
+ (OffsetNumber) 0, addatt, adddec, addisnull);
+
-
- for( j=0; jrd_att->natts; j++ ) {
- if ( oldisnull[j] && addisnull[j] ) {
+ for (j = 0; j < r->rd_att->natts; j++)
+ {
+ if (oldisnull[j] && addisnull[j])
+ {
isnull[j] = 'n';
attr[j] = (Datum) 0;
whatfree[j] = FALSE;
- } else {
+ }
+ else
+ {
FILLEV(
- oldisnull[j], oldatt[j].key, oldatt[j].bytes,
- addisnull[j], addatt[j].key, addatt[j].bytes
- );
-
+ oldisnull[j], oldatt[j].key, oldatt[j].bytes,
+ addisnull[j], addatt[j].key, addatt[j].bytes
+ );
+
datum = FunctionCall2(&giststate->unionFn[j],
- PointerGetDatum(evec),
- PointerGetDatum(&datumsize));
+ PointerGetDatum(evec),
+ PointerGetDatum(&datumsize));
- if ( oldisnull[j] || addisnull[j] ) {
- if ( oldisnull[j] )
+ if (oldisnull[j] || addisnull[j])
+ {
+ if (oldisnull[j])
neednew = true;
- } else {
+ }
+ else
+ {
FunctionCall3(&giststate->equalFn[j],
- ev0p->key,
- datum,
- PointerGetDatum(&result));
-
- if ( !result )
+ ev0p->key,
+ datum,
+ PointerGetDatum(&result));
+
+ if (!result)
neednew = true;
}
- if ( olddec[j] ) pfree( DatumGetPointer(oldatt[j].key) );
- if ( adddec[j] ) pfree( DatumGetPointer(addatt[j].key) );
+ if (olddec[j])
+ pfree(DatumGetPointer(oldatt[j].key));
+ if (adddec[j])
+ pfree(DatumGetPointer(addatt[j].key));
gistcentryinit(giststate, j, ¢ry[j], datum,
- (Relation) NULL, (Page) NULL, (OffsetNumber) NULL,
- datumsize, FALSE, FALSE);
-
+ (Relation) NULL, (Page) NULL, (OffsetNumber) NULL,
+ datumsize, FALSE, FALSE);
+
isnull[j] = ' ';
- attr[j] = centry[j].key;
- if ( (!isAttByVal( giststate, j ) ) ) {
+ attr[j] = centry[j].key;
+ if ((!isAttByVal(giststate, j)))
+ {
whatfree[j] = TRUE;
- if ( centry[j].key != datum )
+ if (centry[j].key != datum)
pfree(DatumGetPointer(datum));
- } else
+ }
+ else
whatfree[j] = FALSE;
}
- }
+ }
pfree(evec);
- if (neednew) {
+ if (neednew)
+ {
/* need to update key */
newtup = (IndexTuple) index_formtuple(giststate->tupdesc, attr, isnull);
newtup->t_tid = oldtup->t_tid;
}
-
+
for (j = 0; j < r->rd_att->natts; j++)
- if ( whatfree[j] )
+ if (whatfree[j])
pfree(DatumGetPointer(attr[j]));
return newtup;
}
static void
-gistunionsubkey( Relation r, GISTSTATE *giststate, IndexTuple *itvec, GIST_SPLITVEC * spl ) {
- int i,j,lr;
+gistunionsubkey(Relation r, GISTSTATE *giststate, IndexTuple *itvec, GIST_SPLITVEC *spl)
+{
+ int i,
+ j,
+ lr;
Datum *attr;
- bool *needfree, IsNull;
- int len, *attrsize;
- OffsetNumber *entries;
- bytea *evec;
+ bool *needfree,
+ IsNull;
+ int len,
+ *attrsize;
+ OffsetNumber *entries;
+ bytea *evec;
Datum datum;
- int datumsize;
- int reallen;
- bool *isnull;
+ int datumsize;
+ int reallen;
+ bool *isnull;
- for(lr=0;lr<=1;lr++) {
- if ( lr ) {
+ for (lr = 0; lr <= 1; lr++)
+ {
+ if (lr)
+ {
attrsize = spl->spl_lattrsize;
attr = spl->spl_lattr;
len = spl->spl_nleft;
entries = spl->spl_left;
isnull = spl->spl_lisnull;
- } else {
+ }
+ else
+ {
attrsize = spl->spl_rattrsize;
attr = spl->spl_rattr;
len = spl->spl_nright;
isnull = spl->spl_risnull;
}
- needfree = (bool *) palloc( (( len==1 ) ? 2 : len ) * sizeof(bool));
- evec = (bytea *) palloc( (( len==1 ) ? 2 : len ) * sizeof(GISTENTRY) + VARHDRSZ);
- for (j = 1; j < r->rd_att->natts; j++) {
+ needfree = (bool *) palloc(((len == 1) ? 2 : len) * sizeof(bool));
+ evec = (bytea *) palloc(((len == 1) ? 2 : len) * sizeof(GISTENTRY) + VARHDRSZ);
+ for (j = 1; j < r->rd_att->natts; j++)
+ {
reallen = 0;
- for (i = 0; i < len; i++) {
- if ( spl->spl_idgrp[ entries[i] ] )
+ for (i = 0; i < len; i++)
+ {
+ if (spl->spl_idgrp[entries[i]])
continue;
- datum = index_getattr(itvec[ entries[i]-1 ], j+1,
+ datum = index_getattr(itvec[entries[i] - 1], j + 1,
giststate->tupdesc, &IsNull);
- if ( IsNull )
+ if (IsNull)
continue;
gistdentryinit(giststate, j,
&((GISTENTRY *) VARDATA(evec))[reallen],
datum,
(Relation) NULL, (Page) NULL,
(OffsetNumber) NULL,
- ATTSIZE( datum, giststate->tupdesc, j+1, IsNull ), FALSE, IsNull);
- if ( (!isAttByVal( giststate, j )) &&
- ((GISTENTRY *) VARDATA(evec))[reallen].key != datum )
+ ATTSIZE(datum, giststate->tupdesc, j + 1, IsNull), FALSE, IsNull);
+ if ((!isAttByVal(giststate, j)) &&
+ ((GISTENTRY *) VARDATA(evec))[reallen].key != datum)
needfree[reallen] = TRUE;
else
needfree[reallen] = FALSE;
reallen++;
-
- }
- if ( reallen == 0 )
+
+ }
+ if (reallen == 0)
{
datum = (Datum) 0;
datumsize = 0;
isnull[j] = true;
- } else {
+ }
+ else
+ {
/*
- * ((GISTENTRY *) VARDATA(evec))[0].bytes may be not defined,
- * so form union with itself
+ * ((GISTENTRY *) VARDATA(evec))[0].bytes may be not
+ * defined, so form union with itself
*/
- if ( reallen == 1 ) {
+ if (reallen == 1)
+ {
VARATT_SIZEP(evec) = 2 * sizeof(GISTENTRY) + VARHDRSZ;
- memcpy( (void*) &((GISTENTRY *) VARDATA(evec))[1],
- (void*) &((GISTENTRY *) VARDATA(evec))[0],
- sizeof( GISTENTRY ) );
- } else
+ memcpy((void *) &((GISTENTRY *) VARDATA(evec))[1],
+ (void *) &((GISTENTRY *) VARDATA(evec))[0],
+ sizeof(GISTENTRY));
+ }
+ else
VARATT_SIZEP(evec) = reallen * sizeof(GISTENTRY) + VARHDRSZ;
datum = FunctionCall2(&giststate->unionFn[j],
- PointerGetDatum(evec),
- PointerGetDatum(&datumsize));
+ PointerGetDatum(evec),
+ PointerGetDatum(&datumsize));
isnull[j] = false;
- }
+ }
for (i = 0; i < reallen; i++)
- if ( needfree[i] )
+ if (needfree[i])
pfree(DatumGetPointer(((GISTENTRY *) VARDATA(evec))[i].key));
-
+
attr[j] = datum;
attrsize[j] = datumsize;
}
}
/*
- * find group in vector with equial value
+ * find group in vector with equial value
*/
static int
-gistfindgroup( GISTSTATE *giststate, GISTENTRY *valvec, GIST_SPLITVEC * spl ) {
- int i,j,len;
- int curid = 1;
- bool result;
-
- /*
- * first key is always not null (see gistinsert),
- * so we may not check for nulls
- */
-
- for(i=0; ispl_nleft; i++) {
- if ( spl->spl_idgrp[ spl->spl_left[i] ]) continue;
+gistfindgroup(GISTSTATE *giststate, GISTENTRY *valvec, GIST_SPLITVEC *spl)
+{
+ int i,
+ j,
+ len;
+ int curid = 1;
+ bool result;
+
+ /*
+ * first key is always not null (see gistinsert), so we may not check
+ * for nulls
+ */
+
+ for (i = 0; i < spl->spl_nleft; i++)
+ {
+ if (spl->spl_idgrp[spl->spl_left[i]])
+ continue;
len = 0;
/* find all equal value in right part */
- for(j=0; j < spl->spl_nright; j++) {
- if ( spl->spl_idgrp[ spl->spl_right[j] ]) continue;
+ for (j = 0; j < spl->spl_nright; j++)
+ {
+ if (spl->spl_idgrp[spl->spl_right[j]])
+ continue;
FunctionCall3(&giststate->equalFn[0],
- valvec[ spl->spl_left[i] ].key,
- valvec[ spl->spl_right[j] ].key,
+ valvec[spl->spl_left[i]].key,
+ valvec[spl->spl_right[j]].key,
PointerGetDatum(&result));
- if ( result ) {
- spl->spl_idgrp[ spl->spl_right[j] ] = curid;
+ if (result)
+ {
+ spl->spl_idgrp[spl->spl_right[j]] = curid;
len++;
}
}
/* find all other equal value in left part */
- if ( len ) {
- /* add current val to list of equial values*/
- spl->spl_idgrp[ spl->spl_left[i] ]=curid;
+ if (len)
+ {
+ /* add current val to list of equial values */
+ spl->spl_idgrp[spl->spl_left[i]] = curid;
/* searching .. */
- for(j=i+1; j < spl->spl_nleft; j++) {
- if ( spl->spl_idgrp[ spl->spl_left[j] ]) continue;
+ for (j = i + 1; j < spl->spl_nleft; j++)
+ {
+ if (spl->spl_idgrp[spl->spl_left[j]])
+ continue;
FunctionCall3(&giststate->equalFn[0],
- valvec[ spl->spl_left[i] ].key,
- valvec[ spl->spl_left[j] ].key,
+ valvec[spl->spl_left[i]].key,
+ valvec[spl->spl_left[j]].key,
PointerGetDatum(&result));
- if ( result ) {
- spl->spl_idgrp[ spl->spl_left[j] ] = curid;
+ if (result)
+ {
+ spl->spl_idgrp[spl->spl_left[j]] = curid;
len++;
}
}
- spl->spl_ngrp[curid] = len+1;
+ spl->spl_ngrp[curid] = len + 1;
curid++;
}
}
*/
static void
gistadjsubkey(Relation r,
- IndexTuple *itup, /* contains compressed entry */
- int *len,
- GIST_SPLITVEC *v,
- GISTSTATE *giststate
- ) {
- int curlen;
- OffsetNumber *curwpos;
- bool decfree[INDEX_MAX_KEYS];
- GISTENTRY entry,identry[INDEX_MAX_KEYS], *ev0p, *ev1p;
- float lpenalty, rpenalty;
- bytea *evec;
- int datumsize;
- bool isnull[INDEX_MAX_KEYS];
- int i,j;
+ IndexTuple *itup, /* contains compressed entry */
+ int *len,
+ GIST_SPLITVEC *v,
+ GISTSTATE *giststate
+)
+{
+ int curlen;
+ OffsetNumber *curwpos;
+ bool decfree[INDEX_MAX_KEYS];
+ GISTENTRY entry,
+ identry[INDEX_MAX_KEYS],
+ *ev0p,
+ *ev1p;
+ float lpenalty,
+ rpenalty;
+ bytea *evec;
+ int datumsize;
+ bool isnull[INDEX_MAX_KEYS];
+ int i,
+ j;
Datum datum;
/* clear vectors */
curlen = v->spl_nleft;
curwpos = v->spl_left;
- for( i=0; ispl_nleft;i++ )
- if ( v->spl_idgrp[ v->spl_left[i] ] == 0 ) {
+ for (i = 0; i < v->spl_nleft; i++)
+ if (v->spl_idgrp[v->spl_left[i]] == 0)
+ {
*curwpos = v->spl_left[i];
curwpos++;
- } else
+ }
+ else
curlen--;
v->spl_nleft = curlen;
curlen = v->spl_nright;
curwpos = v->spl_right;
- for( i=0; ispl_nright;i++ )
- if ( v->spl_idgrp[ v->spl_right[i] ] == 0 ) {
+ for (i = 0; i < v->spl_nright; i++)
+ if (v->spl_idgrp[v->spl_right[i]] == 0)
+ {
*curwpos = v->spl_right[i];
curwpos++;
- } else
+ }
+ else
curlen--;
v->spl_nright = curlen;
ev1p = &((GISTENTRY *) VARDATA(evec))[1];
/* add equivalent tuple */
- for(i = 0; i< *len; i++) {
- if ( v->spl_idgrp[ i+1 ]==0 ) /* already inserted */
+ for (i = 0; i < *len; i++)
+ {
+ if (v->spl_idgrp[i + 1] == 0) /* already inserted */
continue;
- gistDeCompressAtt( giststate, r, itup[i], (Page) NULL, (OffsetNumber) 0,
- identry, decfree, isnull);
+ gistDeCompressAtt(giststate, r, itup[i], (Page) NULL, (OffsetNumber) 0,
+ identry, decfree, isnull);
- v->spl_ngrp[ v->spl_idgrp[ i+1 ] ]--;
- if ( v->spl_ngrp[ v->spl_idgrp[ i+1 ] ] == 0 &&
- (v->spl_grpflag[ v->spl_idgrp[ i+1 ] ] & BOTH_ADDED) != BOTH_ADDED ) {
+ v->spl_ngrp[v->spl_idgrp[i + 1]]--;
+ if (v->spl_ngrp[v->spl_idgrp[i + 1]] == 0 &&
+ (v->spl_grpflag[v->spl_idgrp[i + 1]] & BOTH_ADDED) != BOTH_ADDED)
+ {
/* force last in group */
rpenalty = 1.0;
- lpenalty = ( v->spl_grpflag[ v->spl_idgrp[ i+1 ] ] & LEFT_ADDED ) ? 2.0 : 0.0;
- } else {
- /*where?*/
- for( j=1; jrd_att->natts; j++ ) {
- gistentryinit(entry,v->spl_lattr[j], r, (Page) NULL,
- (OffsetNumber) 0, v->spl_lattrsize[j], FALSE);
- gistpenalty( giststate, j, &entry, v->spl_lisnull[j],
- &identry[j], isnull[j], &lpenalty);
-
- gistentryinit(entry,v->spl_rattr[j], r, (Page) NULL,
- (OffsetNumber) 0, v->spl_rattrsize[j], FALSE);
- gistpenalty( giststate, j, &entry, v->spl_risnull[j],
- &identry[j], isnull[j], &rpenalty);
-
- if ( lpenalty != rpenalty )
+ lpenalty = (v->spl_grpflag[v->spl_idgrp[i + 1]] & LEFT_ADDED) ? 2.0 : 0.0;
+ }
+ else
+ {
+ /* where? */
+ for (j = 1; j < r->rd_att->natts; j++)
+ {
+ gistentryinit(entry, v->spl_lattr[j], r, (Page) NULL,
+ (OffsetNumber) 0, v->spl_lattrsize[j], FALSE);
+ gistpenalty(giststate, j, &entry, v->spl_lisnull[j],
+ &identry[j], isnull[j], &lpenalty);
+
+ gistentryinit(entry, v->spl_rattr[j], r, (Page) NULL,
+ (OffsetNumber) 0, v->spl_rattrsize[j], FALSE);
+ gistpenalty(giststate, j, &entry, v->spl_risnull[j],
+ &identry[j], isnull[j], &rpenalty);
+
+ if (lpenalty != rpenalty)
break;
}
}
/* add */
- if ( lpenalty < rpenalty ) {
- v->spl_grpflag[ v->spl_idgrp[ i+1 ] ] |= LEFT_ADDED;
- v->spl_left[ v->spl_nleft ] = i+1;
+ if (lpenalty < rpenalty)
+ {
+ v->spl_grpflag[v->spl_idgrp[i + 1]] |= LEFT_ADDED;
+ v->spl_left[v->spl_nleft] = i + 1;
v->spl_nleft++;
- for( j=1; jrd_att->natts; j++ ) {
- if ( isnull[j] && v->spl_lisnull[j] ) {
+ for (j = 1; j < r->rd_att->natts; j++)
+ {
+ if (isnull[j] && v->spl_lisnull[j])
+ {
v->spl_lattr[j] = (Datum) 0;
v->spl_lattrsize[j] = 0;
- } else {
+ }
+ else
+ {
FILLEV(
- v->spl_lisnull[j], v->spl_lattr[j], v->spl_lattrsize[j],
- isnull[j], identry[j].key, identry[j].bytes
- );
+ v->spl_lisnull[j], v->spl_lattr[j], v->spl_lattrsize[j],
+ isnull[j], identry[j].key, identry[j].bytes
+ );
datum = FunctionCall2(&giststate->unionFn[j],
- PointerGetDatum(evec),
- PointerGetDatum(&datumsize));
+ PointerGetDatum(evec),
+ PointerGetDatum(&datumsize));
- if ( (!isAttByVal( giststate, j )) && !v->spl_lisnull[j] )
- pfree( DatumGetPointer(v->spl_lattr[j]) );
+ if ((!isAttByVal(giststate, j)) && !v->spl_lisnull[j])
+ pfree(DatumGetPointer(v->spl_lattr[j]));
v->spl_lattr[j] = datum;
v->spl_lattrsize[j] = datumsize;
v->spl_lisnull[j] = false;
}
}
- } else {
- v->spl_grpflag[ v->spl_idgrp[ i+1 ] ] |= RIGHT_ADDED;
- v->spl_right[ v->spl_nright ] = i+1;
+ }
+ else
+ {
+ v->spl_grpflag[v->spl_idgrp[i + 1]] |= RIGHT_ADDED;
+ v->spl_right[v->spl_nright] = i + 1;
v->spl_nright++;
- for( j=1; jrd_att->natts; j++ ) {
- if ( isnull[j] && v->spl_risnull[j] ) {
+ for (j = 1; j < r->rd_att->natts; j++)
+ {
+ if (isnull[j] && v->spl_risnull[j])
+ {
v->spl_rattr[j] = (Datum) 0;
v->spl_rattrsize[j] = 0;
- } else {
+ }
+ else
+ {
FILLEV(
- v->spl_risnull[j], v->spl_rattr[j], v->spl_rattrsize[j],
- isnull[j], identry[j].key, identry[j].bytes
- );
+ v->spl_risnull[j], v->spl_rattr[j], v->spl_rattrsize[j],
+ isnull[j], identry[j].key, identry[j].bytes
+ );
datum = FunctionCall2(&giststate->unionFn[j],
- PointerGetDatum(evec),
- PointerGetDatum(&datumsize));
+ PointerGetDatum(evec),
+ PointerGetDatum(&datumsize));
- if ( (!isAttByVal( giststate, j)) && !v->spl_risnull[j] )
- pfree( DatumGetPointer(v->spl_rattr[j]) );
+ if ((!isAttByVal(giststate, j)) && !v->spl_risnull[j])
+ pfree(DatumGetPointer(v->spl_rattr[j]));
v->spl_rattr[j] = datum;
v->spl_rattrsize[j] = datumsize;
}
}
- }
- gistFreeAtt( r, identry, decfree );
+ }
+ gistFreeAtt(r, identry, decfree);
}
pfree(evec);
}
GIST_SPLITVEC v;
bytea *entryvec;
bool *decompvec;
- int i,j,
+ int i,
+ j,
nlen;
- int MaxGrpId = 1;
+ int MaxGrpId = 1;
Datum datum;
- bool IsNull;
+ bool IsNull;
p = (Page) BufferGetPage(buffer);
opaque = (GISTPageOpaque) PageGetSpecialPointer(p);
for (i = 1; i <= *len; i++)
{
datum = index_getattr(itup[i - 1], 1, giststate->tupdesc, &IsNull);
- gistdentryinit(giststate, 0,&((GISTENTRY *) VARDATA(entryvec))[i],
- datum, r, p, i,
- ATTSIZE( datum, giststate->tupdesc, 1, IsNull ), FALSE, IsNull);
- if ( (!isAttByVal(giststate,0)) && ((GISTENTRY *) VARDATA(entryvec))[i].key != datum )
+ gistdentryinit(giststate, 0, &((GISTENTRY *) VARDATA(entryvec))[i],
+ datum, r, p, i,
+ ATTSIZE(datum, giststate->tupdesc, 1, IsNull), FALSE, IsNull);
+ if ((!isAttByVal(giststate, 0)) && ((GISTENTRY *) VARDATA(entryvec))[i].key != datum)
decompvec[i] = TRUE;
else
decompvec[i] = FALSE;
}
- /* now let the user-defined picksplit function set up the split vector;
- in entryvec have no null value!! */
+ /*
+ * now let the user-defined picksplit function set up the split
+ * vector; in entryvec have no null value!!
+ */
FunctionCall2(&giststate->picksplitFn[0],
PointerGetDatum(entryvec),
PointerGetDatum(&v));
- /* compatibility with old code */
- if ( v.spl_left[ v.spl_nleft-1 ] == InvalidOffsetNumber )
- v.spl_left[ v.spl_nleft-1 ] = (OffsetNumber)*len;
- if ( v.spl_right[ v.spl_nright-1 ] == InvalidOffsetNumber )
- v.spl_right[ v.spl_nright-1 ] = (OffsetNumber)*len;
-
- v.spl_lattr[0] = v.spl_ldatum;
+ /* compatibility with old code */
+ if (v.spl_left[v.spl_nleft - 1] == InvalidOffsetNumber)
+ v.spl_left[v.spl_nleft - 1] = (OffsetNumber) *len;
+ if (v.spl_right[v.spl_nright - 1] == InvalidOffsetNumber)
+ v.spl_right[v.spl_nright - 1] = (OffsetNumber) *len;
+
+ v.spl_lattr[0] = v.spl_ldatum;
v.spl_rattr[0] = v.spl_rdatum;
v.spl_lisnull[0] = false;
v.spl_risnull[0] = false;
- /* if index is multikey, then we must to try get smaller
- * bounding box for subkey(s)
- */
- if ( r->rd_att->natts > 1 ) {
- v.spl_idgrp = (int*) palloc( sizeof(int) * (*len + 1) );
- MemSet((void*)v.spl_idgrp, 0, sizeof(int) * (*len + 1) );
- v.spl_grpflag = (char*) palloc( sizeof(char) * (*len + 1) );
- MemSet((void*)v.spl_grpflag, 0, sizeof(char) * (*len + 1) );
- v.spl_ngrp = (int*) palloc( sizeof(int) * (*len + 1) );
+ /*
+ * if index is multikey, then we must to try get smaller bounding box
+ * for subkey(s)
+ */
+ if (r->rd_att->natts > 1)
+ {
+ v.spl_idgrp = (int *) palloc(sizeof(int) * (*len + 1));
+ MemSet((void *) v.spl_idgrp, 0, sizeof(int) * (*len + 1));
+ v.spl_grpflag = (char *) palloc(sizeof(char) * (*len + 1));
+ MemSet((void *) v.spl_grpflag, 0, sizeof(char) * (*len + 1));
+ v.spl_ngrp = (int *) palloc(sizeof(int) * (*len + 1));
- MaxGrpId = gistfindgroup( giststate, (GISTENTRY *) VARDATA(entryvec), &v );
+ MaxGrpId = gistfindgroup(giststate, (GISTENTRY *) VARDATA(entryvec), &v);
/* form union of sub keys for each page (l,p) */
- gistunionsubkey( r, giststate, itup, &v );
+ gistunionsubkey(r, giststate, itup, &v);
- /* if possible, we insert equivalent tuples
- * with control by penalty for a subkey(s)
- */
- if ( MaxGrpId > 1 )
- gistadjsubkey( r,itup,len, &v, giststate );
+ /*
+ * if possible, we insert equivalent tuples with control by
+ * penalty for a subkey(s)
+ */
+ if (MaxGrpId > 1)
+ gistadjsubkey(r, itup, len, &v, giststate);
- pfree( v.spl_idgrp );
- pfree( v.spl_grpflag );
- pfree( v.spl_ngrp );
- }
+ pfree(v.spl_idgrp);
+ pfree(v.spl_grpflag);
+ pfree(v.spl_ngrp);
+ }
/* clean up the entry vector: its keys need to be deleted, too */
for (i = 1; i <= *len; i++)
lvectup = (IndexTuple *) palloc(sizeof(IndexTuple) * v.spl_nleft);
rvectup = (IndexTuple *) palloc(sizeof(IndexTuple) * v.spl_nright);
- for(i=0; i
- lvectup[i] = itup[ v.spl_left[i] - 1 ];
+ for (i = 0; i < v.spl_nleft; i++)
+ lvectup[i] = itup[v.spl_left[i] - 1];
- for(i=0; i
- rvectup[i] = itup[ v.spl_right[i] - 1 ];
+ for (i = 0; i < v.spl_nright; i++)
+ rvectup[i] = itup[v.spl_right[i] - 1];
/* write on disk (may be need another split) */
newtup = gistSplit(r, rightbuf, rvectup, &nlen, giststate,
(res && rvectup[nlen - 1] == itup[*len - 1]) ? res : NULL);
ReleaseBuffer(rightbuf);
- for( j=1; jrd_att->natts; j++ )
- if ( (!isAttByVal(giststate,j)) && !v.spl_risnull[j] )
- pfree( DatumGetPointer(v.spl_rattr[j]) );
+ for (j = 1; j < r->rd_att->natts; j++)
+ if ((!isAttByVal(giststate, j)) && !v.spl_risnull[j])
+ pfree(DatumGetPointer(v.spl_rattr[j]));
}
else
{
nlen = 1;
newtup = (IndexTuple *) palloc(sizeof(IndexTuple) * 1);
- newtup[0] = gistFormTuple( giststate, r, v.spl_rattr, v.spl_rattrsize, v.spl_risnull );
+ newtup[0] = gistFormTuple(giststate, r, v.spl_rattr, v.spl_rattrsize, v.spl_risnull);
ItemPointerSet(&(newtup[0]->t_tid), rbknum, 1);
}
(res && lvectup[llen - 1] == itup[*len - 1]) ? res : NULL);
ReleaseBuffer(leftbuf);
- for( j=1; jrd_att->natts; j++ )
- if ( (!isAttByVal(giststate,j)) && !v.spl_lisnull[j] )
- pfree( DatumGetPointer(v.spl_lattr[j]) );
+ for (j = 1; j < r->rd_att->natts; j++)
+ if ((!isAttByVal(giststate, j)) && !v.spl_lisnull[j])
+ pfree(DatumGetPointer(v.spl_lattr[j]));
newtup = gistjoinvector(newtup, &nlen, lntup, llen);
pfree(lntup);
nlen += 1;
newtup = (IndexTuple *) repalloc((void *) newtup, sizeof(IndexTuple) * nlen);
- newtup[nlen - 1] = gistFormTuple( giststate, r, v.spl_lattr, v.spl_lattrsize, v.spl_lisnull );
+ newtup[nlen - 1] = gistFormTuple(giststate, r, v.spl_lattr, v.spl_lattrsize, v.spl_lisnull);
ItemPointerSet(&(newtup[nlen - 1]->t_tid), lbknum, 1);
}
Datum datum;
float usize;
OffsetNumber which;
- float sum_grow, which_grow[INDEX_MAX_KEYS];
+ float sum_grow,
+ which_grow[INDEX_MAX_KEYS];
GISTENTRY entry,
identry[INDEX_MAX_KEYS];
- bool IsNull, decompvec[INDEX_MAX_KEYS], isnull[INDEX_MAX_KEYS];
- int j;
+ bool IsNull,
+ decompvec[INDEX_MAX_KEYS],
+ isnull[INDEX_MAX_KEYS];
+ int j;
maxoff = PageGetMaxOffsetNumber(p);
*which_grow = -1.0;
which = -1;
- sum_grow=1;
- gistDeCompressAtt( giststate, r,
- it, (Page) NULL, (OffsetNumber) 0,
- identry, decompvec, isnull );
+ sum_grow = 1;
+ gistDeCompressAtt(giststate, r,
+ it, (Page) NULL, (OffsetNumber) 0,
+ identry, decompvec, isnull);
for (i = FirstOffsetNumber; i <= maxoff && sum_grow; i = OffsetNumberNext(i))
{
- IndexTuple itup = (IndexTuple) PageGetItem(p, PageGetItemId(p, i));
- sum_grow=0;
- for (j=0; jrd_att->natts; j++) {
- datum = index_getattr(itup, j+1, giststate->tupdesc, &IsNull);
- gistdentryinit(giststate, j, &entry, datum, r, p, i, ATTSIZE( datum, giststate->tupdesc, j+1, IsNull ), FALSE, IsNull);
- gistpenalty( giststate, j, &entry, IsNull, &identry[j], isnull[j], &usize);
-
- if ( (!isAttByVal(giststate,j)) && entry.key != datum)
+ IndexTuple itup = (IndexTuple) PageGetItem(p, PageGetItemId(p, i));
+
+ sum_grow = 0;
+ for (j = 0; j < r->rd_att->natts; j++)
+ {
+ datum = index_getattr(itup, j + 1, giststate->tupdesc, &IsNull);
+ gistdentryinit(giststate, j, &entry, datum, r, p, i, ATTSIZE(datum, giststate->tupdesc, j + 1, IsNull), FALSE, IsNull);
+ gistpenalty(giststate, j, &entry, IsNull, &identry[j], isnull[j], &usize);
+
+ if ((!isAttByVal(giststate, j)) && entry.key != datum)
pfree(DatumGetPointer(entry.key));
- if ( which_grow[j]<0 || usize < which_grow[j] ) {
+ if (which_grow[j] < 0 || usize < which_grow[j])
+ {
which = i;
which_grow[j] = usize;
- if ( jrd_att->natts-1 && i==FirstOffsetNumber ) which_grow[j+1]=-1;
- sum_grow += which_grow[j];
- } else if ( which_grow[j] == usize ) {
+ if (j < r->rd_att->natts - 1 && i == FirstOffsetNumber)
+ which_grow[j + 1] = -1;
+ sum_grow += which_grow[j];
+ }
+ else if (which_grow[j] == usize)
sum_grow += usize;
- } else {
- sum_grow=1;
+ else
+ {
+ sum_grow = 1;
break;
}
}
}
- gistFreeAtt( r, identry, decompvec );
+ gistFreeAtt(r, identry, decompvec);
return which;
}
/*
* Since GIST is not marked "amconcurrent" in pg_am, caller should
- * have acquired exclusive lock on index relation. We need no locking
+ * have acquired exclusive lock on index relation. We need no locking
* here.
*/
IndexBulkDeleteCallback callback = (IndexBulkDeleteCallback) PG_GETARG_POINTER(1);
void *callback_state = (void *) PG_GETARG_POINTER(2);
IndexBulkDeleteResult *result;
- BlockNumber num_pages;
+ BlockNumber num_pages;
double tuples_removed;
double num_index_tuples;
RetrieveIndexResult res;
/*
* Since GIST is not marked "amconcurrent" in pg_am, caller should
- * have acquired exclusive lock on index relation. We need no locking
+ * have acquired exclusive lock on index relation. We need no locking
* here.
*/
void
initGISTstate(GISTSTATE *giststate, Relation index)
{
- int i;
+ int i;
if (index->rd_att->natts > INDEX_MAX_KEYS)
elog(ERROR, "initGISTstate: numberOfAttributes %d > %d",
for (i = 0; i < index->rd_att->natts; i++)
{
fmgr_info_copy(&(giststate->consistentFn[i]),
- index_getprocinfo(index, i+1, GIST_CONSISTENT_PROC),
+ index_getprocinfo(index, i + 1, GIST_CONSISTENT_PROC),
CurrentMemoryContext);
fmgr_info_copy(&(giststate->unionFn[i]),
- index_getprocinfo(index, i+1, GIST_UNION_PROC),
+ index_getprocinfo(index, i + 1, GIST_UNION_PROC),
CurrentMemoryContext);
fmgr_info_copy(&(giststate->compressFn[i]),
- index_getprocinfo(index, i+1, GIST_COMPRESS_PROC),
+ index_getprocinfo(index, i + 1, GIST_COMPRESS_PROC),
CurrentMemoryContext);
fmgr_info_copy(&(giststate->decompressFn[i]),
- index_getprocinfo(index, i+1, GIST_DECOMPRESS_PROC),
+ index_getprocinfo(index, i + 1, GIST_DECOMPRESS_PROC),
CurrentMemoryContext);
fmgr_info_copy(&(giststate->penaltyFn[i]),
- index_getprocinfo(index, i+1, GIST_PENALTY_PROC),
+ index_getprocinfo(index, i + 1, GIST_PENALTY_PROC),
CurrentMemoryContext);
fmgr_info_copy(&(giststate->picksplitFn[i]),
- index_getprocinfo(index, i+1, GIST_PICKSPLIT_PROC),
+ index_getprocinfo(index, i + 1, GIST_PICKSPLIT_PROC),
CurrentMemoryContext);
fmgr_info_copy(&(giststate->equalFn[i]),
- index_getprocinfo(index, i+1, GIST_EQUAL_PROC),
+ index_getprocinfo(index, i + 1, GIST_EQUAL_PROC),
CurrentMemoryContext);
}
}
void
-freeGISTstate(GISTSTATE *giststate) {
+freeGISTstate(GISTSTATE *giststate)
+{
/* no work */
}
static IndexTuple
gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t)
{
- bool IsNull;
- Datum datum = index_getattr(t, 1, r->rd_att, &IsNull);
+ bool IsNull;
+ Datum datum = index_getattr(t, 1, r->rd_att, &IsNull);
/*
* If new entry fits in index tuple, copy it in. To avoid worrying
- * about null-value bitmask, pass it off to the general index_formtuple
- * routine if either the previous or new value is NULL.
+ * about null-value bitmask, pass it off to the general
+ * index_formtuple routine if either the previous or new value is
+ * NULL.
*/
if (!IsNull && DatumGetPointer(entry.key) != NULL &&
(Size) entry.bytes <= ATTSIZE(datum, r, 1, IsNull))
Datum k, Relation r, Page pg, OffsetNumber o,
int b, bool l, bool isNull)
{
- if ( b && ! isNull )
+ if (b && !isNull)
{
GISTENTRY *dep;
}
}
else
- {
gistentryinit(*e, (Datum) 0, r, pg, o, 0, l);
- }
}
}
}
else
- {
gistentryinit(*e, (Datum) 0, r, pg, o, 0, l);
- }
}
static IndexTuple
-gistFormTuple( GISTSTATE *giststate, Relation r,
- Datum attdata[], int datumsize[], bool isnull[] )
+gistFormTuple(GISTSTATE *giststate, Relation r,
+ Datum attdata[], int datumsize[], bool isnull[])
{
IndexTuple tup;
- char isnullchar[INDEX_MAX_KEYS];
- bool whatfree[INDEX_MAX_KEYS];
- GISTENTRY centry[INDEX_MAX_KEYS];
- Datum compatt[INDEX_MAX_KEYS];
- int j;
-
- for (j = 0; j < r->rd_att->natts; j++) {
- if ( isnull[j] ) {
+ char isnullchar[INDEX_MAX_KEYS];
+ bool whatfree[INDEX_MAX_KEYS];
+ GISTENTRY centry[INDEX_MAX_KEYS];
+ Datum compatt[INDEX_MAX_KEYS];
+ int j;
+
+ for (j = 0; j < r->rd_att->natts; j++)
+ {
+ if (isnull[j])
+ {
isnullchar[j] = 'n';
compatt[j] = (Datum) 0;
whatfree[j] = FALSE;
- } else {
+ }
+ else
+ {
gistcentryinit(giststate, j, ¢ry[j], attdata[j],
- (Relation) NULL, (Page) NULL, (OffsetNumber) NULL,
- datumsize[j], FALSE, FALSE);
+ (Relation) NULL, (Page) NULL, (OffsetNumber) NULL,
+ datumsize[j], FALSE, FALSE);
isnullchar[j] = ' ';
compatt[j] = centry[j].key;
- if ( !isAttByVal(giststate,j) ) {
+ if (!isAttByVal(giststate, j))
+ {
whatfree[j] = TRUE;
- if ( centry[j].key != attdata[j] )
+ if (centry[j].key != attdata[j])
pfree(DatumGetPointer(attdata[j]));
- } else
+ }
+ else
whatfree[j] = FALSE;
}
}
tup = (IndexTuple) index_formtuple(giststate->tupdesc, compatt, isnullchar);
for (j = 0; j < r->rd_att->natts; j++)
- if ( whatfree[j] ) pfree(DatumGetPointer(compatt[j]));
+ if (whatfree[j])
+ pfree(DatumGetPointer(compatt[j]));
- return tup;
-}
+ return tup;
+}
static void
-gistDeCompressAtt( GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p,
- OffsetNumber o, GISTENTRY attdata[], bool decompvec[], bool isnull[] ) {
- int i;
- Datum datum;
+gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p,
+ OffsetNumber o, GISTENTRY attdata[], bool decompvec[], bool isnull[])
+{
+ int i;
+ Datum datum;
- for(i=0; i < r->rd_att->natts; i++ ) {
- datum = index_getattr(tuple, i+1, giststate->tupdesc, &isnull[i]);
+ for (i = 0; i < r->rd_att->natts; i++)
+ {
+ datum = index_getattr(tuple, i + 1, giststate->tupdesc, &isnull[i]);
gistdentryinit(giststate, i, &attdata[i],
- datum, r, p, o,
- ATTSIZE( datum, giststate->tupdesc, i+1, isnull[i] ), FALSE, isnull[i]);
- if ( isAttByVal(giststate,i) )
+ datum, r, p, o,
+ ATTSIZE(datum, giststate->tupdesc, i + 1, isnull[i]), FALSE, isnull[i]);
+ if (isAttByVal(giststate, i))
decompvec[i] = FALSE;
- else {
- if (attdata[i].key == datum || isnull[i] )
+ else
+ {
+ if (attdata[i].key == datum || isnull[i])
decompvec[i] = FALSE;
else
decompvec[i] = TRUE;
}
}
-}
+}
static void
-gistFreeAtt( Relation r, GISTENTRY attdata[], bool decompvec[] ) {
- int i;
- for(i=0; i < r->rd_att->natts; i++ )
- if ( decompvec[i] )
- pfree( DatumGetPointer(attdata[i].key) );
+gistFreeAtt(Relation r, GISTENTRY attdata[], bool decompvec[])
+{
+ int i;
+
+ for (i = 0; i < r->rd_att->natts; i++)
+ if (decompvec[i])
+ pfree(DatumGetPointer(attdata[i].key));
}
static void
-gistpenalty( GISTSTATE *giststate, int attno,
- GISTENTRY *key1, bool isNull1,
- GISTENTRY *key2, bool isNull2, float *penalty ){
- if ( giststate->penaltyFn[attno].fn_strict && ( isNull1 || isNull2 ) )
- *penalty=0.0;
- else
+gistpenalty(GISTSTATE *giststate, int attno,
+ GISTENTRY *key1, bool isNull1,
+ GISTENTRY *key2, bool isNull2, float *penalty)
+{
+ if (giststate->penaltyFn[attno].fn_strict && (isNull1 || isNull2))
+ *penalty = 0.0;
+ else
FunctionCall3(&giststate->penaltyFn[attno],
- PointerGetDatum(key1),
- PointerGetDatum(key2),
- PointerGetDatum(penalty));
+ PointerGetDatum(key1),
+ PointerGetDatum(key2),
+ PointerGetDatum(penalty));
}
-
+
#ifdef GISTDEBUG
static void
gist_dumptree(Relation r, int level, BlockNumber blk, OffsetNumber coff)
ReleaseBuffer(buffer);
pfree(pred);
}
-
#endif /* defined GISTDEBUG */
void
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.30 2001/08/22 18:24:26 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.31 2001/10/25 05:49:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (key[0].sk_flags & SK_ISNULL)
return false;
*/
- gistdentryinit(giststate, key[0].sk_attno-1, &de,
+ gistdentryinit(giststate, key[0].sk_attno - 1, &de,
datum, r, p, offset,
IndexTupleSize(tuple) - sizeof(IndexTupleData),
FALSE, isNull);
ObjectIdGetDatum(key[0].sk_procedure));
}
- if ( de.key != datum && ! isAttByVal( giststate, key[0].sk_attno-1 ) )
- if ( DatumGetPointer(de.key) != NULL )
- pfree( DatumGetPointer(de.key) );
+ if (de.key != datum && !isAttByVal(giststate, key[0].sk_attno - 1))
+ if (DatumGetPointer(de.key) != NULL)
+ pfree(DatumGetPointer(de.key));
if (DatumGetBool(test) == !!(key[0].sk_flags & SK_NEGATE))
return false;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.39 2001/08/22 18:24:26 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.40 2001/10/25 05:49:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
s->keyData[i].sk_procedure
= RelationGetGISTStrategy(s->relation, s->keyData[i].sk_attno,
s->keyData[i].sk_procedure);
- s->keyData[i].sk_func = p->giststate->consistentFn[s->keyData[i].sk_attno-1];
+ s->keyData[i].sk_func = p->giststate->consistentFn[s->keyData[i].sk_attno - 1];
}
}
else
/*----------
* s->keyData[i].sk_procedure =
- * index_getprocid(s->relation, 1, GIST_CONSISTENT_PROC);
+ * index_getprocid(s->relation, 1, GIST_CONSISTENT_PROC);
*----------
*/
s->keyData[i].sk_procedure
= RelationGetGISTStrategy(s->relation, s->keyData[i].sk_attno,
s->keyData[i].sk_procedure);
- s->keyData[i].sk_func = p->giststate->consistentFn[s->keyData[i].sk_attno-1];
+ s->keyData[i].sk_func = p->giststate->consistentFn[s->keyData[i].sk_attno - 1];
}
}
{
gistfreestack(p->s_stack);
gistfreestack(p->s_markstk);
- if ( p->giststate != NULL )
- freeGISTstate( p->giststate );
+ if (p->giststate != NULL)
+ freeGISTstate(p->giststate);
pfree(s->opaque);
}
}
else
{
-
/*
* remember that we're before the current
* tuple
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/gist/Attic/giststrat.c,v 1.17 2001/05/30 19:53:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/gist/Attic/giststrat.c,v 1.18 2001/10/25 05:49:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
return (RelationInvokeStrategy(r, &GISTEvaluationData, attnum, s,
left, right));
}
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.52 2001/07/15 22:48:15 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.53 2001/10/25 05:49:20 momjian Exp $
*
* NOTES
* This file contains only the public interface routines.
} HashBuildState;
static void hashbuildCallback(Relation index,
- HeapTuple htup,
- Datum *attdata,
- char *nulls,
- bool tupleIsAlive,
- void *state);
+ HeapTuple htup,
+ Datum *attdata,
+ char *nulls,
+ bool tupleIsAlive,
+ void *state);
/*
/* do the heap scan */
reltuples = IndexBuildHeapScan(heap, index, indexInfo,
- hashbuildCallback, (void *) &buildstate);
+ hashbuildCallback, (void *) &buildstate);
/* all done */
BuildingHash = false;
bool tupleIsAlive,
void *state)
{
- HashBuildState *buildstate = (HashBuildState *) state;
+ HashBuildState *buildstate = (HashBuildState *) state;
IndexTuple itup;
HashItem hitem;
InsertIndexResult res;
Datum *datum = (Datum *) PG_GETARG_POINTER(1);
char *nulls = (char *) PG_GETARG_POINTER(2);
ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3);
+
#ifdef NOT_USED
Relation heapRel = (Relation) PG_GETARG_POINTER(4);
#endif
itup->t_tid = *ht_ctid;
/*
- * If the single index key is null, we don't insert it into the
- * index. Hash tables support scans on '='. Relational algebra
- * says that A = B returns null if either A or B is null. This
- * means that no qualification used in an index scan could ever
- * return true on a null attribute. It also means that indices
- * can't be used by ISNULL or NOTNULL scans, but that's an
- * artifact of the strategy map architecture chosen in 1986, not
- * of the way nulls are handled here.
+ * If the single index key is null, we don't insert it into the index.
+ * Hash tables support scans on '='. Relational algebra says that A =
+ * B returns null if either A or B is null. This means that no
+ * qualification used in an index scan could ever return true on a
+ * null attribute. It also means that indices can't be used by ISNULL
+ * or NOTNULL scans, but that's an artifact of the strategy map
+ * architecture chosen in 1986, not of the way nulls are handled here.
*/
if (IndexTupleHasNulls(itup))
{
#ifdef NOT_USED /* XXX surely it's wrong to ignore this? */
bool fromEnd = PG_GETARG_BOOL(1);
-
#endif
ScanKey scankey = (ScanKey) PG_GETARG_POINTER(2);
ItemPointer iptr;
IndexBulkDeleteCallback callback = (IndexBulkDeleteCallback) PG_GETARG_POINTER(1);
void *callback_state = (void *) PG_GETARG_POINTER(2);
IndexBulkDeleteResult *result;
- BlockNumber num_pages;
+ BlockNumber num_pages;
double tuples_removed;
double num_index_tuples;
RetrieveIndexResult res;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.22 2001/03/07 21:20:26 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.23 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
while (PageGetFreeSpace(page) < itemsz)
{
-
/*
* no space on this page; check for an overflow page
*/
if (BlockNumberIsValid(pageopaque->hasho_nextblkno))
{
-
/*
* ovfl page exists; go get it. if it doesn't have room,
* we'll find out next pass through the loop test above.
}
else
{
-
/*
* we're at the end of the bucket chain and we haven't found a
* page with enough room. allocate a new overflow page.
if (res != NULL)
{
-
/*
* Increment the number of keys in the table. We switch lock
* access type just for a moment to allow greater accessibility to
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.30 2001/07/15 22:48:15 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.31 2001/10/25 05:49:21 momjian Exp $
*
* NOTES
* Overflow pages look like ordinary relation pages.
}
else
{
-
/*
* Free_bit addresses the last used bit. Bump it to address the
* first available bit.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.32 2001/07/15 22:48:15 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.33 2001/10/25 05:49:21 momjian Exp $
*
* NOTES
* Postgres hash pages look like ordinary relation pages. The opaque
* system catalogs anyway.
*
* Note that our page locks are actual lockmanager locks, not buffer
- * locks (as are used by btree, for example). This is a good idea because
+ * locks (as are used by btree, for example). This is a good idea because
* the algorithms are not deadlock-free, and we'd better be able to detect
* and recover from deadlocks.
*
{
switch (access)
{
- case HASH_WRITE:
+ case HASH_WRITE:
LockPage(rel, blkno, ExclusiveLock);
break;
case HASH_READ:
{
switch (access)
{
- case HASH_WRITE:
+ case HASH_WRITE:
UnlockPage(rel, blkno, ExclusiveLock);
break;
case HASH_READ:
* It is safe to delete an item after acquiring a regular WRITE lock on
* the page, because no other backend can hold a READ lock on the page,
* and that means no other backend currently has an indexscan stopped on
- * any item of the item being deleted. Our own backend might have such
+ * any item of the item being deleted. Our own backend might have such
* an indexscan (in fact *will*, since that's how VACUUM found the item
* in the first place), but _hash_adjscans will fix the scan position.
*/
_hash_relbuf(rel, obuf, HASH_WRITE);
if (!BlockNumberIsValid(oblkno))
{
-
/*
* the old bucket is completely empty; of course, the new
* bucket will be as well, but since it's a base bucket page
omaxoffnum = PageGetMaxOffsetNumber(opage);
for (;;)
{
-
/*
* at each iteration through this loop, each of these variables
* should be up-to-date: obuf opage oopaque ooffnum omaxoffnum
oblkno = oopaque->hasho_nextblkno;
if (BlockNumberIsValid(oblkno))
{
-
/*
* we ran out of tuples on this particular page, but we
* have more overflow pages; re-init values.
}
else
{
-
/*
* we're at the end of the bucket chain, so now we're
* really done with everything. before quitting, call
if (bucket == nbucket)
{
-
/*
* insert the tuple into the new bucket. if it doesn't fit on
* the current page in the new bucket, we must allocate a new
}
else
{
-
/*
* the tuple stays on this page. we didn't move anything, so
* we didn't delete anything and therefore we don't have to
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.26 2001/03/23 04:49:51 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.27 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (scankey == (ScanKey) NULL ||
(keyDatum = scankey[0].sk_argument) == (Datum) NULL)
{
-
/*
* If the scankey argument is NULL, all tuples will satisfy the
* scan so we start the scan at the first bucket (bucket 0).
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/hash/Attic/hashstrat.c,v 1.18 2001/05/30 19:53:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/hash/Attic/hashstrat.c,v 1.19 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
(StrategyTransformMap) HTNegateCommute,
HTEvaluationExpressions
};
-
#endif
/* ----------------------------------------------------------------
return strat;
}
-
#endif
#ifdef NOT_USED
return (RelationInvokeStrategy(rel, &HTEvaluationData, attno, strat,
left, right));
}
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.125 2001/08/23 23:06:37 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.126 2001/10/25 05:49:21 momjian Exp $
*
*
* INTERFACE ROUTINES
{
ItemId lpp;
Page dp;
- BlockNumber page;
- BlockNumber pages;
+ BlockNumber page;
+ BlockNumber pages;
int lines;
OffsetNumber lineoff;
int linesleft;
/*
* return NULL if we've exhausted all the pages
*/
- if ((dir < 0) ? (page == 0) : (page+1 >= pages))
+ if ((dir < 0) ? (page == 0) : (page + 1 >= pages))
{
if (BufferIsValid(*buffer))
ReleaseBuffer(*buffer);
(
(Datum) NULL
)
- );
+ );
}
-
#endif /* defined(DISABLE_COMPLEX_MACRO) */
if (relation->rd_rel->relhasoids)
{
/*
- * If the object id of this tuple has already been assigned, trust the
- * caller. There are a couple of ways this can happen. At initial db
- * creation, the backend program sets oids for tuples. When we define
- * an index, we set the oid. Finally, in the future, we may allow
- * users to set their own object ids in order to support a persistent
- * object store (objects need to contain pointers to one another).
+ * If the object id of this tuple has already been assigned, trust
+ * the caller. There are a couple of ways this can happen. At
+ * initial db creation, the backend program sets oids for tuples.
+ * When we define an index, we set the oid. Finally, in the
+ * future, we may allow users to set their own object ids in order
+ * to support a persistent object store (objects need to contain
+ * pointers to one another).
*/
if (!OidIsValid(tup->t_data->t_oid))
tup->t_data->t_oid = newoid();
}
/*
- * Now, do we need a new page for the tuple, or not? This is a bit
- * tricky since someone else could have added tuples to the page
- * while we weren't looking. We have to recheck the available space
- * after reacquiring the buffer lock. But don't bother to do that
- * if the former amount of free space is still not enough; it's
- * unlikely there's more free now than before.
+ * Now, do we need a new page for the tuple, or not? This is a
+ * bit tricky since someone else could have added tuples to the
+ * page while we weren't looking. We have to recheck the
+ * available space after reacquiring the buffer lock. But don't
+ * bother to do that if the former amount of free space is still
+ * not enough; it's unlikely there's more free now than before.
*
* What's more, if we need to get a new page, we will need to acquire
- * buffer locks on both old and new pages. To avoid deadlock against
- * some other backend trying to get the same two locks in the other
- * order, we must be consistent about the order we get the locks in.
- * We use the rule "lock the lower-numbered page of the relation
- * first". To implement this, we must do RelationGetBufferForTuple
- * while not holding the lock on the old page, and we must rely on it
- * to get the locks on both pages in the correct order.
+ * buffer locks on both old and new pages. To avoid deadlock
+ * against some other backend trying to get the same two locks in
+ * the other order, we must be consistent about the order we get
+ * the locks in. We use the rule "lock the lower-numbered page of
+ * the relation first". To implement this, we must do
+ * RelationGetBufferForTuple while not holding the lock on the old
+ * page, and we must rely on it to get the locks on both pages in
+ * the correct order.
*/
if (newtupsize > pagefree)
{
{
/*
* Rats, it doesn't fit anymore. We must now unlock and
- * relock to avoid deadlock. Fortunately, this path should
- * seldom be taken.
+ * relock to avoid deadlock. Fortunately, this path
+ * should seldom be taken.
*/
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
newbuf = RelationGetBufferForTuple(relation, newtup->t_len,
pgstat_count_heap_update(&relation->pgstat_info);
/*
- * At this point newbuf and buffer are both pinned and locked,
- * and newbuf has enough space for the new tuple. If they are
- * the same buffer, only one pin is held.
+ * At this point newbuf and buffer are both pinned and locked, and
+ * newbuf has enough space for the new tuple. If they are the same
+ * buffer, only one pin is held.
*/
/* NO ELOG(ERROR) from here till changes are logged */
* Note: xlhdr is declared to have adequate size and correct alignment
* for an xl_heap_header. However the two tids, if present at all,
* will be packed in with no wasted space after the xl_heap_header;
- * they aren't necessarily aligned as implied by this struct declaration.
+ * they aren't necessarily aligned as implied by this struct
+ * declaration.
*/
- struct {
- xl_heap_header hdr;
- TransactionId tid1;
- TransactionId tid2;
+ struct
+ {
+ xl_heap_header hdr;
+ TransactionId tid1;
+ TransactionId tid2;
} xlhdr;
int hsize = SizeOfHeapHeader;
xl_heap_update xlrec;
if (record->xl_len > SizeOfHeapClean)
{
- OffsetNumber unbuf[BLCKSZ/sizeof(OffsetNumber)];
+ OffsetNumber unbuf[BLCKSZ / sizeof(OffsetNumber)];
OffsetNumber *unused = unbuf;
char *unend;
ItemId lp;
if (redo)
{
- struct {
+ struct
+ {
HeapTupleHeaderData hdr;
- char data[MaxTupleSize];
+ char data[MaxTupleSize];
} tbuf;
HeapTupleHeader htup;
xl_heap_header xlhdr;
if (redo)
{
- struct {
+ struct
+ {
HeapTupleHeaderData hdr;
- char data[MaxTupleSize];
+ char data[MaxTupleSize];
} tbuf;
xl_heap_header xlhdr;
int hsize;
*
*
* IDENTIFICATION
- * $Id: hio.c,v 1.42 2001/07/13 22:52:58 tgl Exp $
+ * $Id: hio.c,v 1.43 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* NOTE: it is unlikely, but not quite impossible, for otherBuffer to be the
* same buffer we select for insertion of the new tuple (this could only
* happen if space is freed in that page after heap_update finds there's not
- * enough there). In that case, the page will be pinned and locked only once.
+ * enough there). In that case, the page will be pinned and locked only once.
*
* Note that we use LockPage(rel, 0) to lock relation for extension.
* We can do this as long as in all other places we use page-level locking
if (otherBuffer != InvalidBuffer)
otherBlock = BufferGetBlockNumber(otherBuffer);
else
- otherBlock = InvalidBlockNumber; /* just to keep compiler quiet */
+ otherBlock = InvalidBlockNumber; /* just to keep compiler
+ * quiet */
/*
* We first try to put the tuple on the same page we last inserted a
* tuple on, as cached in the relcache entry. If that doesn't work,
- * we ask the shared Free Space Map to locate a suitable page. Since
+ * we ask the shared Free Space Map to locate a suitable page. Since
* the FSM's info might be out of date, we have to be prepared to loop
* around and retry multiple times. (To insure this isn't an infinite
- * loop, we must update the FSM with the correct amount of free space on
- * each page that proves not to be suitable.) If the FSM has no record of
- * a page with enough free space, we give up and extend the relation.
+ * loop, we must update the FSM with the correct amount of free space
+ * on each page that proves not to be suitable.) If the FSM has no
+ * record of a page with enough free space, we give up and extend the
+ * relation.
*/
targetBlock = relation->rd_targblock;
* target.
*/
targetBlock = GetPageWithFreeSpace(&relation->rd_node, len);
+
/*
* If the FSM knows nothing of the rel, try the last page before
* we give up and extend. This avoids one-tuple-per-page syndrome
*/
if (targetBlock == InvalidBlockNumber)
{
- BlockNumber nblocks = RelationGetNumberOfBlocks(relation);
+ BlockNumber nblocks = RelationGetNumberOfBlocks(relation);
if (nblocks > 0)
targetBlock = nblocks - 1;
while (targetBlock != InvalidBlockNumber)
{
/*
- * Read and exclusive-lock the target block, as well as the
- * other block if one was given, taking suitable care with
- * lock ordering and the possibility they are the same block.
+ * Read and exclusive-lock the target block, as well as the other
+ * block if one was given, taking suitable care with lock ordering
+ * and the possibility they are the same block.
*/
if (otherBuffer == InvalidBuffer)
{
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
LockBuffer(otherBuffer, BUFFER_LOCK_EXCLUSIVE);
}
+
/*
- * Now we can check to see if there's enough free space here.
- * If so, we're done.
+ * Now we can check to see if there's enough free space here. If
+ * so, we're done.
*/
pageHeader = (Page) BufferGetPage(buffer);
pageFreeSpace = PageGetFreeSpace(pageHeader);
relation->rd_targblock = targetBlock;
return buffer;
}
+
/*
- * Not enough space, so we must give up our page locks and
- * pin (if any) and prepare to look elsewhere. We don't care
- * which order we unlock the two buffers in, so this can be
- * slightly simpler than the code above.
+ * Not enough space, so we must give up our page locks and pin (if
+ * any) and prepare to look elsewhere. We don't care which order
+ * we unlock the two buffers in, so this can be slightly simpler
+ * than the code above.
*/
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
if (otherBuffer == InvalidBuffer)
- {
ReleaseBuffer(buffer);
- }
else if (otherBlock != targetBlock)
{
LockBuffer(otherBuffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
}
+
/*
* Update FSM as to condition of this page, and ask for another
* page to try.
/*
* Have to extend the relation.
*
- * We have to use a lock to ensure no one else is extending the
- * rel at the same time, else we will both try to initialize the
- * same new page.
+ * We have to use a lock to ensure no one else is extending the rel at
+ * the same time, else we will both try to initialize the same new
+ * page.
*/
if (!relation->rd_myxactonly)
LockPage(relation, 0, ExclusiveLock);
* XXX This does an lseek - rather expensive - but at the moment it is
* the only way to accurately determine how many blocks are in a
* relation. Is it worth keeping an accurate file length in shared
- * memory someplace, rather than relying on the kernel to do it for us?
+ * memory someplace, rather than relying on the kernel to do it for
+ * us?
*/
buffer = ReadBuffer(relation, P_NEW);
/*
- * Release the file-extension lock; it's now OK for someone else
- * to extend the relation some more.
+ * Release the file-extension lock; it's now OK for someone else to
+ * extend the relation some more.
*/
if (!relation->rd_myxactonly)
UnlockPage(relation, 0, ExclusiveLock);
/*
- * We can be certain that locking the otherBuffer first is OK,
- * since it must have a lower page number.
+ * We can be certain that locking the otherBuffer first is OK, since
+ * it must have a lower page number.
*/
if (otherBuffer != InvalidBuffer)
LockBuffer(otherBuffer, BUFFER_LOCK_EXCLUSIVE);
*
* XXX should we enter the new page into the free space map immediately,
* or just keep it for this backend's exclusive use in the short run
- * (until VACUUM sees it)? Seems to depend on whether you expect the
+ * (until VACUUM sees it)? Seems to depend on whether you expect the
* current backend to make more insertions or not, which is probably a
* good bet most of the time. So for now, don't add it to FSM yet.
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.24 2001/03/22 06:16:07 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.25 2001/10/25 05:49:21 momjian Exp $
*
* NOTES
* initam should be moved someplace else.
time(&stats->local_reset_timestamp);
time(&stats->last_request_timestamp);
}
-
#endif
#ifdef NOT_USED
return stats;
}
-
#endif
#ifdef NOT_USED
void
PrintHeapAccessStatistics(HeapAccessStatistics stats)
{
-
/*
* return nothing if stats aren't valid
*/
printf("\n");
}
-
#endif
#ifdef NOT_USED
if (stats != NULL)
pfree(stats);
}
-
#endif
/* ----------------------------------------------------------------
void
initam(void)
{
-
/*
* initialize heap statistics.
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.24 2001/08/10 18:57:33 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.25 2001/10/25 05:49:21 momjian Exp $
*
*
* INTERFACE ROUTINES
* external storage (possibly still in compressed format).
* ----------
*/
-varattrib *
+varattrib *
heap_tuple_fetch_attr(varattrib *attr)
{
varattrib *result;
if (VARATT_IS_EXTERNAL(attr))
{
-
/*
* This is an external stored plain value
*/
}
else
{
-
/*
* This is a plain value inside of the main tuple - why am I
* called?
* or external storage.
* ----------
*/
-varattrib *
+varattrib *
heap_tuple_untoast_attr(varattrib *attr)
{
varattrib *result;
}
else
{
-
/*
* This is an external stored plain value
*/
}
else if (VARATT_IS_COMPRESSED(attr))
{
-
/*
* This is a compressed value inside of the main tuple
*/
if (VARATT_IS_COMPRESSED(attr))
{
/*
- * va_rawsize shows the original data size, whether the datum
- * is external or not.
+ * va_rawsize shows the original data size, whether the datum is
+ * external or not.
*/
result = attr->va_content.va_compressed.va_rawsize + VARHDRSZ;
}
if (oldtup != NULL)
{
-
/*
* For UPDATE get the old and new values of this attribute
*/
old_value->va_content.va_external.va_toastrelid !=
new_value->va_content.va_external.va_toastrelid)
{
-
/*
* The old external store value isn't needed any more
* after the update
}
else
{
-
/*
* This attribute isn't changed by this update so we
* reuse the original reference to the old value in
}
else
{
-
/*
* For INSERT simply get the new value
*/
*/
if (att[i]->attlen == -1)
{
-
/*
* If the table's attribute says PLAIN always, force it so.
*/
}
else
{
-
/*
* Not a variable size attribute, plain storage always
*/
}
else
{
-
/*
* incompressible data, ignore on subsequent compression
* passes
}
else
{
-
/*
* incompressible data, ignore on subsequent compression
* passes
Datum t_values[3];
char t_nulls[3];
varattrib *result;
- struct {
- struct varlena hdr;
- char data[TOAST_MAX_CHUNK_SIZE];
+ struct
+ {
+ struct varlena hdr;
+ char data[TOAST_MAX_CHUNK_SIZE];
} chunk_data;
int32 chunk_size;
int32 chunk_seq = 0;
heap_insert(toastrel, toasttup);
/*
- * Create the index entry. We cheat a little here by not using
+ * Create the index entry. We cheat a little here by not using
* FormIndexDatum: this relies on the knowledge that the index
* columns are the same as the initial columns of the table.
*
- * Note also that there had better not be any user-created index
- * on the TOAST table, since we don't bother to update anything else.
+ * Note also that there had better not be any user-created index on
+ * the TOAST table, since we don't bother to update anything else.
*/
idxres = index_insert(toastidx, t_values, t_nulls,
&(toasttup->t_self),
toastidx = index_open(toastrel->rd_rel->reltoastidxid);
/*
- * Setup a scan key to fetch from the index by va_valueid
- * (we don't particularly care whether we see them in sequence or not)
+ * Setup a scan key to fetch from the index by va_valueid (we don't
+ * particularly care whether we see them in sequence or not)
*/
ScanKeyEntryInitialize(&toastkey,
(bits16) 0,
return result;
}
-
#endif /* TUPLE_TOASTER_ACTIVE */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.28 2001/06/22 19:16:21 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.29 2001/10/25 05:49:21 momjian Exp $
*
* NOTES
* many of the old access method routines have been turned into
scan->flags = 0x0; /* XXX should have a symbolic name */
}
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.53 2001/10/06 23:21:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.54 2001/10/25 05:49:21 momjian Exp $
*
* INTERFACE ROUTINES
* index_open - open an index relation by relationId
pgstat_initstats(&scan->xs_pgstat_info, relation);
/*
- * We want to look up the amgettuple procedure just once per scan,
- * not once per index_getnext call. So do it here and save
- * the fmgr info result in the scan descriptor.
+ * We want to look up the amgettuple procedure just once per scan, not
+ * once per index_getnext call. So do it here and save the fmgr info
+ * result in the scan descriptor.
*/
GET_SCAN_PROCEDURE(beginscan, amgettuple);
fmgr_info(procedure, &scan->fn_getnext);
pgstat_count_index_scan(&scan->xs_pgstat_info);
/*
- * have the am's gettuple proc do all the work.
- * index_beginscan already set up fn_getnext.
+ * have the am's gettuple proc do all the work. index_beginscan
+ * already set up fn_getnext.
*/
result = (RetrieveIndexResult)
DatumGetPointer(FunctionCall2(&scan->fn_getnext,
result = (IndexBulkDeleteResult *)
DatumGetPointer(OidFunctionCall3(procedure,
PointerGetDatum(relation),
- PointerGetDatum((Pointer) callback),
- PointerGetDatum(callback_state)));
+ PointerGetDatum((Pointer) callback),
+ PointerGetDatum(callback_state)));
return result;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.53 2001/10/06 23:21:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.54 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
StrategyNumber maxStrategy)
{
return (bool)
- (PointerIsValid(operator) &&
- StrategyNumberIsInBounds(operator->strategy, maxStrategy) &&
- !(operator->flags & ~(SK_NEGATE | SK_COMMUTE)));
+ (PointerIsValid(operator) &&
+ StrategyNumberIsInBounds(operator->strategy, maxStrategy) &&
+ !(operator->flags & ~(SK_NEGATE | SK_COMMUTE)));
}
/* ----------------
}
return true;
}
-
#endif
#ifdef NOT_USED
return result;
}
-
#endif
/* ----------------
/* not reached, just to make compiler happy */
return FALSE;
}
-
#endif
/* ----------------
{
for (attIndex = 0; attIndex < maxAttributeNumber; attIndex++)
{
- Oid opclass = operatorClassObjectId[attIndex];
+ Oid opclass = operatorClassObjectId[attIndex];
RegProcedure *loc;
StrategyNumber support;
{
tuple = SearchSysCache(AMPROCNUM,
ObjectIdGetDatum(opclass),
- Int16GetDatum(support+1),
+ Int16GetDatum(support + 1),
0, 0);
if (HeapTupleIsValid(tuple))
{
/* Now load the strategy information for the index operators */
for (attIndex = 0; attIndex < maxAttributeNumber; attIndex++)
{
- Oid opclass = operatorClassObjectId[attIndex];
+ Oid opclass = operatorClassObjectId[attIndex];
StrategyMap map;
StrategyNumber strategy;
for (strategy = 1; strategy <= maxStrategyNumber; strategy++)
{
- ScanKey mapentry = StrategyMapGetScanKeyEntry(map, strategy);
+ ScanKey mapentry = StrategyMapGetScanKeyEntry(map, strategy);
tuple = SearchSysCache(AMOPSTRATEGY,
ObjectIdGetDatum(opclass),
}
}
}
-
#endif /* defined(ISTRATDEBUG) */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.42 2001/05/03 19:00:36 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.43 2001/10/25 05:49:21 momjian Exp $
*
* NOTES
*
* NOTE: although any negative int32 is acceptable for reporting "<",
* and any positive int32 is acceptable for reporting ">", routines
* that work on 32-bit or wider datatypes can't just return "a - b".
- * That could overflow and give the wrong answer. Also, one should not
+ * That could overflow and give the wrong answer. Also, one should not
* return INT_MIN to report "<", since some callers will negate the result.
*
* NOTE: it is critical that the comparison function impose a total order
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.86 2001/09/29 23:49:51 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.87 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* If we are not on the leaf level, we will be able to discard the key
* data from the first item that winds up on the right page.
*/
- if (! state->is_leaf)
+ if (!state->is_leaf)
rightfree += (int) firstrightitemsz -
(int) (MAXALIGN(sizeof(BTItemData)) + sizeof(ItemIdData));
{
/*
* On a rightmost page, try to equalize right free space with
- * twice the left free space. See comments for _bt_findsplitloc.
+ * twice the left free space. See comments for
+ * _bt_findsplitloc.
*/
delta = (2 * leftfree) - rightfree;
}
for (;;)
{
-
/*
* Read up to 2 more child pages and look for pointers to them in
* *saved* parent page
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.53 2001/07/15 22:48:16 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.54 2001/10/25 05:49:21 momjian Exp $
*
* NOTES
* Postgres btree pages look like ordinary relation pages. The opaque
*/
if (metad->btm_root == P_NONE)
{
-
/*
* Get, initialize, write, and leave a lock of the appropriate
* type on the new root page. Since this is the first page in
}
else
{
-
/*
* Metadata initialized by someone else. In order to
* guarantee no deadlocks, we have to release the metadata
if (!P_ISROOT(rootopaque))
{
-
/*
* It happened, but if root page splitter failed to create new
* root page then we'll go in loop trying to call _bt_getroot
void
_bt_pageinit(Page page, Size size)
{
-
/*
* Cargo_cult programming -- don't really need this to be zero, but
* creating new pages is an infrequent occurrence and it makes me feel
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.82 2001/07/15 22:48:16 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.83 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool haveDead;
Relation heapRel;
BTSpool *spool;
+
/*
* spool2 is needed only when the index is an unique index. Dead
* tuples are put into spool2 instead of spool in order to avoid
static void _bt_restscan(IndexScanDesc scan);
static void btbuildCallback(Relation index,
- HeapTuple htup,
- Datum *attdata,
- char *nulls,
- bool tupleIsAlive,
- void *state);
+ HeapTuple htup,
+ Datum *attdata,
+ char *nulls,
+ bool tupleIsAlive,
+ void *state);
/*
if (buildstate.usefast)
{
buildstate.spool = _bt_spoolinit(index, indexInfo->ii_Unique);
+
/*
* Different from spool, the uniqueness isn't checked for spool2.
*/
bool tupleIsAlive,
void *state)
{
- BTBuildState *buildstate = (BTBuildState *) state;
+ BTBuildState *buildstate = (BTBuildState *) state;
IndexTuple itup;
BTItem btitem;
InsertIndexResult res;
btitem = _bt_formitem(itup);
/*
- * if we are doing bottom-up btree build, we insert the index into
- * a spool file for subsequent processing. otherwise, we insert
- * into the btree.
+ * if we are doing bottom-up btree build, we insert the index into a
+ * spool file for subsequent processing. otherwise, we insert into
+ * the btree.
*/
if (buildstate->usefast)
{
if (ItemPointerIsValid(&(scan->currentItemData)))
{
-
/*
* Restore scan position using heap TID returned by previous call
* to btgettuple(). _bt_restscan() re-grabs the read lock on the
* Save heap TID to use it in _bt_restscan. Then release the read
* lock on the buffer so that we aren't blocking other backends.
*
- * NOTE: we do keep the pin on the buffer! This is essential to ensure
+ * NOTE: we do keep the pin on the buffer! This is essential to ensure
* that someone else doesn't delete the index entry we are stopped on.
*/
if (res)
#ifdef NOT_USED /* XXX surely it's wrong to ignore this? */
bool fromEnd = PG_GETARG_BOOL(1);
-
#endif
ScanKey scankey = (ScanKey) PG_GETARG_POINTER(2);
ItemPointer iptr;
IndexBulkDeleteCallback callback = (IndexBulkDeleteCallback) PG_GETARG_POINTER(1);
void *callback_state = (void *) PG_GETARG_POINTER(2);
IndexBulkDeleteResult *result;
- BlockNumber num_pages;
+ BlockNumber num_pages;
double tuples_removed;
double num_index_tuples;
RetrieveIndexResult res;
num_index_tuples = 0;
/*
- * We use a standard IndexScanDesc scan object, but to speed up the loop,
- * we skip most of the wrapper layers of index_getnext and instead call
- * _bt_step directly. This implies holding buffer lock on a target page
- * throughout the loop over the page's tuples. Initially, we have a read
- * lock acquired by _bt_step when we stepped onto the page. If we find
- * a tuple we need to delete, we trade in the read lock for an exclusive
- * write lock; after that, we hold the write lock until we step off the
- * page (fortunately, _bt_relbuf doesn't care which kind of lock it's
- * releasing). This should minimize the amount of work needed per page.
+ * We use a standard IndexScanDesc scan object, but to speed up the
+ * loop, we skip most of the wrapper layers of index_getnext and
+ * instead call _bt_step directly. This implies holding buffer lock
+ * on a target page throughout the loop over the page's tuples.
+ * Initially, we have a read lock acquired by _bt_step when we stepped
+ * onto the page. If we find a tuple we need to delete, we trade in
+ * the read lock for an exclusive write lock; after that, we hold the
+ * write lock until we step off the page (fortunately, _bt_relbuf
+ * doesn't care which kind of lock it's releasing). This should
+ * minimize the amount of work needed per page.
*/
scan = index_beginscan(rel, false, 0, (ScanKey) NULL);
so = (BTScanOpaque) scan->opaque;
if (res != NULL)
{
Buffer buf;
- BlockNumber lockedBlock = InvalidBlockNumber;
+ BlockNumber lockedBlock = InvalidBlockNumber;
pfree(res);
/* we have the buffer pinned and locked */
do
{
Page page;
- BlockNumber blkno;
+ BlockNumber blkno;
OffsetNumber offnum;
BTItem btitem;
IndexTuple itup;
- ItemPointer htup;
+ ItemPointer htup;
/* current is the next index tuple */
blkno = ItemPointerGetBlockNumber(current);
{
/*
* If this is first deletion on this page, trade in read
- * lock for a really-exclusive write lock. Then, step back
- * one and re-examine the item, because someone else might
- * have inserted an item while we weren't holding the lock!
+ * lock for a really-exclusive write lock. Then, step
+ * back one and re-examine the item, because someone else
+ * might have inserted an item while we weren't holding
+ * the lock!
*/
if (blkno != lockedBlock)
{
* We need to back up the scan one item so that the next
* cycle will re-examine the same offnum on this page.
*
- * For now, just hack the current-item index. Will need
- * to be smarter when deletion includes removal of empty
+ * For now, just hack the current-item index. Will need to
+ * be smarter when deletion includes removal of empty
* index pages.
*/
current->ip_posid--;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.68 2001/10/06 23:21:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.69 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
* At this point we are positioned at the first item >= scan key, or
- * possibly at the end of a page on which all the existing items are
- * greater than the scan key and we know that everything on later pages
- * is less than or equal to scan key.
- *
+ * possibly at the end of a page on which all the existing items are
+ * greater than the scan key and we know that everything on later
+ * pages is less than or equal to scan key.
+ *
* We could step forward in the latter case, but that'd be a waste of
* time if we want to scan backwards. So, it's now time to examine
* the scan strategy to find the exact place to start the scan.
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.60 2001/03/22 03:59:15 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.61 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
* create and initialize a spool structure
*/
-BTSpool *
+BTSpool *
_bt_spoolinit(Relation index, bool isunique)
{
BTSpool *btspool = (BTSpool *) palloc(sizeof(BTSpool));
if (pgspc < btisz || pgspc < state->btps_full)
{
-
/*
* Item won't fit on this page, or we feel the page is full enough
* already. Finish off the page and write it out.
if (merge)
{
-
/*
* Another BTSpool for dead tuples exists. Now we have to merge
* btspool and btspool2.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtstrat.c,v 1.14 2001/05/30 19:53:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtstrat.c,v 1.15 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
return (RelationInvokeStrategy(rel, &BTEvaluationData, attno, strat,
left, right));
}
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.46 2001/10/06 23:21:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.47 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* We can short-circuit most of the work if there's just one key */
if (numberOfKeys == 1)
{
-
/*
* We don't use indices for 'A is null' and 'A is not null'
* currently and 'A < = > <> NULL' will always fail - so qual is
}
else
{
-
/*
* No "=" for this key, so we're done with required keys
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.65 2001/10/06 23:21:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.66 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* for sorting tuples by cost, for picking split */
typedef struct SPLITCOST
{
- OffsetNumber offset_number;
- float cost_differential;
- bool choose_left;
+ OffsetNumber offset_number;
+ float cost_differential;
+ bool choose_left;
} SPLITCOST;
typedef struct RTSTATE
/* non-export function prototypes */
static void rtbuildCallback(Relation index,
- HeapTuple htup,
- Datum *attdata,
- char *nulls,
- bool tupleIsAlive,
- void *state);
+ HeapTuple htup,
+ Datum *attdata,
+ char *nulls,
+ bool tupleIsAlive,
+ void *state);
static InsertIndexResult rtdoinsert(Relation r, IndexTuple itup,
RTSTATE *rtstate);
static void rttighten(Relation r, RTSTACK *stk, Datum datum, int att_size,
RTSTATE *rtstate);
static int nospace(Page p, IndexTuple it);
static void initRtstate(RTSTATE *rtstate, Relation index);
-static int qsort_comp_splitcost(const void *a, const void *b);
+static int qsort_comp_splitcost(const void *a, const void *b);
/*
bool tupleIsAlive,
void *state)
{
- RTBuildState *buildstate = (RTBuildState *) state;
+ RTBuildState *buildstate = (RTBuildState *) state;
IndexTuple itup;
InsertIndexResult res;
}
/*
- * Since we already have the index relation locked, we call
- * rtdoinsert directly. Normal access method calls dispatch
- * through rtinsert, which locks the relation for write. This is
- * the right thing to do if you're inserting single tups, but not
- * when you're initializing the whole index at once.
+ * Since we already have the index relation locked, we call rtdoinsert
+ * directly. Normal access method calls dispatch through rtinsert,
+ * which locks the relation for write. This is the right thing to do
+ * if you're inserting single tups, but not when you're initializing
+ * the whole index at once.
*/
res = rtdoinsert(index, itup, &buildstate->rtState);
Datum *datum = (Datum *) PG_GETARG_POINTER(1);
char *nulls = (char *) PG_GETARG_POINTER(2);
ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3);
+
#ifdef NOT_USED
Relation heapRel = (Relation) PG_GETARG_POINTER(4);
#endif
/*
* Since rtree is not marked "amconcurrent" in pg_am, caller should
- * have acquired exclusive lock on index relation. We need no locking
+ * have acquired exclusive lock on index relation. We need no locking
* here.
*/
PointerGetDatum(&newd_size));
/*
- * If newd_size == 0 we have degenerate rectangles, so we
- * don't know if there was any change, so we have to
- * assume there was.
+ * If newd_size == 0 we have degenerate rectangles, so we don't know
+ * if there was any change, so we have to assume there was.
*/
if ((newd_size == 0) || (newd_size != old_size))
{
if (td->attrs[0]->attlen < 0)
{
-
/*
* This is an internal page, so 'oldud' had better be a union
* (constant-length) key, too. (See comment below.)
res = (InsertIndexResult) palloc(sizeof(InsertIndexResultData));
/*
- * spl_left contains a list of the offset numbers of the
- * tuples that will go to the left page. For each offset
- * number, get the tuple item, then add the item to the
- * left page. Similarly for the right side.
+ * spl_left contains a list of the offset numbers of the tuples that
+ * will go to the left page. For each offset number, get the tuple
+ * item, then add the item to the left page. Similarly for the right
+ * side.
*/
/* fill left node */
if (i == newitemoff)
ItemPointerSet(&(res->pointerData), lbknum, leftoff);
- spl_left++; /* advance in left split vector */
+ spl_left++; /* advance in left split vector */
}
/* fill right node */
if (i == newitemoff)
ItemPointerSet(&(res->pointerData), rbknum, rightoff);
- spl_right++; /* advance in right split vector */
+ spl_right++; /* advance in right split vector */
}
/* Make sure we consumed all of the split vectors, and release 'em */
right_avail_space;
int total_num_tuples,
num_tuples_without_seeds,
- max_after_split; /* in Guttman's lingo, (M - m) */
- float diff; /* diff between cost of putting tuple left or right */
- SPLITCOST *cost_vector;
+ max_after_split; /* in Guttman's lingo, (M - m) */
+ float diff; /* diff between cost of putting tuple left
+ * or right */
+ SPLITCOST *cost_vector;
int n;
/*
if (firsttime)
{
-
/*
* There is no possible split except to put the new item on its
* own page. Since we still have to compute the union rectangles,
/*
* Now split up the regions between the two seeds.
*
- * The cost_vector array will contain hints for determining where
- * each tuple should go. Each record in the array will contain
- * a boolean, choose_left, that indicates which node the tuple
- * prefers to be on, and the absolute difference in cost between
- * putting the tuple in its favored node and in the other node.
+ * The cost_vector array will contain hints for determining where each
+ * tuple should go. Each record in the array will contain a boolean,
+ * choose_left, that indicates which node the tuple prefers to be on,
+ * and the absolute difference in cost between putting the tuple in
+ * its favored node and in the other node.
*
* Later, we will sort the cost_vector in descending order by cost
- * difference, and consider the tuples in that order for
- * placement. That way, the tuples that *really* want to be in
- * one node or the other get to choose first, and the tuples that
- * don't really care choose last.
+ * difference, and consider the tuples in that order for placement.
+ * That way, the tuples that *really* want to be in one node or the
+ * other get to choose first, and the tuples that don't really care
+ * choose last.
*
- * First, build the cost_vector array. The new index tuple will
- * also be handled in this loop, and represented in the array,
- * with i==newitemoff.
+ * First, build the cost_vector array. The new index tuple will also be
+ * handled in this loop, and represented in the array, with
+ * i==newitemoff.
*
- * In the case of variable size tuples it is possible that we only
- * have the two seeds and no other tuples, in which case we don't
- * do any of this cost_vector stuff.
+ * In the case of variable size tuples it is possible that we only have
+ * the two seeds and no other tuples, in which case we don't do any of
+ * this cost_vector stuff.
*/
/* to keep compiler quiet */
}
/*
- * Sort the array. The function qsort_comp_splitcost is
- * set up "backwards", to provided descending order.
+ * Sort the array. The function qsort_comp_splitcost is set up
+ * "backwards", to provided descending order.
*/
qsort(cost_vector, num_tuples_without_seeds, sizeof(SPLITCOST),
&qsort_comp_splitcost);
}
/*
- * Now make the final decisions about where each tuple will go,
- * and build the vectors to return in the SPLITVEC record.
+ * Now make the final decisions about where each tuple will go, and
+ * build the vectors to return in the SPLITVEC record.
*
- * The cost_vector array contains (descriptions of) all the
- * tuples, in the order that we want to consider them, so we
- * we just iterate through it and place each tuple in left
- * or right nodes, according to the criteria described below.
+ * The cost_vector array contains (descriptions of) all the tuples, in
+ * the order that we want to consider them, so we we just iterate
+ * through it and place each tuple in left or right nodes, according
+ * to the criteria described below.
*/
left = v->spl_left;
right = v->spl_right;
v->spl_nright = 0;
- /* Place the seeds first.
- * left avail space, left union, right avail space, and right
- * union have already been adjusted for the seeds.
+ /*
+ * Place the seeds first. left avail space, left union, right avail
+ * space, and right union have already been adjusted for the seeds.
*/
*left++ = seed_1;
choose_left;
/*
- * We need to figure out which page needs the least
- * enlargement in order to store the item.
+ * We need to figure out which page needs the least enlargement in
+ * order to store the item.
*/
i = cost_vector[n].offset_number;
* the new item.)
*
* Guttman's algorithm actually has two factors to consider (in
- * order): 1. if one node has so many tuples already assigned to
+ * order): 1. if one node has so many tuples already assigned to
* it that the other needs all the rest in order to satisfy the
- * condition that neither node has fewer than m tuples, then
- * that is decisive; 2. otherwise, choose the page that shows
- * the smaller enlargement of its union area.
+ * condition that neither node has fewer than m tuples, then that
+ * is decisive; 2. otherwise, choose the page that shows the
+ * smaller enlargement of its union area.
*
- * I have chosen m = M/2, where M is the maximum number of
- * tuples on a page. (Actually, this is only strictly
- * true for fixed size tuples. For variable size tuples,
- * there still might have to be only one tuple on a page,
- * if it is really big. But even with variable size
- * tuples we still try to get m as close as possible to M/2.)
+ * I have chosen m = M/2, where M is the maximum number of tuples on
+ * a page. (Actually, this is only strictly true for fixed size
+ * tuples. For variable size tuples, there still might have to be
+ * only one tuple on a page, if it is really big. But even with
+ * variable size tuples we still try to get m as close as possible
+ * to M/2.)
*
- * The question of which page shows the smaller enlargement of
- * its union area has already been answered, and the answer
- * stored in the choose_left field of the SPLITCOST record.
+ * The question of which page shows the smaller enlargement of its
+ * union area has already been answered, and the answer stored in
+ * the choose_left field of the SPLITCOST record.
*/
left_feasible = (left_avail_space >= item_1_sz &&
((left_avail_space - item_1_sz) >= newitemsz ||
if (left_feasible && right_feasible)
{
/*
- * Both feasible, use Guttman's algorithm.
- * First check the m condition described above, and if
- * that doesn't apply, choose the page with the smaller
- * enlargement of its union area.
+ * Both feasible, use Guttman's algorithm. First check the m
+ * condition described above, and if that doesn't apply,
+ * choose the page with the smaller enlargement of its union
+ * area.
*/
if (v->spl_nleft > max_after_split)
choose_left = false;
else
{
elog(ERROR, "rtpicksplit: failed to find a workable page split");
- choose_left = false;/* keep compiler quiet */
+ choose_left = false; /* keep compiler quiet */
}
if (choose_left)
}
if (num_tuples_without_seeds > 0)
- {
pfree(cost_vector);
- }
*left = *right = InvalidOffsetNumber; /* add ending sentinels */
IndexBulkDeleteCallback callback = (IndexBulkDeleteCallback) PG_GETARG_POINTER(1);
void *callback_state = (void *) PG_GETARG_POINTER(2);
IndexBulkDeleteResult *result;
- BlockNumber num_pages;
+ BlockNumber num_pages;
double tuples_removed;
double num_index_tuples;
RetrieveIndexResult res;
/*
* Since rtree is not marked "amconcurrent" in pg_am, caller should
- * have acquired exclusive lock on index relation. We need no locking
+ * have acquired exclusive lock on index relation. We need no locking
* here.
*/
static int
qsort_comp_splitcost(const void *a, const void *b)
{
- float diff =
- ((SPLITCOST *)a)->cost_differential -
- ((SPLITCOST *)b)->cost_differential;
+ float diff =
+ ((SPLITCOST *) a)->cost_differential -
+ ((SPLITCOST *) b)->cost_differential;
+
if (diff < 0)
return 1;
else if (diff > 0)
ReleaseBuffer(buf);
}
}
-
#endif /* defined RTDEBUG */
void
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.38 2001/07/15 22:48:16 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.39 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
else
{
-
/*
* remember that we're before the current
* tuple
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtstrat.c,v 1.17 2001/05/30 19:53:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtstrat.c,v 1.18 2001/10/25 05:49:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
NULL, /* express overlap */
NULL, /* express overright */
NULL, /* express right */
- (StrategyExpression) RTEqualExpressionData, /* express same */
+ (StrategyExpression) RTEqualExpressionData, /* express same */
NULL, /* express contains */
NULL /* express contained-by */
};
return (RelationInvokeStrategy(r, &RTEvaluationData, attnum, s,
left, right));
}
-
#endif
RegProcedure
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/access/transam/clog.c,v 1.4 2001/09/29 04:02:21 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/clog.c,v 1.5 2001/10/25 05:49:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
* Defines for CLOG page and segment sizes. A page is the same BLCKSZ
- * as is used everywhere else in Postgres. The CLOG segment size can be
+ * as is used everywhere else in Postgres. The CLOG segment size can be
* chosen somewhat arbitrarily; we make it 1 million transactions by default,
* or 256Kb.
*
/* We need two bits per xact, so four xacts fit in a byte */
#define CLOG_BITS_PER_XACT 2
-#define CLOG_XACTS_PER_BYTE 4
-#define CLOG_XACTS_PER_PAGE (CLOG_BLCKSZ * CLOG_XACTS_PER_BYTE)
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (CLOG_BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
#define CLOG_XACTS_PER_SEGMENT 0x100000
#define CLOG_PAGES_PER_SEGMENT (CLOG_XACTS_PER_SEGMENT / CLOG_XACTS_PER_PAGE)
#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
-#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
+#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
* the control lock.
*
* As with the regular buffer manager, it is possible for another process
- * to re-dirty a page that is currently being written out. This is handled
+ * to re-dirty a page that is currently being written out. This is handled
* by setting the page's state from WRITE_IN_PROGRESS to DIRTY. The writing
* process must notice this and not mark the page CLEAN when it's done.
*
* XLOG interactions: this module generates an XLOG record whenever a new
- * CLOG page is initialized to zeroes. Other writes of CLOG come from
+ * 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. Also, the XLOG
+ * on redo; so we need make no additional XLOG entry here. Also, 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 for commits, and we don't really care for aborts. Therefore,
typedef enum
{
- CLOG_PAGE_EMPTY, /* CLOG buffer is not in use */
- CLOG_PAGE_READ_IN_PROGRESS, /* CLOG page is being read in */
- CLOG_PAGE_CLEAN, /* CLOG page is valid and not dirty */
- CLOG_PAGE_DIRTY, /* CLOG page is valid but needs write */
- CLOG_PAGE_WRITE_IN_PROGRESS /* CLOG page is being written out in */
+ CLOG_PAGE_EMPTY,/* CLOG buffer is not in use */
+ CLOG_PAGE_READ_IN_PROGRESS, /* CLOG page is being read
+ * in */
+ CLOG_PAGE_CLEAN,/* CLOG page is valid and not dirty */
+ CLOG_PAGE_DIRTY,/* CLOG page is valid but needs write */
+ CLOG_PAGE_WRITE_IN_PROGRESS /* CLOG page is being
+ * written out in */
} ClogPageStatus;
/*
{
/*
* Info for each buffer slot. Page number is undefined when status is
- * EMPTY. lru_count is essentially the number of operations since last
- * use of this page; the page with highest lru_count is the best candidate
- * to replace.
+ * EMPTY. lru_count is essentially the number of operations since
+ * last use of this page; the page with highest lru_count is the best
+ * candidate to replace.
*/
char *page_buffer[NUM_CLOG_BUFFERS];
- ClogPageStatus page_status[NUM_CLOG_BUFFERS];
+ ClogPageStatus page_status[NUM_CLOG_BUFFERS];
int page_number[NUM_CLOG_BUFFERS];
- unsigned int page_lru_count[NUM_CLOG_BUFFERS];
+ unsigned int page_lru_count[NUM_CLOG_BUFFERS];
+
/*
* latest_page_number is the page number of the current end of the
* CLOG; this is not critical data, since we use it only to avoid
* The value is automatically inherited by backends via fork, and
* doesn't need to be in shared memory.
*/
-static LWLockId ClogBufferLocks[NUM_CLOG_BUFFERS]; /* Per-buffer I/O locks */
+static LWLockId ClogBufferLocks[NUM_CLOG_BUFFERS]; /* Per-buffer I/O locks */
/*
* ClogDir is set during CLOGShmemInit and does not change thereafter.
*/
static char ClogDir[MAXPGPATH];
-#define ClogFileName(path, seg) \
+#define ClogFileName(path, seg) \
snprintf(path, MAXPGPATH, "%s/%04X", ClogDir, seg)
/*
LWLockAcquire(CLogControlLock, LW_EXCLUSIVE);
Assert(ClogCtl->page_number[slotno] == pageno &&
- ClogCtl->page_status[slotno] == CLOG_PAGE_READ_IN_PROGRESS);
+ ClogCtl->page_status[slotno] == CLOG_PAGE_READ_IN_PROGRESS);
ClogCtl->page_status[slotno] = CLOG_PAGE_CLEAN;
*
* NOTE: only one write attempt is made here. Hence, it is possible that
* the page is still dirty at exit (if someone else re-dirtied it during
- * the write). However, we *do* attempt a fresh write even if the page
+ * the write). However, we *do* attempt a fresh write even if the page
* is already being written; this is for checkpoints.
*
* Control lock must be held at entry, and will be held at exit.
static void
WriteCLOGPage(int slotno)
{
- int pageno;
+ int pageno;
/* Do nothing if page does not need writing */
if (ClogCtl->page_status[slotno] != CLOG_PAGE_DIRTY &&
* update on this page will mark it dirty again. NB: we are assuming
* that read/write of the page status field is atomic, since we change
* the state while not holding control lock. However, we cannot set
- * this state any sooner, or we'd possibly fool a previous writer
- * into thinking he's successfully dumped the page when he hasn't.
- * (Scenario: other writer starts, page is redirtied, we come along and
- * set WRITE_IN_PROGRESS again, other writer completes and sets CLEAN
- * because redirty info has been lost, then we think it's clean too.)
+ * this state any sooner, or we'd possibly fool a previous writer into
+ * thinking he's successfully dumped the page when he hasn't.
+ * (Scenario: other writer starts, page is redirtied, we come along
+ * and set WRITE_IN_PROGRESS again, other writer completes and sets
+ * CLEAN because redirty info has been lost, then we think it's clean
+ * too.)
*/
ClogCtl->page_status[slotno] = CLOG_PAGE_WRITE_IN_PROGRESS;
static void
CLOGPhysicalReadPage(int pageno, int slotno)
{
- int segno = pageno / CLOG_PAGES_PER_SEGMENT;
+ int segno = pageno / CLOG_PAGES_PER_SEGMENT;
int rpageno = pageno % CLOG_PAGES_PER_SEGMENT;
int offset = rpageno * CLOG_BLCKSZ;
char path[MAXPGPATH];
/*
* In a crash-and-restart situation, it's possible for us to receive
- * commands to set the commit status of transactions whose bits are
- * in already-truncated segments of the commit log (see notes in
- * CLOGPhysicalWritePage). Hence, if we are InRecovery, allow the
+ * commands to set the commit status of transactions whose bits are in
+ * already-truncated segments of the commit log (see notes in
+ * CLOGPhysicalWritePage). Hence, if we are InRecovery, allow the
* case where the file doesn't exist, and return zeroes instead.
*/
fd = BasicOpenFile(path, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR);
static void
CLOGPhysicalWritePage(int pageno, int slotno)
{
- int segno = pageno / CLOG_PAGES_PER_SEGMENT;
+ int segno = pageno / CLOG_PAGES_PER_SEGMENT;
int rpageno = pageno % CLOG_PAGES_PER_SEGMENT;
int offset = rpageno * CLOG_BLCKSZ;
char path[MAXPGPATH];
ClogFileName(path, segno);
/*
- * If the file doesn't already exist, we should create it. It is possible
- * for this to need to happen when writing a page that's not first in
- * its segment; we assume the OS can cope with that. (Note: it might seem
- * that it'd be okay to create files only when ZeroCLOGPage is called for
- * the first page of a segment. However, if after a crash and restart
- * the REDO logic elects to replay the log from a checkpoint before the
- * latest one, then it's possible that we will get commands to set
- * transaction status of transactions that have already been truncated
- * from the commit log. Easiest way to deal with that is to accept
- * references to nonexistent files here and in CLOGPhysicalReadPage.)
+ * If the file doesn't already exist, we should create it. It is
+ * possible for this to need to happen when writing a page that's not
+ * first in its segment; we assume the OS can cope with that. (Note:
+ * it might seem that it'd be okay to create files only when
+ * ZeroCLOGPage is called for the first page of a segment. However,
+ * if after a crash and restart the REDO logic elects to replay the
+ * log from a checkpoint before the latest one, then it's possible
+ * that we will get commands to set transaction status of transactions
+ * that have already been truncated from the commit log. Easiest way
+ * to deal with that is to accept references to nonexistent files here
+ * and in CLOGPhysicalReadPage.)
*/
fd = BasicOpenFile(path, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR);
if (fd < 0)
}
/*
- * If we find any EMPTY slot, just select that one.
- * Else locate the least-recently-used slot that isn't the
- * latest CLOG page.
+ * If we find any EMPTY slot, just select that one. Else locate
+ * the least-recently-used slot that isn't the latest CLOG page.
*/
for (slotno = 0; slotno < NUM_CLOG_BUFFERS; slotno++)
{
if (ClogCtl->page_status[slotno] == CLOG_PAGE_EMPTY)
return slotno;
if (ClogCtl->page_lru_count[slotno] > bestcount &&
- ClogCtl->page_number[slotno] != ClogCtl->latest_page_number)
+ ClogCtl->page_number[slotno] != ClogCtl->latest_page_number)
{
bestslot = slotno;
bestcount = ClogCtl->page_lru_count[slotno];
return bestslot;
/*
- * We need to do I/O. Normal case is that we have to write it out,
- * but it's possible in the worst case to have selected a read-busy
- * page. In that case we use ReadCLOGPage to wait for the read to
- * complete.
+ * We need to do I/O. Normal case is that we have to write it
+ * out, but it's possible in the worst case to have selected a
+ * read-busy page. In that case we use ReadCLOGPage to wait for
+ * the read to complete.
*/
if (ClogCtl->page_status[bestslot] == CLOG_PAGE_READ_IN_PROGRESS)
(void) ReadCLOGPage(ClogCtl->page_number[bestslot]);
WriteCLOGPage(bestslot);
/*
- * Now loop back and try again. This is the easiest way of dealing
- * with corner cases such as the victim page being re-dirtied while
- * we wrote it.
+ * Now loop back and try again. This is the easiest way of
+ * dealing with corner cases such as the victim page being
+ * re-dirtied while we wrote it.
*/
}
}
for (slotno = 0; slotno < NUM_CLOG_BUFFERS; slotno++)
{
WriteCLOGPage(slotno);
+
/*
* We cannot assert that the slot is clean now, since another
* process might have re-dirtied it already. That's okay.
* Remove all CLOG segments before the one holding the passed transaction ID
*
* When this is called, we know that the database logically contains no
- * reference to transaction IDs older than oldestXact. However, we must
+ * reference to transaction IDs older than oldestXact. However, we must
* not truncate the CLOG until we have performed a checkpoint, to ensure
* that no such references remain on disk either; else a crash just after
* the truncation might leave us with a problem. Since CLOG segments hold
* a large number of transactions, the opportunity to actually remove a
* segment is fairly rare, and so it seems best not to do the checkpoint
- * unless we have confirmed that there is a removable segment. Therefore
+ * unless we have confirmed that there is a removable segment. Therefore
* we issue the checkpoint command here, not in higher-level code as might
* seem cleaner.
*/
/*
* Scan CLOG shared memory and remove any pages preceding the cutoff
* page, to ensure we won't rewrite them later. (Any dirty pages
- * should have been flushed already during the checkpoint, we're
- * just being extra careful here.)
+ * should have been flushed already during the checkpoint, we're just
+ * being extra careful here.)
*/
LWLockAcquire(CLogControlLock, LW_EXCLUSIVE);
restart:;
+
/*
- * While we are holding the lock, make an important safety check:
- * the planned cutoff point must be <= the current CLOG endpoint page.
+ * While we are holding the lock, make an important safety check: the
+ * planned cutoff point must be <= the current CLOG endpoint page.
* Otherwise we have already wrapped around, and proceeding with the
* truncation would risk removing the current CLOG segment.
*/
continue;
if (!CLOGPagePrecedes(ClogCtl->page_number[slotno], cutoffPage))
continue;
+
/*
* If page is CLEAN, just change state to EMPTY (expected case).
*/
ClogCtl->page_status[slotno] = CLOG_PAGE_EMPTY;
continue;
}
+
/*
* Hmm, we have (or may have) I/O operations acting on the page,
* so we've got to wait for them to finish and then start again.
TransactionId xid1;
TransactionId xid2;
- xid1 = (TransactionId) page1 * CLOG_XACTS_PER_PAGE;
+ xid1 = (TransactionId) page1 *CLOG_XACTS_PER_PAGE;
+
xid1 += FirstNormalTransactionId;
- xid2 = (TransactionId) page2 * CLOG_XACTS_PER_PAGE;
+ xid2 = (TransactionId) page2 *CLOG_XACTS_PER_PAGE;
+
xid2 += FirstNormalTransactionId;
return TransactionIdPrecedes(xid1, xid2);
if (info == CLOG_ZEROPAGE)
{
- int pageno;
- int slotno;
+ int pageno;
+ int slotno;
memcpy(&pageno, XLogRecGetData(record), sizeof(int));
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int pageno;
memcpy(&pageno, rec, sizeof(int));
sprintf(buf + strlen(buf), "zeropage: %d", pageno);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.48 2001/08/26 16:55:59 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.49 2001/10/25 05:49:22 momjian Exp $
*
* NOTES
* This file contains the high level access-method interface to the
* ----------------
*/
static TransactionId cachedTestXid = InvalidTransactionId;
-static XidStatus cachedTestXidStatus;
+static XidStatus cachedTestXidStatus;
/* ----------------------------------------------------------------
XidStatus xidstatus; /* recorded status of xid */
/*
- * Before going to the commit log manager, check our single item cache to
- * see if we didn't just check the transaction status a moment ago.
+ * Before going to the commit log manager, check our single item cache
+ * to see if we didn't just check the transaction status a moment ago.
*/
if (TransactionIdEquals(transactionId, cachedTestXid))
return (status == cachedTestXidStatus);
/*
* Also, check to see if the transaction ID is a permanent one.
*/
- if (! TransactionIdIsNormal(transactionId))
+ if (!TransactionIdIsNormal(transactionId))
{
if (TransactionIdEquals(transactionId, BootstrapTransactionId))
return (status == TRANSACTION_STATUS_COMMITTED);
/*
* Get the status.
*/
- xidstatus = TransactionIdGetStatus(transactionId);
-
- /*
- * DO NOT cache status for unfinished transactions!
- */
- if (xidstatus != TRANSACTION_STATUS_IN_PROGRESS)
- {
- TransactionIdStore(transactionId, &cachedTestXid);
- cachedTestXidStatus = xidstatus;
- }
-
- return (status == xidstatus);
+ xidstatus = TransactionIdGetStatus(transactionId);
+
+ /*
+ * DO NOT cache status for unfinished transactions!
+ */
+ if (xidstatus != TRANSACTION_STATUS_IN_PROGRESS)
+ {
+ TransactionIdStore(transactionId, &cachedTestXid);
+ cachedTestXidStatus = xidstatus;
+ }
+
+ return (status == xidstatus);
}
/* --------------------------------
return TransactionLogTest(transactionId, TRANSACTION_STATUS_IN_PROGRESS);
}
-#endif /* NOT_USED */
+#endif /* NOT_USED */
/* --------------------------------
* TransactionId Commit
{
/*
* If either ID is a permanent XID then we can just do unsigned
- * comparison. If both are normal, do a modulo-2^31 comparison.
+ * comparison. If both are normal, do a modulo-2^31 comparison.
*/
int32 diff;
* Copyright (c) 2000, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.46 2001/09/29 04:02:21 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.47 2001/10/25 05:49:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
TransactionId
GetNewTransactionId(void)
{
- TransactionId xid;
+ TransactionId xid;
/*
* During bootstrap initialization, we return the special bootstrap
TransactionIdAdvance(ShmemVariableCache->nextXid);
/*
- * If we have just allocated the first XID of a new page of the
- * commit log, zero out that commit-log page before returning.
- * We must do this while holding XidGenLock, else another xact could
- * acquire and commit a later XID before we zero the page. Fortunately,
- * a page of the commit log holds 32K or more transactions, so we don't
- * have to do this very often.
+ * If we have just allocated the first XID of a new page of the commit
+ * log, zero out that commit-log page before returning. We must do
+ * this while holding XidGenLock, else another xact could acquire and
+ * commit a later XID before we zero the page. Fortunately, a page of
+ * the commit log holds 32K or more transactions, so we don't have to
+ * do this very often.
*/
ExtendCLOG(xid);
/*
- * Must set MyProc->xid before releasing XidGenLock. This ensures that
- * when GetSnapshotData calls ReadNewTransactionId, all active XIDs
- * before the returned value of nextXid are already present in the shared
- * PROC array. Else we have a race condition.
+ * Must set MyProc->xid before releasing XidGenLock. This ensures
+ * that when GetSnapshotData calls ReadNewTransactionId, all active
+ * XIDs before the returned value of nextXid are already present in
+ * the shared PROC array. Else we have a race condition.
*
* XXX by storing xid into MyProc without acquiring SInvalLock, we are
* relying on fetch/store of an xid to be atomic, else other backends
- * might see a partially-set xid here. But holding both locks at once
- * would be a nasty concurrency hit (and in fact could cause a deadlock
- * against GetSnapshotData). So for now, assume atomicity. Note that
- * readers of PROC xid field should be careful to fetch the value only
- * once, rather than assume they can read it multiple times and get the
- * same answer each time.
+ * might see a partially-set xid here. But holding both locks at once
+ * would be a nasty concurrency hit (and in fact could cause a
+ * deadlock against GetSnapshotData). So for now, assume atomicity.
+ * Note that readers of PROC xid field should be careful to fetch the
+ * value only once, rather than assume they can read it multiple times
+ * and get the same answer each time.
*
- * A solution to the atomic-store problem would be to give each PROC
- * its own spinlock used only for fetching/storing that PROC's xid.
+ * A solution to the atomic-store problem would be to give each PROC its
+ * own spinlock used only for fetching/storing that PROC's xid.
* (SInvalLock would then mean primarily that PROCs couldn't be added/
* removed while holding the lock.)
*/
TransactionId
ReadNewTransactionId(void)
{
- TransactionId xid;
+ TransactionId xid;
/*
* During bootstrap initialization, we return the special bootstrap
Oid
GetNewObjectId(void)
{
- Oid result;
+ Oid result;
LWLockAcquire(OidGenLock, LW_EXCLUSIVE);
/*
* Check for wraparound of the OID counter. We *must* not return 0
* (InvalidOid); and as long as we have to check that, it seems a good
- * idea to skip over everything below BootstrapObjectIdData too. (This
- * basically just reduces the odds of OID collision right after a wrap
- * occurs.) Note we are relying on unsigned comparison here.
+ * idea to skip over everything below BootstrapObjectIdData too.
+ * (This basically just reduces the odds of OID collision right after
+ * a wrap occurs.) Note we are relying on unsigned comparison here.
*/
if (ShmemVariableCache->nextOid < ((Oid) BootstrapObjectIdData))
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.112 2001/10/18 17:30:03 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.113 2001/10/25 05:49:22 momjian Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
*/
return false;
}
-
#endif
/* --------------------------------
static void
AtStart_Locks(void)
{
-
/*
* at present, it is unknown to me what belongs here -cim 3/18/90
*
static void
AtStart_Memory(void)
{
-
/*
* We shouldn't have any transaction contexts already.
*/
recptr = XLogInsert(RM_XACT_ID, XLOG_XACT_ABORT, &rdata);
/*
- * There's no need for XLogFlush here, since the default assumption
- * would be that we aborted, anyway.
+ * There's no need for XLogFlush here, since the default
+ * assumption would be that we aborted, anyway.
*/
/* Mark the transaction aborted in clog */
static void
AtAbort_Locks(void)
{
-
/*
* XXX What if ProcReleaseLocks() fails? (race condition?)
*
static void
AtAbort_Memory(void)
{
-
/*
* Make sure we are in a valid context (not a child of
* TransactionCommandContext...). Note that it is possible for this
static void
AtCleanup_Memory(void)
{
-
/*
* Now that we're "out" of a transaction, have the system allocate
* things in the top memory context instead of per-transaction
{
return CurrentTransactionState->state == TRANS_INPROGRESS;
}
-
#endif
/* --------------------------------
* this must be done _before_ releasing locks we hold and _after_
* RecordTransactionCommit.
*
- * LWLockAcquire(SInvalLock) is required: UPDATE with xid 0 is blocked
- * by xid 1' UPDATE, xid 1 is doing commit while xid 2 gets snapshot -
- * if xid 2' GetSnapshotData sees xid 1 as running then it must see
- * xid 0 as running as well or it will see two tuple versions - one
- * deleted by xid 1 and one inserted by xid 0. See notes in
- * GetSnapshotData.
+ * LWLockAcquire(SInvalLock) is required: UPDATE with xid 0 is blocked by
+ * xid 1' UPDATE, xid 1 is doing commit while xid 2 gets snapshot - if
+ * xid 2' GetSnapshotData sees xid 1 as running then it must see xid 0
+ * as running as well or it will see two tuple versions - one deleted
+ * by xid 1 and one inserted by xid 0. See notes in GetSnapshotData.
*/
if (MyProc != (PROC *) NULL)
{
AtCommit_Memory();
AtEOXact_Files();
- SharedBufferChanged = false;/* safest place to do it */
+ SharedBufferChanged = false; /* safest place to do it */
/* Count transaction commit in statistics collector */
pgstat_count_xact_commit();
/*
* Release any LW locks we might be holding as quickly as possible.
* (Regular locks, however, must be held till we finish aborting.)
- * Releasing LW locks is critical since we might try to grab them again
- * while cleaning up!
+ * Releasing LW locks is critical since we might try to grab them
+ * again while cleaning up!
*/
LWLockReleaseAll();
AtEOXact_Files();
AtAbort_Locks();
- SharedBufferChanged = false;/* safest place to do it */
+ SharedBufferChanged = false; /* safest place to do it */
/* Count transaction abort in statistics collector */
pgstat_count_xact_rollback();
switch (s->blockState)
{
-
/*
* if we aren't in a transaction block, we just do our usual
* start transaction.
switch (s->blockState)
{
-
/*
* if we aren't in a transaction block, we just do our usual
* transaction commit
switch (s->blockState)
{
-
/*
* if we aren't in a transaction block, we just do the basic
* abort & cleanup transaction.
*/
if (s->blockState == TBLOCK_INPROGRESS)
{
-
/*
* here we are in a transaction block which should commit when we
* get to the upcoming CommitTransactionCommand() so we set the
if (s->blockState == TBLOCK_ABORT)
{
-
/*
* here, we are in a transaction block which aborted and since the
* AbortTransaction() was already done, we do whatever is needed
*/
if (s->blockState == TBLOCK_INPROGRESS)
{
-
/*
* here we were inside a transaction block something screwed up
* inside the system so we enter the abort state, do the abort
AbortTransaction();
s->blockState = TBLOCK_ENDABORT;
}
-
#endif
/* --------------------------------
if (s->blockState == TBLOCK_INPROGRESS)
{
-
/*
* here we were inside a transaction block and we got an abort
* command from the user, so we move to the abort state, do the
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: xid.c,v 1.33 2001/08/26 16:55:59 tgl Exp $
+ * $Id: xid.c,v 1.34 2001/10/25 05:49:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
xidout(PG_FUNCTION_ARGS)
{
TransactionId transactionId = PG_GETARG_TRANSACTIONID(0);
+
/* maximum 32 bit unsigned integer representation takes 10 chars */
char *str = palloc(11);
TransactionId now = GetCurrentTransactionId();
/* Permanent XIDs are always infinitely old */
- if (! TransactionIdIsNormal(xid))
+ if (!TransactionIdIsNormal(xid))
PG_RETURN_INT32(INT_MAX);
PG_RETURN_INT32((int32) (now - xid));
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.78 2001/09/29 04:02:21 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.79 2001/10/25 05:49:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* delete 'em */
/*
- * XLOGfileslop is used in the code as the allowed "fuzz" in the number of
+ * XLOGfileslop is used in the code as the allowed "fuzz" in the number of
* preallocated XLOG segments --- we try to have at least XLOGfiles advance
* segments but no more than XLOGfiles+XLOGfileslop segments. This could
* be made a separate GUC variable, but at present I think it's sufficient
{
XLogRecPtr Write; /* last byte + 1 to write out */
XLogRecPtr Flush; /* last byte + 1 to flush */
-} XLogwrtRqst;
+} XLogwrtRqst;
typedef struct XLogwrtResult
{
XLogRecPtr Write; /* last byte + 1 written out */
XLogRecPtr Flush; /* last byte + 1 flushed */
-} XLogwrtResult;
+} XLogwrtResult;
/*
* Shared state data for XLogInsert.
/*
* These values do not change after startup, although the pointed-to
- * pages and xlblocks values certainly do. Permission to read/write the
- * pages and xlblocks values depends on WALInsertLock and WALWriteLock.
+ * pages and xlblocks values certainly do. Permission to read/write
+ * the pages and xlblocks values depends on WALInsertLock and
+ * WALWriteLock.
*/
char *pages; /* buffers for unwritten XLOG pages */
XLogRecPtr *xlblocks; /* 1st byte ptr-s + BLCKSZ */
static int XLogFileInit(uint32 log, uint32 seg,
bool *use_existent, bool use_lock);
static bool InstallXLogFileSegment(uint32 log, uint32 seg, char *tmppath,
- bool find_free, int max_advance,
- bool use_lock);
+ bool find_free, int max_advance,
+ bool use_lock);
static int XLogFileOpen(uint32 log, uint32 seg, bool econt);
static void PreallocXlogFiles(XLogRecPtr endptr);
static void MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr);
SpinLockRelease_NoHoldoff(&XLogCtl->info_lck);
/*
- * If cache is half filled then try to acquire write lock and
- * do XLogWrite. Ignore any fractional blocks in performing this check.
+ * If cache is half filled then try to acquire write lock and do
+ * XLogWrite. Ignore any fractional blocks in performing this check.
*/
LogwrtRqst.Write.xrecoff -= LogwrtRqst.Write.xrecoff % BLCKSZ;
if (LogwrtRqst.Write.xlogid != LogwrtResult.Write.xlogid ||
NewPageEndPtr.xrecoff = BLCKSZ;
}
else
- {
NewPageEndPtr.xrecoff += BLCKSZ;
- }
XLogCtl->xlblocks[nextidx] = NewPageEndPtr;
NewPage = (XLogPageHeader) (XLogCtl->pages + nextidx * BLCKSZ);
Insert->curridx = nextidx;
/* And fill the new page's header */
NewPage->xlp_magic = XLOG_PAGE_MAGIC;
- /* NewPage->xlp_info = 0; */ /* done by memset */
+ /* NewPage->xlp_info = 0; *//* done by memset */
NewPage->xlp_sui = ThisStartUpID;
NewPage->xlp_pageaddr.xlogid = NewPageEndPtr.xlogid;
NewPage->xlp_pageaddr.xrecoff = NewPageEndPtr.xrecoff - BLCKSZ;
while (XLByteLT(LogwrtResult.Write, WriteRqst.Write))
{
-
/*
* Make sure we're not ahead of the insert process. This could
* happen if we're passed a bogus WriteRqst.Write that is past the
if (!XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg))
{
-
/*
* Switch to new logfile segment.
*/
if (XLByteLT(LogwrtResult.Flush, WriteRqst.Flush) &&
XLByteLT(LogwrtResult.Flush, LogwrtResult.Write))
{
-
/*
* Could get here without iterating above loop, in which case we
* might have no open file or the wrong one. However, we do not
if (XLOG_DEBUG)
{
elog(DEBUG, "XLogFlush%s%s: request %X/%X; write %X/%X; flush %X/%X\n",
- (IsBootstrapProcessingMode()) ? "(bootstrap)" : "",
- (InRedo) ? "(redo)" : "",
- record.xlogid, record.xrecoff,
- LogwrtResult.Write.xlogid, LogwrtResult.Write.xrecoff,
- LogwrtResult.Flush.xlogid, LogwrtResult.Flush.xrecoff);
+ (IsBootstrapProcessingMode()) ? "(bootstrap)" : "",
+ (InRedo) ? "(redo)" : "",
+ record.xlogid, record.xrecoff,
+ LogwrtResult.Write.xlogid, LogwrtResult.Write.xrecoff,
+ LogwrtResult.Flush.xlogid, LogwrtResult.Flush.xrecoff);
fflush(stderr);
}
if (XLByteLT(LogwrtResult.Flush, record))
elog(STOP, "XLogFlush: request %X/%X is not satisfied --- flushed only to %X/%X",
record.xlogid, record.xrecoff,
- LogwrtResult.Flush.xlogid, LogwrtResult.Flush.xrecoff);
+ LogwrtResult.Flush.xlogid, LogwrtResult.Flush.xrecoff);
}
LWLockRelease(WALWriteLock);
}
{
/*
* Before deleting the file, see if it can be recycled as
- * a future log segment. We allow recycling segments up to
- * XLOGfiles + XLOGfileslop segments beyond the current
+ * a future log segment. We allow recycling segments up
+ * to XLOGfiles + XLOGfileslop segments beyond the current
* XLOG location.
*/
if (InstallXLogFileSegment(endlogId, endlogSeg, path,
if (readBuf == NULL)
{
-
/*
* First time through, permanently allocate readBuf. We do it
* this way, rather than just making a static array, for two
readFile = XLogFileOpen(readId, readSeg, (emode == LOG));
if (readFile < 0)
goto next_record_is_invalid;
- readOff = (uint32) (-1);/* force read to occur below */
+ readOff = (uint32) (-1); /* force read to occur below */
}
targetPageOff = ((RecPtr->xrecoff % XLogSegSize) / BLCKSZ) * BLCKSZ;
#ifdef USE_LOCALE
char *localeptr;
-
#endif
/*
"\n\tsuch queries, you may wish to set LC_COLLATE to \"C\" and"
"\n\tre-initdb. For more information see the Administrator's Guide.",
ControlFile->lc_collate);
-#else /* not USE_LOCALE */
+#else /* not USE_LOCALE */
strcpy(ControlFile->lc_collate, "C");
strcpy(ControlFile->lc_ctype, "C");
-#endif /* not USE_LOCALE */
+#endif /* not USE_LOCALE */
/* Contents are protected with a CRC */
INIT_CRC64(ControlFile->crc);
if (ControlFile->catalog_version_no != CATALOG_VERSION_NO)
elog(STOP,
"The database cluster was initialized with CATALOG_VERSION_NO %d,\n"
- "\tbut the backend was compiled with CATALOG_VERSION_NO %d.\n"
+ "\tbut the backend was compiled with CATALOG_VERSION_NO %d.\n"
"\tIt looks like you need to initdb.",
ControlFile->catalog_version_no, CATALOG_VERSION_NO);
if (ControlFile->blcksz != BLCKSZ)
#ifdef USE_LOCALE
if (setlocale(LC_COLLATE, ControlFile->lc_collate) == NULL)
elog(STOP,
- "The database cluster was initialized with LC_COLLATE '%s',\n"
+ "The database cluster was initialized with LC_COLLATE '%s',\n"
"\twhich is not recognized by setlocale().\n"
"\tIt looks like you need to initdb.",
ControlFile->lc_collate);
"\twhich is not recognized by setlocale().\n"
"\tIt looks like you need to initdb.",
ControlFile->lc_ctype);
-#else /* not USE_LOCALE */
+#else /* not USE_LOCALE */
if (strcmp(ControlFile->lc_collate, "C") != 0 ||
strcmp(ControlFile->lc_ctype, "C") != 0)
elog(STOP,
- "The database cluster was initialized with LC_COLLATE '%s' and\n"
+ "The database cluster was initialized with LC_COLLATE '%s' and\n"
"\tLC_CTYPE '%s', but the server was compiled without locale support.\n"
"\tIt looks like you need to initdb or recompile.",
ControlFile->lc_collate, ControlFile->lc_ctype);
-#endif /* not USE_LOCALE */
+#endif /* not USE_LOCALE */
}
void
{
/* nextXid must be beyond record's xid */
if (TransactionIdFollowsOrEquals(record->xl_xid,
- ShmemVariableCache->nextXid))
+ ShmemVariableCache->nextXid))
{
ShmemVariableCache->nextXid = record->xl_xid;
TransactionIdAdvance(ShmemVariableCache->nextXid);
Insert->PrevRecord = LastRec;
/*
- * If the next record will go to the new page
- * then initialize for that one.
+ * If the next record will go to the new page then initialize for that
+ * one.
*/
if ((BLCKSZ - EndOfLog.xrecoff % BLCKSZ) < SizeOfXLogRecord)
EndOfLog.xrecoff += (BLCKSZ - EndOfLog.xrecoff % BLCKSZ);
NewPageEndPtr.xrecoff = BLCKSZ;
}
else
- {
NewPageEndPtr.xrecoff += BLCKSZ;
- }
XLogCtl->xlblocks[0] = NewPageEndPtr;
Insert->currpage->xlp_magic = XLOG_PAGE_MAGIC;
if (InRecovery)
XLogCtl->xlblocks[0].xlogid = openLogId;
XLogCtl->xlblocks[0].xrecoff =
((EndOfLog.xrecoff - 1) / BLCKSZ + 1) * BLCKSZ;
+
/*
* Tricky point here: readBuf contains the *last* block that the
- * LastRec record spans, not the one it starts in. The last block
+ * LastRec record spans, not the one it starts in. The last block
* is indeed the one we want to use.
*/
Assert(readOff == (XLogCtl->xlblocks[0].xrecoff - BLCKSZ) % XLogSegSize);
if (InRecovery)
{
-
/*
* In case we had to use the secondary checkpoint, make sure that
* it will still be shown as the secondary checkpoint after this
if (record->xl_rmid != RM_XLOG_ID)
{
elog(LOG, (whichChkpt == 1 ?
- "invalid resource manager id in primary checkpoint record" :
- "invalid resource manager id in secondary checkpoint record"));
+ "invalid resource manager id in primary checkpoint record" :
+ "invalid resource manager id in secondary checkpoint record"));
return NULL;
}
if (record->xl_info != XLOG_CHECKPOINT_SHUTDOWN &&
/*
* The CheckpointLock can be held for quite a while, which is not good
- * because we won't respond to a cancel/die request while waiting for an
- * LWLock. (But the alternative of using a regular lock won't work for
- * background checkpoint processes, which are not regular backends.)
- * So, rather than use a plain LWLockAcquire, use this kluge to allow
- * an interrupt to be accepted while we are waiting:
+ * because we won't respond to a cancel/die request while waiting for
+ * an LWLock. (But the alternative of using a regular lock won't work
+ * for background checkpoint processes, which are not regular
+ * backends.) So, rather than use a plain LWLockAcquire, use this
+ * kluge to allow an interrupt to be accepted while we are waiting:
*/
while (!LWLockConditionalAcquire(CheckpointLock, LW_EXCLUSIVE))
{
* but watch out for case that undo = 0.
*
* Without UNDO support: just use the redo pointer. This allows xlog
- * space to be freed much faster when there are long-running transactions.
+ * space to be freed much faster when there are long-running
+ * transactions.
*/
#ifdef NOT_USED
if (ControlFile->checkPointCopy.undo.xrecoff != 0 &&
if (sync_method != new_sync_method || open_sync_bit != new_sync_bit)
{
-
/*
* To ensure that no blocks escape unsynced, force an fsync on the
* currently open log segment (if any). Also, if the open flag is
{
switch (sync_method)
{
- case SYNC_METHOD_FSYNC:
+ case SYNC_METHOD_FSYNC:
if (pg_fsync(openLogFile) != 0)
elog(STOP, "fsync of log file %u, segment %u failed: %m",
openLogId, openLogSeg);
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.20 2001/10/05 17:28:11 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.21 2001/10/25 05:49:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
rdesc->moreRecently->lessRecently = rdesc->lessRecently;
hentry = (XLogRelCacheEntry *) hash_search(_xlrelcache,
- (void *) &(rdesc->reldata.rd_node), HASH_REMOVE, NULL);
+ (void *) &(rdesc->reldata.rd_node), HASH_REMOVE, NULL);
if (hentry == NULL)
elog(STOP, "_xl_remove_hash_entry: file was not found in cache");
hash_seq_init(&status, _xlrelcache);
while ((hentry = (XLogRelCacheEntry *) hash_seq_search(&status)) != NULL)
- {
_xl_remove_hash_entry(hentry->rdesc);
- }
hash_destroy(_xlrelcache);
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.118 2001/10/19 17:03:08 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.119 2001/10/25 05:49:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
fprintf(stderr,
gettext("Usage:\n"
- " postgres -boot [-d] [-D datadir] [-F] [-o file] [-x num] dbname\n"
+ " postgres -boot [-d] [-D datadir] [-F] [-o file] [-x num] dbname\n"
" -d debug mode\n"
" -D datadir data directory\n"
" -F turn off fsync\n"
{
if (!potential_DataDir)
{
- fprintf(stderr,
+ fprintf(stderr,
gettext("%s does not know where to find the database system data.\n"
"You must specify the directory that contains the database system\n"
"either by specifying the -D invocation option or by setting the\n"
case BS_XLOG_CHECKPOINT:
if (IsUnderPostmaster)
- InitDummyProcess(); /* needed to get LWLocks */
+ InitDummyProcess(); /* needed to get LWLocks */
CreateDummyCaches();
CreateCheckPoint(false);
SetRedoRecPtr();
node = hashtable[CompHash(str, length)];
while (node != NULL)
{
-
/*
* We must differentiate between string constants that might have
* the same value as a identifier and the identifier itself.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.51 2001/06/18 16:13:21 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.52 2001/10/25 05:49:22 momjian Exp $
*
* NOTES
* See acl.h.
DatumGetCString(DirectFunctionCall1(aclitemout,
PointerGetDatum(aip + i))));
}
-
-#endif /* ACLDEBUG */
+#endif /* ACLDEBUG */
/*
relname);
/*
- * If there's no ACL, create a default using the
- * pg_class.relowner field.
+ * If there's no ACL, create a default using the pg_class.relowner
+ * field.
*/
aclDatum = SysCacheGetAttr(RELNAME, tuple, Anum_pg_class_relacl,
&isNull);
foreach(j, stmt->grantees)
{
- PrivGrantee *grantee = (PrivGrantee *)lfirst(j);
+ PrivGrantee *grantee = (PrivGrantee *) lfirst(j);
char *granteeString;
char *aclString;
- AclItem aclitem;
+ AclItem aclitem;
unsigned modechg;
if (grantee->username)
{
replaces[i] = ' ';
nulls[i] = ' '; /* ignored if replaces[i]==' ' anyway */
- values[i] = (Datum) NULL; /* ignored if replaces[i]==' ' anyway */
+ values[i] = (Datum) NULL; /* ignored if replaces[i]==' '
+ * anyway */
}
replaces[Anum_pg_class_relacl - 1] = 'r';
values[Anum_pg_class_relacl - 1] = PointerGetDatum(new_acl);
{
/* keep the catalog indexes up to date */
Relation idescs[Num_pg_class_indices];
+
CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices,
idescs);
CatalogIndexInsert(idescs, Num_pg_class_indices, relation, newtuple);
}
/*
- * "World" rights are applicable regardless of the passed-in ID,
- * and since they're much the cheapest to check, check 'em first.
+ * "World" rights are applicable regardless of the passed-in ID, and
+ * since they're much the cheapest to check, check 'em first.
*/
if (aidat->ai_idtype != ACL_IDTYPE_WORLD)
elog(ERROR, "aclcheck: first entry in ACL is not 'world' entry");
for (i = 1, aip = aidat + 1; /* skip world entry */
i < num && aip->ai_idtype == ACL_IDTYPE_UID;
++i, ++aip)
- /* skip UID entry */;
+ /* skip UID entry */ ;
for (;
i < num && aip->ai_idtype == ACL_IDTYPE_GID;
++i, ++aip)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.178 2001/10/22 22:47:57 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.179 2001/10/25 05:49:22 momjian Exp $
*
*
* INTERFACE ROUTINES
static void AddNewRelationTuple(Relation pg_class_desc,
- Relation new_rel_desc,
- Oid new_rel_oid, Oid new_type_oid,
- char relkind, bool relhasoids,
- char *temp_relname);
+ Relation new_rel_desc,
+ Oid new_rel_oid, Oid new_type_oid,
+ char relkind, bool relhasoids,
+ char *temp_relname);
static void DeleteAttributeTuples(Relation rel);
static void DeleteRelationTuple(Relation rel);
static void DeleteTypeTuple(Relation rel);
Form_pg_attribute
SystemAttributeDefinition(AttrNumber attno, bool relhasoids)
{
- if (attno >= 0 || attno < - (int) lengthof(SysAtt))
+ if (attno >= 0 || attno < -(int) lengthof(SysAtt))
elog(ERROR, "SystemAttributeDefinition: invalid attribute number %d",
attno);
if (attno == ObjectIdAttributeNumber && !relhasoids)
/*
* If the given name is a system attribute name, return a Form_pg_attribute
- * pointer for a prototype definition. If not, return NULL.
+ * pointer for a prototype definition. If not, return NULL.
*/
Form_pg_attribute
SystemAttributeByName(const char *attname, bool relhasoids)
{
- int j;
+ int j;
for (j = 0; j < (int) lengthof(SysAtt); j++)
{
/*
* Real ugly stuff to assign the proper relid in the relation
- * descriptor follows. Note that only "bootstrapped" relations
- * whose OIDs are hard-coded in pg_class.h need be listed here.
+ * descriptor follows. Note that only "bootstrapped" relations whose
+ * OIDs are hard-coded in pg_class.h need be listed here.
*/
if (relname && IsSystemRelationName(relname))
{
/* Fill in the correct relation OID in the copied tuple */
attStruct = (Form_pg_attribute) GETSTRUCT(tup);
attStruct->attrelid = new_rel_oid;
- /* Unneeded since they should be OK in the constant data anyway */
+
+ /*
+ * Unneeded since they should be OK in the constant data
+ * anyway
+ */
/* attStruct->attstattarget = 0; */
/* attStruct->attcacheoff = -1; */
case RELKIND_RELATION:
case RELKIND_INDEX:
case RELKIND_TOASTVALUE:
- new_rel_reltup->relpages = 10; /* bogus estimates */
+ new_rel_reltup->relpages = 10; /* bogus estimates */
new_rel_reltup->reltuples = 1000;
break;
case RELKIND_SEQUENCE:
if (!IsIgnoringSystemIndexes())
{
-
/*
* First, open the catalog indices and insert index tuples for the
* new relation.
{
int i;
int j;
- bool success;
+ bool success;
List *listptr2;
+
ccname = (char *) palloc(NAMEDATALEN);
/* Loop until we find a non-conflicting constraint name */
/* What happens if this loops forever? */
j = numchecks + 1;
- do {
+ do
+ {
success = true;
snprintf(ccname, NAMEDATALEN, "$%d", j);
/* Check against old constraints */
for (i = 0; i < numoldchecks; i++)
{
- if (strcmp(oldchecks[i].ccname, ccname) == 0) {
+ if (strcmp(oldchecks[i].ccname, ccname) == 0)
+ {
success = false;
break;
}
}
- /* Check against other new constraints, if the check hasn't already failed */
- if (success) {
+
+ /*
+ * Check against other new constraints, if the check
+ * hasn't already failed
+ */
+ if (success)
+ {
foreach(listptr2, rawConstraints)
{
Constraint *cdef2 = (Constraint *) lfirst(listptr2);
cdef2->raw_expr == NULL ||
cdef2->name == NULL)
continue;
- if (strcmp(cdef2->name, ccname) == 0) {
+ if (strcmp(cdef2->name, ccname) == 0)
+ {
success = false;
break;
}
int
RemoveCheckConstraint(Relation rel, const char *constrName, bool inh)
{
- Oid relid;
- Relation rcrel;
- Relation relrel;
- Relation inhrel;
- Relation relidescs[Num_pg_class_indices];
- TupleDesc tupleDesc;
- TupleConstr *oldconstr;
- int numoldchecks;
- int numchecks;
- HeapScanDesc rcscan;
- ScanKeyData key[2];
- HeapTuple rctup;
- HeapTuple reltup;
- Form_pg_class relStruct;
- int rel_deleted = 0;
- int all_deleted = 0;
-
- /* Find id of the relation */
- relid = RelationGetRelid(rel);
-
- /* Process child tables and remove constraints of the
- same name. */
- if (inh)
- {
- List *child,
- *children;
-
- /* This routine is actually in the planner */
- children = find_all_inheritors(relid);
-
- /*
- * find_all_inheritors does the recursive search of the
- * inheritance hierarchy, so all we have to do is process all
- * of the relids in the list that it returns.
- */
- foreach(child, children)
- {
- Oid childrelid = lfirsti(child);
-
- if (childrelid == relid)
- continue;
- inhrel = heap_open(childrelid, AccessExclusiveLock);
- all_deleted += RemoveCheckConstraint(inhrel, constrName, false);
- heap_close(inhrel, NoLock);
- }
- }
+ Oid relid;
+ Relation rcrel;
+ Relation relrel;
+ Relation inhrel;
+ Relation relidescs[Num_pg_class_indices];
+ TupleDesc tupleDesc;
+ TupleConstr *oldconstr;
+ int numoldchecks;
+ int numchecks;
+ HeapScanDesc rcscan;
+ ScanKeyData key[2];
+ HeapTuple rctup;
+ HeapTuple reltup;
+ Form_pg_class relStruct;
+ int rel_deleted = 0;
+ int all_deleted = 0;
+
+ /* Find id of the relation */
+ relid = RelationGetRelid(rel);
+
+ /*
+ * Process child tables and remove constraints of the same name.
+ */
+ if (inh)
+ {
+ List *child,
+ *children;
+
+ /* This routine is actually in the planner */
+ children = find_all_inheritors(relid);
+
+ /*
+ * find_all_inheritors does the recursive search of the
+ * inheritance hierarchy, so all we have to do is process all of
+ * the relids in the list that it returns.
+ */
+ foreach(child, children)
+ {
+ Oid childrelid = lfirsti(child);
+
+ if (childrelid == relid)
+ continue;
+ inhrel = heap_open(childrelid, AccessExclusiveLock);
+ all_deleted += RemoveCheckConstraint(inhrel, constrName, false);
+ heap_close(inhrel, NoLock);
+ }
+ }
/* Grab an exclusive lock on the pg_relcheck relation */
rcrel = heap_openr(RelCheckRelationName, RowExclusiveLock);
/*
- * Create two scan keys. We need to match on the oid of the table
- * the CHECK is in and also we need to match the name of the CHECK
+ * Create two scan keys. We need to match on the oid of the table the
+ * CHECK is in and also we need to match the name of the CHECK
* constraint.
*/
ScanKeyEntryInitialize(&key[0], 0, Anum_pg_relcheck_rcrelid,
rcscan = heap_beginscan(rcrel, 0, SnapshotNow, 2, key);
/*
- * Scan over the result set, removing any matching entries. Note
- * that this has the side-effect of removing ALL CHECK constraints
- * that share the specified constraint name.
+ * Scan over the result set, removing any matching entries. Note that
+ * this has the side-effect of removing ALL CHECK constraints that
+ * share the specified constraint name.
*/
- while (HeapTupleIsValid(rctup = heap_getnext(rcscan, 0))) {
+ while (HeapTupleIsValid(rctup = heap_getnext(rcscan, 0)))
+ {
simple_heap_delete(rcrel, &rctup->t_self);
++rel_deleted;
- ++all_deleted;
+ ++all_deleted;
}
/* Clean up after the scan */
* message, but for ALTER TABLE ADD ATTRIBUTE this'd be important.)
*/
- /*
+ /*
* Get number of existing constraints.
*/
relrel = heap_openr(RelationRelationName, RowExclusiveLock);
reltup = SearchSysCacheCopy(RELOID,
- ObjectIdGetDatum(RelationGetRelid(rel)), 0, 0, 0);
+ ObjectIdGetDatum(RelationGetRelid(rel)), 0, 0, 0);
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup of relation %u failed",
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.165 2001/10/06 23:21:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.166 2001/10/25 05:49:22 momjian Exp $
*
*
* INTERFACE ROUTINES
static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName,
bool istemp);
static TupleDesc BuildFuncTupleDesc(Oid funcOid,
- Oid *classObjectId);
+ Oid *classObjectId);
static TupleDesc ConstructTupleDescriptor(Relation heapRelation,
- int numatts, AttrNumber *attNums,
- Oid *classObjectId);
+ int numatts, AttrNumber *attNums,
+ Oid *classObjectId);
static void ConstructIndexReldesc(Relation indexRelation, Oid amoid);
static Oid UpdateRelationRelation(Relation indexRelation, char *temp_relname);
static void InitializeAttributeOids(Relation indexRelation,
int numatts, Oid indexoid);
static void AppendAttributeTuples(Relation indexRelation, int numatts);
static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
- IndexInfo *indexInfo,
- Oid *classOids,
- bool primary);
+ IndexInfo *indexInfo,
+ Oid *classOids,
+ bool primary);
static Oid IndexGetRelation(Oid indexId);
static bool activate_index(Oid indexId, bool activate, bool inplace);
* here we are indexing on a system attribute (-1...-n)
*/
from = SystemAttributeDefinition(atnum,
- heapRelation->rd_rel->relhasoids);
+ heapRelation->rd_rel->relhasoids);
}
else
{
elog(ERROR, "Type %u does not exist", keyType);
typeTup = (Form_pg_type) GETSTRUCT(tuple);
- to->atttypid = keyType;
- to->atttypmod = -1;
- to->attlen = typeTup->typlen;
- to->attbyval = typeTup->typbyval;
- to->attalign = typeTup->typalign;
+ to->atttypid = keyType;
+ to->atttypmod = -1;
+ to->attlen = typeTup->typlen;
+ to->attbyval = typeTup->typbyval;
+ to->attalign = typeTup->typalign;
to->attstorage = typeTup->typstorage;
ReleaseSysCache(tuple);
* Fill in a copy of relevant pg_am entry
*/
indexRelation->rd_am = AccessMethodObjectIdGetForm(amoid,
- CacheMemoryContext);
+ CacheMemoryContext);
+
/*
- * Set up some additional fields of the index' pg_class entry.
- * In particular, initialize knowledge of whether the index is shared.
+ * Set up some additional fields of the index' pg_class entry. In
+ * particular, initialize knowledge of whether the index is shared.
*/
indexRelation->rd_rel->relowner = GetUserId();
indexRelation->rd_rel->relam = amoid;
- indexRelation->rd_rel->relisshared =
+ indexRelation->rd_rel->relisshared =
IsSharedSystemRelationName(RelationGetPhysicalRelationName(indexRelation));
indexRelation->rd_rel->relkind = RELKIND_INDEX;
indexRelation->rd_rel->relhasoids = false;
for (i = 0; i < numatts; i++)
{
/*
- * There used to be very grotty code here to set these fields,
- * but I think it's unnecessary. They should be set already.
+ * There used to be very grotty code here to set these fields, but
+ * I think it's unnecessary. They should be set already.
*/
- Assert(indexTupDesc->attrs[i]->attnum == i+1);
+ Assert(indexTupDesc->attrs[i]->attnum == i + 1);
Assert(indexTupDesc->attrs[i]->attcacheoff == -1);
new_tuple = heap_addheader(Natts_pg_attribute,
indexForm->indexrelid = indexoid;
indexForm->indrelid = heapoid;
indexForm->indproc = indexInfo->ii_FuncOid;
- indexForm->indisclustered = false; /* not used */
+ indexForm->indisclustered = false; /* not used */
indexForm->indisunique = indexInfo->ii_Unique;
indexForm->indisprimary = primary;
memcpy((char *) &indexForm->indpred, (char *) predText, predLen);
elog(ERROR, "must index at least one column");
if (heapRelationName && !allow_system_table_mods &&
- IsSystemRelationName(heapRelationName) && IsNormalProcessingMode())
+ IsSystemRelationName(heapRelationName) && IsNormalProcessingMode())
elog(ERROR, "User-defined indexes on system catalogs are not supported");
/*
else
indexTupDesc = ConstructTupleDescriptor(heapRelation,
indexInfo->ii_NumKeyAttrs,
- indexInfo->ii_KeyAttrNumbers,
+ indexInfo->ii_KeyAttrNumbers,
classObjectId);
if (istemp)
* To drop an index safely, we must grab exclusive lock on its parent
* table; otherwise there could be other backends using the index!
* Exclusive lock on the index alone is insufficient because another
- * backend might be in the midst of devising a query plan that will use
- * the index. The parser and planner take care to hold an appropriate
- * lock on the parent table while working, but having them hold locks on
- * all the indexes too seems overly complex. We do grab exclusive lock
- * on the index too, just to be safe. Both locks must be held till end of
- * transaction, else other backends will still see this index in pg_index.
+ * backend might be in the midst of devising a query plan that will
+ * use the index. The parser and planner take care to hold an
+ * appropriate lock on the parent table while working, but having them
+ * hold locks on all the indexes too seems overly complex. We do grab
+ * exclusive lock on the index too, just to be safe. Both locks must
+ * be held till end of transaction, else other backends will still see
+ * this index in pg_index.
*/
heapId = IndexGetRelation(indexId);
userHeapRelation = heap_open(heapId, AccessExclusiveLock);
* ensure other backends update their relcache lists of indexes. So,
* unconditionally do setRelhasindex(true).
*
- * Possible future improvement: skip the physical tuple update and
- * just send out an invalidation message.
+ * Possible future improvement: skip the physical tuple update and just
+ * send out an invalidation message.
*/
setRelhasindex(heapId, true, false, InvalidOid);
* just once per command, and then use it for (potentially) many tuples.
* ----------------
*/
-IndexInfo *
+IndexInfo *
BuildIndexInfo(HeapTuple indexTuple)
{
Form_pg_index indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
* Handle functional index.
*
* If we have a functional index then the number of attributes defined in
- * the index must be 1 (the function's single return value).
- * Otherwise it's same as number of keys.
+ * the index must be 1 (the function's single return value). Otherwise
+ * it's same as number of keys.
*/
ii->ii_FuncOid = indexStruct->indproc;
if (OidIsValid(indexInfo->ii_FuncOid))
{
-
/*
* Functional index --- compute the single index attribute
*/
}
else
{
-
/*
* Plain index --- for each attribute we need from the heap tuple,
* get the attribute and stick it into the datum and nullv arrays.
* set relhasindex of relation's pg_class entry
*
* If isprimary is TRUE, we are defining a primary index, so also set
- * relhaspkey to TRUE. Otherwise, leave relhaspkey alone.
+ * relhaspkey to TRUE. Otherwise, leave relhaspkey alone.
*
* If reltoastidxid is not InvalidOid, also set reltoastidxid to that value.
* This is only used for TOAST relations.
Relation pg_class;
HeapTuple tuple;
HeapTuple newtup;
- BlockNumber relpages;
+ BlockNumber relpages;
int i;
Form_pg_class rd_rel;
Relation idescs[Num_pg_class_indices];
* when it is actually sizable. See also CREATE TABLE in heap.c.
*
* Note: this path is also taken during bootstrap, because bootstrap.c
- * passes reltuples = 0 after loading a table. We have to estimate some
- * number for reltuples based on the actual number of pages.
+ * passes reltuples = 0 after loading a table. We have to estimate
+ * some number for reltuples based on the actual number of pages.
*/
relpages = RelationGetNumberOfBlocks(whichRel);
reltuples = 1000;
}
else
- reltuples = (double) relpages * NTUPLES_PER_PAGE(whichRel->rd_rel->relnatts);
+ reltuples = (double) relpages *NTUPLES_PER_PAGE(whichRel->rd_rel->relnatts);
}
/*
*/
if (in_place_upd)
{
-
/*
* At bootstrap time, we don't need to worry about concurrency or
* visibility of changes, so we cheat. Also cheat if REINDEX.
* build procedure does whatever cleanup is needed; in particular, it should
* close the heap and index relations.
*
- * The total count of heap tuples is returned. This is for updating pg_class
- * statistics. (It's annoying not to be able to do that here, but we can't
+ * The total count of heap tuples is returned. This is for updating pg_class
+ * statistics. (It's annoying not to be able to do that here, but we can't
* do it until after the relation is closed.) Note that the index AM itself
* must keep track of the number of index tuples; we don't do so here because
* the AM might reject some of the tuples for its own reasons, such as being
/*
* Ok, begin our scan of the base relation. We use SnapshotAny
- * because we must retrieve all tuples and do our own time qual checks.
+ * because we must retrieve all tuples and do our own time qual
+ * checks.
*/
if (IsBootstrapProcessingMode())
{
scan = heap_beginscan(heapRelation, /* relation */
0, /* start at end */
- snapshot, /* seeself */
+ snapshot, /* seeself */
0, /* number of keys */
(ScanKey) NULL); /* scan key */
if (snapshot == SnapshotAny)
{
/* do our own time qual check */
- bool indexIt;
- uint16 sv_infomask;
+ bool indexIt;
+ uint16 sv_infomask;
/*
- * HeapTupleSatisfiesVacuum may update tuple's hint status bits.
- * We could possibly get away with not locking the buffer here,
- * since caller should hold ShareLock on the relation, but let's
- * be conservative about it.
+ * HeapTupleSatisfiesVacuum may update tuple's hint status
+ * bits. We could possibly get away with not locking the
+ * buffer here, since caller should hold ShareLock on the
+ * relation, but let's be conservative about it.
*/
LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE);
sv_infomask = heapTuple->t_data->t_infomask;
tupleIsAlive = true;
break;
case HEAPTUPLE_RECENTLY_DEAD:
+
/*
* If tuple is recently deleted then we must index it
* anyway to keep VACUUM from complaining.
tupleIsAlive = false;
break;
case HEAPTUPLE_INSERT_IN_PROGRESS:
+
/*
- * Since caller should hold ShareLock or better, we should
- * not see any tuples inserted by open transactions ---
- * unless it's our own transaction. (Consider INSERT
- * followed by CREATE INDEX within a transaction.)
+ * Since caller should hold ShareLock or better, we
+ * should not see any tuples inserted by open
+ * transactions --- unless it's our own transaction.
+ * (Consider INSERT followed by CREATE INDEX within a
+ * transaction.)
*/
- if (! TransactionIdIsCurrentTransactionId(heapTuple->t_data->t_xmin))
+ if (!TransactionIdIsCurrentTransactionId(heapTuple->t_data->t_xmin))
elog(ERROR, "IndexBuildHeapScan: concurrent insert in progress");
indexIt = true;
tupleIsAlive = true;
break;
case HEAPTUPLE_DELETE_IN_PROGRESS:
+
/*
- * Since caller should hold ShareLock or better, we should
- * not see any tuples deleted by open transactions ---
- * unless it's our own transaction. (Consider DELETE
- * followed by CREATE INDEX within a transaction.)
+ * Since caller should hold ShareLock or better, we
+ * should not see any tuples deleted by open
+ * transactions --- unless it's our own transaction.
+ * (Consider DELETE followed by CREATE INDEX within a
+ * transaction.)
*/
- if (! TransactionIdIsCurrentTransactionId(heapTuple->t_data->t_xmax))
+ if (!TransactionIdIsCurrentTransactionId(heapTuple->t_data->t_xmax))
elog(ERROR, "IndexBuildHeapScan: concurrent delete in progress");
indexIt = true;
tupleIsAlive = false;
break;
default:
elog(ERROR, "Unexpected HeapTupleSatisfiesVacuum result");
- indexIt = tupleIsAlive = false; /* keep compiler quiet */
+ indexIt = tupleIsAlive = false; /* keep compiler quiet */
break;
}
LockBuffer(scan->rs_cbuf, BUFFER_LOCK_UNLOCK);
- if (! indexIt)
+ if (!indexIt)
continue;
}
else
*/
if (predicate != NIL)
{
- if (! tupleIsAlive)
+ if (!tupleIsAlive)
continue;
ExecStoreTuple(heapTuple, slot, InvalidBuffer, false);
if (!ExecQual(predicate, econtext, false))
/*
* For the current heap tuple, extract all the attributes we use
- * in this index, and note which are null. This also performs
+ * in this index, and note which are null. This also performs
* evaluation of the function, if this is a functional index.
*/
FormIndexDatum(indexInfo,
/*
* You'd think we should go ahead and build the index tuple here,
- * but some index AMs want to do further processing on the
- * data first. So pass the attdata and nulls arrays, instead.
+ * but some index AMs want to do further processing on the data
+ * first. So pass the attdata and nulls arrays, instead.
*/
/* Call the AM's callback routine to process the tuple */
if (inplace)
{
-
/*
* Release any buffers associated with this index. If they're
* dirty, they're just dropped without bothering to flush to disk.
upd_pg_class_inplace = true;
/*
- * Ensure to hold an exclusive lock throughout the
- * transaction. The lock could be less intensive
- * but now it's AccessExclusiveLock for simplicity.
+ * Ensure to hold an exclusive lock throughout the transaction. The
+ * lock could be less intensive but now it's AccessExclusiveLock for
+ * simplicity.
*/
rel = heap_open(relid, AccessExclusiveLock);
+
/*
* ignore the indexes of the target system relation while processing
* reindex.
else
elog(ERROR, "the target relation %u is shared", relid);
}
+
/*
- * Continue to hold the lock.
+ * Continue to hold the lock.
*/
heap_close(rel, NoLock);
heap_close(indexRelation, AccessShareLock);
if (reindexed)
{
-
/*
* Ok,we could use the reindexed indexes of the target system
* relation now.
{
if (!overwrite && relid == RelOid_pg_class)
{
-
/*
* For pg_class, relhasindex should be set to true here in
* place.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.39 2001/08/10 15:49:39 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.40 2001/10/25 05:49:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
else
{
-
/*
* If no finalfn, aggregate result type is type of the state value
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.62 2001/10/22 19:34:13 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.63 2001/10/25 05:49:23 momjian Exp $
*
* NOTES
* these routines moved here from commands/define.c and somewhat cleaned up.
static bool
validOperatorName(const char *name)
{
- size_t len = strlen(name);
+ size_t len = strlen(name);
/* Can't be empty or too long */
if (len == 0 || len >= NAMEDATALEN)
return false;
/*
- * For SQL92 compatibility, '+' and '-' cannot be the
- * last char of a multi-char operator unless the operator
- * contains chars that are not in SQL92 operators.
- * The idea is to lex '=-' as two operators, but not
- * to forbid operator names like '?-' that could not be
- * sequences of SQL92 operators.
+ * For SQL92 compatibility, '+' and '-' cannot be the last char of a
+ * multi-char operator unless the operator contains chars that are not
+ * in SQL92 operators. The idea is to lex '=-' as two operators, but
+ * not to forbid operator names like '?-' that could not be sequences
+ * of SQL92 operators.
*/
if (len > 1 &&
- (name[len-1] == '+' ||
- name[len-1] == '-'))
+ (name[len - 1] == '+' ||
+ name[len - 1] == '-'))
{
- int ic;
+ int ic;
- for (ic = len-2; ic >= 0; ic--)
+ for (ic = len - 2; ic >= 0; ic--)
{
if (strchr("~!@#^&|`?$%", name[ic]))
break;
HeapScanDesc pg_operator_scan;
Oid operatorObjectId;
HeapTuple tup;
- ScanKeyData opKey[3];
+ ScanKeyData opKey[3];
/*
* form scan key
int nargs;
NameData oname;
TupleDesc tupDesc;
- ScanKeyData opKey[3];
+ ScanKeyData opKey[3];
operatorObjectId = OperatorGet(operatorName,
leftTypeName,
}
else
{
-
/*
* self-linkage to this operator; will fix below. Note
* that only self-linkage for commutation makes sense.
char nulls[Natts_pg_operator];
char replaces[Natts_pg_operator];
Datum values[Natts_pg_operator];
- ScanKeyData opKey[1];
+ ScanKeyData opKey[1];
for (i = 0; i < Natts_pg_operator; ++i)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.61 2001/10/06 23:21:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.62 2001/10/25 05:49:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (languageObjectId == SQLlanguageId)
{
-
/*
* If this call is defining a set, check if the set is already
* defined by looking to see whether this call's function text
prosrc = procedureName;
if (fmgr_internal_function(prosrc) == InvalidOid)
elog(ERROR,
- "there is no built-in function named \"%s\"",
+ "there is no built-in function named \"%s\"",
prosrc);
}
if (languageObjectId == ClanguageId)
{
- void *libraryhandle;
+ void *libraryhandle;
/* If link symbol is specified as "-", substitute procedure name */
if (strcmp(prosrc, "-") == 0)
if (HeapTupleIsValid(oldtup))
{
/* There is one; okay to replace it? */
- Form_pg_proc oldproc = (Form_pg_proc) GETSTRUCT(oldtup);
+ Form_pg_proc oldproc = (Form_pg_proc) GETSTRUCT(oldtup);
if (!replace)
elog(ERROR, "function %s already exists with same argument types",
if (GetUserId() != oldproc->proowner && !superuser())
elog(ERROR, "ProcedureCreate: you do not have permission to replace function %s",
procedureName);
+
/*
* Not okay to change the return type of the existing proc, since
* existing rules, views, etc may depend on the return type.
"\n\tUse DROP FUNCTION first.");
/* Okay, do it... */
- tup = heap_modifytuple(oldtup, rel, values, nulls, replaces);
- simple_heap_update(rel, &tup->t_self, tup);
+ tup = heap_modifytuple(oldtup, rel, values, nulls, replaces);
+ simple_heap_update(rel, &tup->t_self, tup);
ReleaseSysCache(oldtup);
}
/*
* For base-type returns, the target list should have exactly one
- * entry, and its type should agree with what the user declared.
- * (As of Postgres 7.2, we accept binary-compatible types too.)
+ * entry, and its type should agree with what the user declared. (As
+ * of Postgres 7.2, we accept binary-compatible types too.)
*/
typerelid = typeidTypeRelid(rettype);
if (typerelid == InvalidOid)
/*
* If the target list is of length 1, and the type of the varnode in
* the target list matches the declared return type, this is okay.
- * This can happen, for example, where the body of the function
- * is 'SELECT func2()', where func2 has the same return type as
- * the function that's calling it.
+ * This can happen, for example, where the body of the function is
+ * 'SELECT func2()', where func2 has the same return type as the
+ * function that's calling it.
*/
if (tlistlen == 1)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.64 2001/10/12 00:07:14 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.65 2001/10/25 05:49:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
/*
- * validate size specifications: either positive (fixed-length) or
- * -1 (variable-length).
+ * validate size specifications: either positive (fixed-length) or -1
+ * (variable-length).
*/
- if (! (internalSize > 0 || internalSize == -1))
+ if (!(internalSize > 0 || internalSize == -1))
elog(ERROR, "TypeCreate: invalid type internal size %d",
internalSize);
- if (! (externalSize > 0 || externalSize == -1))
+ if (!(externalSize > 0 || externalSize == -1))
elog(ERROR, "TypeCreate: invalid type external size %d",
externalSize);
if (!OidIsValid(procOid))
{
-
/*
* For array types, the input procedures may take 3 args (data
* value, element OID, atttypmod); the pg_proc argtype
*/
if (defaultTypeValue)
values[i] = DirectFunctionCall1(textin,
- CStringGetDatum(defaultTypeValue));
+ CStringGetDatum(defaultTypeValue));
else
nulls[i] = 'n';
i++; /* 17 */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.13 2001/03/22 06:16:12 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.14 2001/10/25 05:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
case T_Param:
{
-
/*
* the node is a parameter, substitute the entry from the
* target list of the child that corresponds to the
if (p->param_tlist)
{
-
/*
* we have a parameter with an attribute like
* $N.foo so replace it with a new var node
break;
case T_Expr:
{
-
/*
* the node is an expression, we need to recursively call
* ourselves until we find parameter nodes
{
case T_Param:
{
-
/*
* the node is a parameter, substitute the entry from the
* target list of the child that corresponds to the
if (p->param_tlist)
{
-
/*
* we have a parameter with an attribute like
* $N.foo so match the resname "foo" against the
break;
case T_Expr:
{
-
/*
* the node is an expression, we need to recursively call
* ourselves until we find parameter nodes
{
case TG_SQL:
{
-
/*
* for SQL ingredients, the SQL query is contained in
* the 'src' field
}
else if (n->nodeType == TG_EYE_NODE)
{
-
/*
* if we hit an eye, we need to stop and make what we have into a
* subrecipe query block
}
else if (n->nodeType == TG_TEE_NODE)
{
-
/*
* if we hit a tee, check to see if the parsing has been done for
* this tee already by the other parent
rel = RelationNameGetRelation(n->nodeName);
if (RelationIsValid(rel))
{
-
/*
* this tee has already been visited, no need to do any
* further processing
if (RelationIsValid(rel))
{
-
/*
* for complex types, create new relation with the same
* tuple descriptor as the output table type
}
else
{
-
/*
* we have to create a relation with one attribute of the
* simple base type. That attribute will have an attr
snode = (Scan *) plan;
if (snode->scanrelid == rt_ind)
{
-
/*
* found the sequential scan that should be replaced with the
* tplan.
}
-
#endif /* TIOGA */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: recipe.h,v 1.3 2001/01/24 19:42:53 momjian Exp $
+ * $Id: recipe.h,v 1.4 2001/10/25 05:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "nodes/parsenodes.h"
extern void beginRecipe(RecipeStmt *stmt);
-
#endif /* RECIPE_H */
* doesn't work! - jolly 8/19/95
*
*
- * $Id: version.c,v 1.26 2001/03/23 04:49:52 momjian Exp $
+ * $Id: version.c,v 1.27 2001/10/25 05:49:27 momjian Exp $
*
* NOTES
* At the point the version is defined, 2 physical relations are created
CommandCounterIncrement();
pg_exec_query(query);
}
-
#endif
/*
* Define a version.
VersionReplace(name, saved_basename, saved_snapshot);
VersionRetrieve(name, saved_basename, saved_snapshot);
}
-
#endif
/*
sprintf(query_buf, "CREATE TABLE %s_del (DOID oid)", vname);
eval_as_new_xact(query_buf);
}
-
#endif
return;
}
-
#endif
/*
eval_as_new_xact(rule_buf);
}
-
#endif
/*
/* printf("%s\n",rule_buf); */
}
-
#endif
/*
eval_as_new_xact(rule_buf);
#endif /* OLD_REWRITE */
}
-
#endif
/*
/* printf("%s\n",rule_buf); */
}
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.22 2001/07/05 19:33:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.23 2001/10/25 05:49:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
* Analysis algorithms supported
*/
-typedef enum {
+typedef enum
+{
ALG_MINIMAL = 1, /* Compute only most-common-values */
- ALG_SCALAR /* Compute MCV, histogram, sort correlation */
+ ALG_SCALAR /* Compute MCV, histogram, sort
+ * correlation */
} AlgCode;
/*
Oid eqfunc; /* and associated function */
Oid ltopr; /* '<' operator for datatype, if any */
- /* These fields are filled in by the actual statistics-gathering routine */
+ /*
+ * These fields are filled in by the actual statistics-gathering
+ * routine
+ */
bool stats_valid;
float4 stanullfrac; /* fraction of entries that are NULL */
int4 stawidth; /* average width */
#define swapDatum(a,b) do {Datum _tmp; _tmp=a; a=b; b=_tmp;} while(0)
-static int MESSAGE_LEVEL;
+static int MESSAGE_LEVEL;
/* context information for compare_scalars() */
static FmgrInfo *datumCmpFn;
static VacAttrStats *examine_attribute(Relation onerel, int attnum);
static int acquire_sample_rows(Relation onerel, HeapTuple *rows,
- int targrows, double *totalrows);
+ int targrows, double *totalrows);
static double random_fract(void);
static double init_selection_state(int n);
static double select_next_random_record(double t, int n, double *stateptr);
-static int compare_rows(const void *a, const void *b);
-static int compare_scalars(const void *a, const void *b);
-static int compare_mcvs(const void *a, const void *b);
+static int compare_rows(const void *a, const void *b);
+static int compare_scalars(const void *a, const void *b);
+static int compare_mcvs(const void *a, const void *b);
static void compute_minimal_stats(VacAttrStats *stats,
- TupleDesc tupDesc, double totalrows,
- HeapTuple *rows, int numrows);
+ TupleDesc tupDesc, double totalrows,
+ HeapTuple *rows, int numrows);
static void compute_scalar_stats(VacAttrStats *stats,
- TupleDesc tupDesc, double totalrows,
- HeapTuple *rows, int numrows);
+ TupleDesc tupDesc, double totalrows,
+ HeapTuple *rows, int numrows);
static void update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats);
* Begin a transaction for analyzing this relation.
*
* Note: All memory allocated during ANALYZE will live in
- * TransactionCommandContext or a subcontext thereof, so it will
- * all be released by transaction commit at the end of this routine.
+ * TransactionCommandContext or a subcontext thereof, so it will all
+ * be released by transaction commit at the end of this routine.
*/
StartTransactionCommand();
ReleaseSysCache(tuple);
/*
- * Open the class, getting only a read lock on it, and check permissions.
- * Permissions check should match vacuum's check!
+ * Open the class, getting only a read lock on it, and check
+ * permissions. Permissions check should match vacuum's check!
*/
onerel = heap_open(relid, AccessShareLock);
- if (! (pg_ownercheck(GetUserId(), RelationGetRelationName(onerel),
- RELNAME) ||
- (is_dbadmin(MyDatabaseId) && !onerel->rd_rel->relisshared)))
+ if (!(pg_ownercheck(GetUserId(), RelationGetRelationName(onerel),
+ RELNAME) ||
+ (is_dbadmin(MyDatabaseId) && !onerel->rd_rel->relisshared)))
{
/* No need for a notice if we already complained during VACUUM */
if (!vacstmt->vacuum)
if (i >= attr_cnt)
elog(ERROR, "ANALYZE: there is no attribute %s in %s",
col, RelationGetRelationName(onerel));
- vacattrstats[tcnt] = examine_attribute(onerel, i+1);
+ vacattrstats[tcnt] = examine_attribute(onerel, i + 1);
if (vacattrstats[tcnt] != NULL)
tcnt++;
}
tcnt = 0;
for (i = 0; i < attr_cnt; i++)
{
- vacattrstats[tcnt] = examine_attribute(onerel, i+1);
+ vacattrstats[tcnt] = examine_attribute(onerel, i + 1);
if (vacattrstats[tcnt] != NULL)
tcnt++;
}
/*
* Determine how many rows we need to sample, using the worst case
- * from all analyzable columns. We use a lower bound of 100 rows
- * to avoid possible overflow in Vitter's algorithm.
+ * from all analyzable columns. We use a lower bound of 100 rows to
+ * avoid possible overflow in Vitter's algorithm.
*/
targrows = 100;
for (i = 0; i < attr_cnt; i++)
/*
* If we are running a standalone ANALYZE, update pages/tuples stats
* in pg_class. We have the accurate page count from heap_beginscan,
- * but only an approximate number of tuples; therefore, if we are
- * part of VACUUM ANALYZE do *not* overwrite the accurate count already
+ * but only an approximate number of tuples; therefore, if we are part
+ * of VACUUM ANALYZE do *not* overwrite the accurate count already
* inserted by VACUUM.
*/
if (!vacstmt->vacuum)
RelationGetForm(onerel)->relhasindex);
/*
- * Compute the statistics. Temporary results during the calculations
+ * Compute the statistics. Temporary results during the calculations
* for each column are stored in a child context. The calc routines
* are responsible to make sure that whatever they store into the
* VacAttrStats structure is allocated in TransactionCommandContext.
/*
* Emit the completed stats rows into pg_statistic, replacing any
- * previous statistics for the target columns. (If there are stats
- * in pg_statistic for columns we didn't process, we leave them alone.)
+ * previous statistics for the target columns. (If there are
+ * stats in pg_statistic for columns we didn't process, we leave
+ * them alone.)
*/
update_attstats(relid, attr_cnt, vacattrstats);
}
static VacAttrStats *
examine_attribute(Relation onerel, int attnum)
{
- Form_pg_attribute attr = onerel->rd_att->attrs[attnum-1];
+ Form_pg_attribute attr = onerel->rd_att->attrs[attnum - 1];
Operator func_operator;
Oid oprrest;
HeapTuple typtuple;
return NULL;
/*
- * If we have "=" then we're at least able to do the minimal algorithm,
- * so start filling in a VacAttrStats struct.
+ * If we have "=" then we're at least able to do the minimal
+ * algorithm, so start filling in a VacAttrStats struct.
*/
stats = (VacAttrStats *) palloc(sizeof(VacAttrStats));
MemSet(stats, 0, sizeof(VacAttrStats));
{
oprrest = ((Form_pg_operator) GETSTRUCT(func_operator))->oprrest;
if (oprrest == F_SCALARLTSEL)
- {
ltopr = oprid(func_operator);
- }
ReleaseSysCache(func_operator);
}
stats->ltopr = ltopr;
/*
- * Determine the algorithm to use (this will get more complicated later)
+ * Determine the algorithm to use (this will get more complicated
+ * later)
*/
if (OidIsValid(ltopr))
{
* acquire_sample_rows -- acquire a random sample of rows from the table
*
* Up to targrows rows are collected (if there are fewer than that many
- * rows in the table, all rows are collected). When the table is larger
+ * rows in the table, all rows are collected). When the table is larger
* than targrows, a truly random sample is collected: every row has an
* equal chance of ending up in the final sample.
*
int numrows = 0;
HeapScanDesc scan;
HeapTuple tuple;
- ItemPointer lasttuple;
- BlockNumber lastblock,
+ ItemPointer lasttuple;
+ BlockNumber lastblock,
estblock;
OffsetNumber lastoffset;
int numest;
double rstate;
Assert(targrows > 1);
+
/*
* Do a simple linear scan until we reach the target number of rows.
*/
break;
}
heap_endscan(scan);
+
/*
- * If we ran out of tuples then we're done, no matter how few we
+ * If we ran out of tuples then we're done, no matter how few we
* collected. No sort is needed, since they're already in order.
*/
if (!HeapTupleIsValid(tuple))
*totalrows = (double) numrows;
return numrows;
}
+
/*
* Otherwise, start replacing tuples in the sample until we reach the
* end of the relation. This algorithm is from Jeff Vitter's paper
- * (see full citation below). It works by repeatedly computing the number
- * of the next tuple we want to fetch, which will replace a randomly
- * chosen element of the reservoir (current set of tuples). At all times
- * the reservoir is a true random sample of the tuples we've passed over
- * so far, so when we fall off the end of the relation we're done.
+ * (see full citation below). It works by repeatedly computing the
+ * number of the next tuple we want to fetch, which will replace a
+ * randomly chosen element of the reservoir (current set of tuples).
+ * At all times the reservoir is a true random sample of the tuples
+ * we've passed over so far, so when we fall off the end of the
+ * relation we're done.
*
- * A slight difficulty is that since we don't want to fetch tuples or even
- * pages that we skip over, it's not possible to fetch *exactly* the N'th
- * tuple at each step --- we don't know how many valid tuples are on
- * the skipped pages. We handle this by assuming that the average number
- * of valid tuples/page on the pages already scanned over holds good for
- * the rest of the relation as well; this lets us estimate which page
- * the next tuple should be on and its position in the page. Then we
- * fetch the first valid tuple at or after that position, being careful
- * not to use the same tuple twice. This approach should still give a
- * good random sample, although it's not perfect.
+ * A slight difficulty is that since we don't want to fetch tuples or
+ * even pages that we skip over, it's not possible to fetch *exactly*
+ * the N'th tuple at each step --- we don't know how many valid tuples
+ * are on the skipped pages. We handle this by assuming that the
+ * average number of valid tuples/page on the pages already scanned
+ * over holds good for the rest of the relation as well; this lets us
+ * estimate which page the next tuple should be on and its position in
+ * the page. Then we fetch the first valid tuple at or after that
+ * position, being careful not to use the same tuple twice. This
+ * approach should still give a good random sample, although it's not
+ * perfect.
*/
- lasttuple = &(rows[numrows-1]->t_self);
+ lasttuple = &(rows[numrows - 1]->t_self);
lastblock = ItemPointerGetBlockNumber(lasttuple);
lastoffset = ItemPointerGetOffsetNumber(lasttuple);
+
/*
- * If possible, estimate tuples/page using only completely-scanned pages.
+ * If possible, estimate tuples/page using only completely-scanned
+ * pages.
*/
for (numest = numrows; numest > 0; numest--)
{
- if (ItemPointerGetBlockNumber(&(rows[numest-1]->t_self)) != lastblock)
+ if (ItemPointerGetBlockNumber(&(rows[numest - 1]->t_self)) != lastblock)
break;
}
if (numest == 0)
estblock = lastblock + 1;
}
else
- {
estblock = lastblock;
- }
tuplesperpage = (double) numest / (double) estblock;
t = (double) numrows; /* t is the # of records processed so far */
rstate = init_selection_state(targrows);
for (;;)
{
- double targpos;
- BlockNumber targblock;
- Buffer targbuffer;
- Page targpage;
- OffsetNumber targoffset,
- maxoffset;
+ double targpos;
+ BlockNumber targblock;
+ Buffer targbuffer;
+ Page targpage;
+ OffsetNumber targoffset,
+ maxoffset;
t = select_next_random_record(t, targrows, &rstate);
/* Try to read the t'th record in the table */
targpos = t / tuplesperpage;
targblock = (BlockNumber) targpos;
- targoffset = ((int) ((targpos - targblock) * tuplesperpage)) +
+ targoffset = ((int) ((targpos - targblock) * tuplesperpage)) +
FirstOffsetNumber;
/* Make sure we are past the last selected record */
if (targblock <= lastblock)
targoffset = lastoffset + 1;
}
/* Loop to find first valid record at or after given position */
- pageloop:;
+pageloop:;
+
/*
- * Have we fallen off the end of the relation? (We rely on
+ * Have we fallen off the end of the relation? (We rely on
* heap_beginscan to have updated rd_nblocks.)
*/
if (targblock >= onerel->rd_nblocks)
break;
+
/*
- * We must maintain a pin on the target page's buffer to ensure that
- * the maxoffset value stays good (else concurrent VACUUM might
- * delete tuples out from under us). Hence, pin the page until we
- * are done looking at it. We don't maintain a lock on the page,
- * so tuples could get added to it, but we ignore such tuples.
+ * We must maintain a pin on the target page's buffer to ensure
+ * that the maxoffset value stays good (else concurrent VACUUM
+ * might delete tuples out from under us). Hence, pin the page
+ * until we are done looking at it. We don't maintain a lock on
+ * the page, so tuples could get added to it, but we ignore such
+ * tuples.
*/
targbuffer = ReadBuffer(onerel, targblock);
if (!BufferIsValid(targbuffer))
* Found a suitable tuple, so save it, replacing one old
* tuple at random
*/
- int k = (int) (targrows * random_fract());
+ int k = (int) (targrows * random_fract());
Assert(k >= 0 && k < targrows);
heap_freetuple(rows[k]);
static double
random_fract(void)
{
- long z;
+ long z;
/* random() can produce endpoint values, try again if so */
do
{
z = random();
- } while (! (z > 0 && z < MAX_RANDOM_VALUE));
+ } while (!(z > 0 && z < MAX_RANDOM_VALUE));
return (double) z / (double) MAX_RANDOM_VALUE;
}
init_selection_state(int n)
{
/* Initial value of W (for use when Algorithm Z is first applied) */
- return exp(- log(random_fract())/n);
+ return exp(-log(random_fract()) / n);
}
static double
if (t <= (22.0 * n))
{
/* Process records using Algorithm X until t is large enough */
- double V,
- quot;
+ double V,
+ quot;
V = random_fract(); /* Generate V */
t += 1;
else
{
/* Now apply Algorithm Z */
- double W = *stateptr;
- double term = t - (double) n + 1;
- double S;
+ double W = *stateptr;
+ double term = t - (double) n + 1;
+ double S;
for (;;)
{
- double numer,
- numer_lim,
- denom;
- double U,
- X,
- lhs,
- rhs,
- y,
- tmp;
+ double numer,
+ numer_lim,
+ denom;
+ double U,
+ X,
+ lhs,
+ rhs,
+ y,
+ tmp;
/* Generate U and X */
U = random_fract();
S = floor(X); /* S is tentatively set to floor(X) */
/* Test if U <= h(S)/cg(X) in the manner of (6.3) */
tmp = (t + 1) / term;
- lhs = exp(log(((U * tmp * tmp) * (term + S))/(t + X))/n);
- rhs = (((t + X)/(term + S)) * term)/t;
+ lhs = exp(log(((U * tmp * tmp) * (term + S)) / (t + X)) / n);
+ rhs = (((t + X) / (term + S)) * term) / t;
if (lhs <= rhs)
{
- W = rhs/lhs;
+ W = rhs / lhs;
break;
}
/* Test if U <= f(S)/cg(X) */
- y = (((U * (t + 1))/term) * (t + S + 1))/(t + X);
+ y = (((U * (t + 1)) / term) * (t + S + 1)) / (t + X);
if ((double) n < S)
{
denom = t;
y *= numer / denom;
denom -= 1;
}
- W = exp(- log(random_fract())/n); /* Generate W in advance */
- if (exp(log(y)/n) <= (t + X)/t)
+ W = exp(-log(random_fract()) / n); /* Generate W in advance */
+ if (exp(log(y) / n) <= (t + X) / t)
break;
}
t += S + 1;
static int
compare_rows(const void *a, const void *b)
{
- HeapTuple ha = * (HeapTuple *) a;
- HeapTuple hb = * (HeapTuple *) b;
- BlockNumber ba = ItemPointerGetBlockNumber(&ha->t_self);
+ HeapTuple ha = *(HeapTuple *) a;
+ HeapTuple hb = *(HeapTuple *) b;
+ BlockNumber ba = ItemPointerGetBlockNumber(&ha->t_self);
OffsetNumber oa = ItemPointerGetOffsetNumber(&ha->t_self);
- BlockNumber bb = ItemPointerGetBlockNumber(&hb->t_self);
+ BlockNumber bb = ItemPointerGetBlockNumber(&hb->t_self);
OffsetNumber ob = ItemPointerGetOffsetNumber(&hb->t_self);
if (ba < bb)
FmgrInfo f_cmpeq;
typedef struct
{
- Datum value;
- int count;
+ Datum value;
+ int count;
} TrackItem;
TrackItem *track;
int track_cnt,
track_max;
int num_mcv = stats->attr->attstattarget;
- /* We track up to 2*n values for an n-element MCV list; but at least 10 */
+ /*
+ * We track up to 2*n values for an n-element MCV list; but at least
+ * 10
+ */
track_max = 2 * num_mcv;
if (track_max < 10)
track_max = 10;
/*
* If it's a varlena field, add up widths for average width
- * calculation. Note that if the value is toasted, we
- * use the toasted width. We don't bother with this calculation
- * if it's a fixed-width type.
+ * calculation. Note that if the value is toasted, we use the
+ * toasted width. We don't bother with this calculation if it's a
+ * fixed-width type.
*/
if (is_varlena)
{
total_width += VARSIZE(DatumGetPointer(value));
+
/*
* If the value is toasted, we want to detoast it just once to
- * avoid repeated detoastings and resultant excess memory usage
- * during the comparisons. Also, check to see if the value is
- * excessively wide, and if so don't detoast at all --- just
- * ignore the value.
+ * avoid repeated detoastings and resultant excess memory
+ * usage during the comparisons. Also, check to see if the
+ * value is excessively wide, and if so don't detoast at all
+ * --- just ignore the value.
*/
if (toast_raw_datum_size(value) > WIDTH_THRESHOLD)
{
/* Found a match */
track[j].count++;
/* This value may now need to "bubble up" in the track list */
- while (j > 0 && track[j].count > track[j-1].count)
+ while (j > 0 && track[j].count > track[j - 1].count)
{
- swapDatum(track[j].value, track[j-1].value);
- swapInt(track[j].count, track[j-1].count);
+ swapDatum(track[j].value, track[j - 1].value);
+ swapInt(track[j].count, track[j - 1].count);
j--;
}
}
/* No match. Insert at head of count-1 list */
if (track_cnt < track_max)
track_cnt++;
- for (j = track_cnt-1; j > firstcount1; j--)
+ for (j = track_cnt - 1; j > firstcount1; j--)
{
- track[j].value = track[j-1].value;
- track[j].count = track[j-1].count;
+ track[j].value = track[j - 1].value;
+ track[j].count = track[j - 1].count;
}
if (firstcount1 < track_cnt)
{
/* We can only compute valid stats if we found some non-null values. */
if (nonnull_cnt > 0)
{
- int nmultiple,
- summultiple;
+ int nmultiple,
+ summultiple;
stats->stats_valid = true;
/* Do the simple null-frac and width stats */
nmultiple == track_cnt)
{
/*
- * Our track list includes every value in the sample, and every
- * value appeared more than once. Assume the column has just
- * these values.
+ * Our track list includes every value in the sample, and
+ * every value appeared more than once. Assume the column has
+ * just these values.
*/
stats->stadistinct = track_cnt;
}
* We assume (not very reliably!) that all the multiply-occurring
* values are reflected in the final track[] list, and the other
* nonnull values all appeared but once. (XXX this usually
- * results in a drastic overestimate of ndistinct. Can we do
+ * results in a drastic overestimate of ndistinct. Can we do
* any better?)
*----------
*/
- int f1 = nonnull_cnt - summultiple;
- double term1;
+ int f1 = nonnull_cnt - summultiple;
+ double term1;
if (f1 < 1)
f1 = 1;
* a fixed value.
*/
if (stats->stadistinct > 0.1 * totalrows)
- stats->stadistinct = - (stats->stadistinct / totalrows);
+ stats->stadistinct = -(stats->stadistinct / totalrows);
/*
* Decide how many values are worth storing as most-common values.
* If we are able to generate a complete MCV list (all the values
* in the sample will fit, and we think these are all the ones in
- * the table), then do so. Otherwise, store only those values
- * that are significantly more common than the (estimated) average.
- * We set the threshold rather arbitrarily at 25% more than average,
- * with at least 2 instances in the sample.
+ * the table), then do so. Otherwise, store only those values
+ * that are significantly more common than the (estimated)
+ * average. We set the threshold rather arbitrarily at 25% more
+ * than average, with at least 2 instances in the sample.
*/
if (track_cnt < track_max && toowide_cnt == 0 &&
stats->stadistinct > 0 &&
}
else
{
- double ndistinct = stats->stadistinct;
- double avgcount,
- mincount;
+ double ndistinct = stats->stadistinct;
+ double avgcount,
+ mincount;
if (ndistinct < 0)
- ndistinct = - ndistinct * totalrows;
+ ndistinct = -ndistinct * totalrows;
/* estimate # of occurrences in sample of a typical value */
avgcount = (double) numrows / ndistinct;
/* set minimum threshold count to store a value */
if (num_mcv > 0)
{
MemoryContext old_context;
- Datum *mcv_values;
- float4 *mcv_freqs;
+ Datum *mcv_values;
+ float4 *mcv_freqs;
/* Must copy the target values into TransactionCommandContext */
old_context = MemoryContextSwitchTo(TransactionCommandContext);
/*
* If it's a varlena field, add up widths for average width
- * calculation. Note that if the value is toasted, we
- * use the toasted width. We don't bother with this calculation
- * if it's a fixed-width type.
+ * calculation. Note that if the value is toasted, we use the
+ * toasted width. We don't bother with this calculation if it's a
+ * fixed-width type.
*/
if (is_varlena)
{
total_width += VARSIZE(DatumGetPointer(value));
+
/*
* If the value is toasted, we want to detoast it just once to
- * avoid repeated detoastings and resultant excess memory usage
- * during the comparisons. Also, check to see if the value is
- * excessively wide, and if so don't detoast at all --- just
- * ignore the value.
+ * avoid repeated detoastings and resultant excess memory
+ * usage during the comparisons. Also, check to see if the
+ * value is excessively wide, and if so don't detoast at all
+ * --- just ignore the value.
*/
if (toast_raw_datum_size(value) > WIDTH_THRESHOLD)
{
/* We can only compute valid stats if we found some sortable values. */
if (values_cnt > 0)
{
- int ndistinct, /* # distinct values in sample */
- nmultiple, /* # that appear multiple times */
- num_hist,
- dups_cnt;
- int slot_idx = 0;
+ int ndistinct, /* # distinct values in sample */
+ nmultiple, /* # that appear multiple times */
+ num_hist,
+ dups_cnt;
+ int slot_idx = 0;
/* Sort the collected values */
datumCmpFn = &f_cmpfn;
sizeof(ScalarItem), compare_scalars);
/*
- * Now scan the values in order, find the most common ones,
- * and also accumulate ordering-correlation statistics.
+ * Now scan the values in order, find the most common ones, and
+ * also accumulate ordering-correlation statistics.
*
* To determine which are most common, we first have to count the
- * number of duplicates of each value. The duplicates are adjacent
- * in the sorted list, so a brute-force approach is to compare
- * successive datum values until we find two that are not equal.
- * However, that requires N-1 invocations of the datum comparison
- * routine, which are completely redundant with work that was done
- * during the sort. (The sort algorithm must at some point have
- * compared each pair of items that are adjacent in the sorted order;
- * otherwise it could not know that it's ordered the pair correctly.)
- * We exploit this by having compare_scalars remember the highest
- * tupno index that each ScalarItem has been found equal to. At the
- * end of the sort, a ScalarItem's tupnoLink will still point to
- * itself if and only if it is the last item of its group of
- * duplicates (since the group will be ordered by tupno).
+ * number of duplicates of each value. The duplicates are
+ * adjacent in the sorted list, so a brute-force approach is to
+ * compare successive datum values until we find two that are not
+ * equal. However, that requires N-1 invocations of the datum
+ * comparison routine, which are completely redundant with work
+ * that was done during the sort. (The sort algorithm must at
+ * some point have compared each pair of items that are adjacent
+ * in the sorted order; otherwise it could not know that it's
+ * ordered the pair correctly.) We exploit this by having
+ * compare_scalars remember the highest tupno index that each
+ * ScalarItem has been found equal to. At the end of the sort, a
+ * ScalarItem's tupnoLink will still point to itself if and only
+ * if it is the last item of its group of duplicates (since the
+ * group will be ordered by tupno).
*/
corr_xysum = 0;
ndistinct = 0;
{
int tupno = values[i].tupno;
- corr_xysum += (double) i * (double) tupno;
+ corr_xysum += (double) i *(double) tupno;
+
dups_cnt++;
if (tupnoLink[tupno] == tupno)
{
{
nmultiple++;
if (track_cnt < num_mcv ||
- dups_cnt > track[track_cnt-1].count)
+ dups_cnt > track[track_cnt - 1].count)
{
/*
* Found a new item for the mcv list; find its
* Loop invariant is that j points at an empty/
* replaceable slot.
*/
- int j;
+ int j;
if (track_cnt < num_mcv)
track_cnt++;
- for (j = track_cnt-1; j > 0; j--)
+ for (j = track_cnt - 1; j > 0; j--)
{
- if (dups_cnt <= track[j-1].count)
+ if (dups_cnt <= track[j - 1].count)
break;
- track[j].count = track[j-1].count;
- track[j].first = track[j-1].first;
+ track[j].count = track[j - 1].count;
+ track[j].first = track[j - 1].first;
}
track[j].count = dups_cnt;
track[j].first = i + 1 - dups_cnt;
else if (toowide_cnt == 0 && nmultiple == ndistinct)
{
/*
- * Every value in the sample appeared more than once. Assume the
- * column has just these values.
+ * Every value in the sample appeared more than once. Assume
+ * the column has just these values.
*/
stats->stadistinct = ndistinct;
}
* Overwidth values are assumed to have been distinct.
*----------
*/
- int f1 = ndistinct - nmultiple + toowide_cnt;
- double term1;
+ int f1 = ndistinct - nmultiple + toowide_cnt;
+ double term1;
if (f1 < 1)
f1 = 1;
* a fixed value.
*/
if (stats->stadistinct > 0.1 * totalrows)
- stats->stadistinct = - (stats->stadistinct / totalrows);
+ stats->stadistinct = -(stats->stadistinct / totalrows);
/*
* Decide how many values are worth storing as most-common values.
* If we are able to generate a complete MCV list (all the values
* in the sample will fit, and we think these are all the ones in
- * the table), then do so. Otherwise, store only those values
- * that are significantly more common than the (estimated) average.
- * We set the threshold rather arbitrarily at 25% more than average,
- * with at least 2 instances in the sample. Also, we won't suppress
- * values that have a frequency of at least 1/K where K is the
- * intended number of histogram bins; such values might otherwise
- * cause us to emit duplicate histogram bin boundaries.
+ * the table), then do so. Otherwise, store only those values
+ * that are significantly more common than the (estimated)
+ * average. We set the threshold rather arbitrarily at 25% more
+ * than average, with at least 2 instances in the sample. Also,
+ * we won't suppress values that have a frequency of at least 1/K
+ * where K is the intended number of histogram bins; such values
+ * might otherwise cause us to emit duplicate histogram bin
+ * boundaries.
*/
if (track_cnt == ndistinct && toowide_cnt == 0 &&
stats->stadistinct > 0 &&
}
else
{
- double ndistinct = stats->stadistinct;
- double avgcount,
- mincount,
- maxmincount;
+ double ndistinct = stats->stadistinct;
+ double avgcount,
+ mincount,
+ maxmincount;
if (ndistinct < 0)
- ndistinct = - ndistinct * totalrows;
+ ndistinct = -ndistinct * totalrows;
/* estimate # of occurrences in sample of a typical value */
avgcount = (double) numrows / ndistinct;
/* set minimum threshold count to store a value */
if (num_mcv > 0)
{
MemoryContext old_context;
- Datum *mcv_values;
- float4 *mcv_freqs;
+ Datum *mcv_values;
+ float4 *mcv_freqs;
/* Must copy the target values into TransactionCommandContext */
old_context = MemoryContextSwitchTo(TransactionCommandContext);
if (num_hist >= 2)
{
MemoryContext old_context;
- Datum *hist_values;
- int nvals;
+ Datum *hist_values;
+ int nvals;
/* Sort the MCV items into position order to speed next loop */
qsort((void *) track, num_mcv,
* Collapse out the MCV items from the values[] array.
*
* Note we destroy the values[] array here... but we don't need
- * it for anything more. We do, however, still need values_cnt.
- * nvals will be the number of remaining entries in values[].
+ * it for anything more. We do, however, still need
+ * values_cnt. nvals will be the number of remaining entries
+ * in values[].
*/
if (num_mcv > 0)
{
- int src,
- dest;
- int j;
+ int src,
+ dest;
+ int j;
src = dest = 0;
j = 0; /* index of next interesting MCV item */
while (src < values_cnt)
{
- int ncopy;
+ int ncopy;
if (j < num_mcv)
{
- int first = track[j].first;
+ int first = track[j].first;
if (src >= first)
{
ncopy = first - src;
}
else
- {
ncopy = values_cnt - src;
- }
memmove(&values[dest], &values[src],
ncopy * sizeof(ScalarItem));
src += ncopy;
hist_values = (Datum *) palloc(num_hist * sizeof(Datum));
for (i = 0; i < num_hist; i++)
{
- int pos;
+ int pos;
pos = (i * (nvals - 1)) / (num_hist - 1);
hist_values[i] = datumCopy(values[pos].value,
if (values_cnt > 1)
{
MemoryContext old_context;
- float4 *corrs;
- double corr_xsum,
- corr_x2sum;
+ float4 *corrs;
+ double corr_xsum,
+ corr_x2sum;
/* Must copy the target values into TransactionCommandContext */
old_context = MemoryContextSwitchTo(TransactionCommandContext);
* (values_cnt-1)*values_cnt*(2*values_cnt-1) / 6.
*----------
*/
- corr_xsum = (double) (values_cnt-1) * (double) values_cnt / 2.0;
- corr_x2sum = (double) (values_cnt-1) * (double) values_cnt *
- (double) (2*values_cnt-1) / 6.0;
+ corr_xsum = (double) (values_cnt - 1) * (double) values_cnt / 2.0;
+ corr_x2sum = (double) (values_cnt - 1) * (double) values_cnt *
+ (double) (2 * values_cnt - 1) / 6.0;
+
/* And the correlation coefficient reduces to */
corrs[0] = (values_cnt * corr_xysum - corr_xsum * corr_xsum) /
(values_cnt * corr_x2sum - corr_xsum * corr_xsum);
* qsort comparator for sorting ScalarItems
*
* Aside from sorting the items, we update the datumCmpTupnoLink[] array
- * whenever two ScalarItems are found to contain equal datums. The array
+ * whenever two ScalarItems are found to contain equal datums. The array
* is indexed by tupno; for each ScalarItem, it contains the highest
* tupno that that item's datum has been found to be equal to. This allows
* us to avoid additional comparisons in compute_scalar_stats().
* Statistics are stored in several places: the pg_class row for the
* relation has stats about the whole relation, and there is a
* pg_statistic row for each (non-system) attribute that has ever
- * been analyzed. The pg_class values are updated by VACUUM, not here.
+ * been analyzed. The pg_class values are updated by VACUUM, not here.
*
* pg_statistic rows are just added or updated normally. This means
* that pg_statistic will probably contain some deleted rows at the
FmgrInfo out_function;
HeapTuple stup,
oldtup;
- int i, k, n;
+ int i,
+ k,
+ n;
Datum values[Natts_pg_statistic];
char nulls[Natts_pg_statistic];
char replaces[Natts_pg_statistic];
}
i = 0;
- values[i++] = ObjectIdGetDatum(relid); /* starelid */
- values[i++] = Int16GetDatum(stats->attnum); /* staattnum */
- values[i++] = Float4GetDatum(stats->stanullfrac); /* stanullfrac */
- values[i++] = Int32GetDatum(stats->stawidth); /* stawidth */
- values[i++] = Float4GetDatum(stats->stadistinct); /* stadistinct */
+ values[i++] = ObjectIdGetDatum(relid); /* starelid */
+ values[i++] = Int16GetDatum(stats->attnum); /* staattnum */
+ values[i++] = Float4GetDatum(stats->stanullfrac); /* stanullfrac */
+ values[i++] = Int32GetDatum(stats->stawidth); /* stawidth */
+ values[i++] = Float4GetDatum(stats->stadistinct); /* stadistinct */
for (k = 0; k < STATISTIC_NUM_SLOTS; k++)
{
- values[i++] = Int16GetDatum(stats->stakind[k]); /* stakindN */
+ values[i++] = Int16GetDatum(stats->stakind[k]); /* stakindN */
}
for (k = 0; k < STATISTIC_NUM_SLOTS; k++)
{
- values[i++] = ObjectIdGetDatum(stats->staop[k]); /* staopN */
+ values[i++] = ObjectIdGetDatum(stats->staop[k]); /* staopN */
}
for (k = 0; k < STATISTIC_NUM_SLOTS; k++)
{
- int nnum = stats->numnumbers[k];
+ int nnum = stats->numnumbers[k];
if (nnum > 0)
{
/* XXX knows more than it should about type float4: */
arry = construct_array(numdatums, nnum,
false, sizeof(float4), 'i');
- values[i++] = PointerGetDatum(arry); /* stanumbersN */
+ values[i++] = PointerGetDatum(arry); /* stanumbersN */
}
else
{
}
for (k = 0; k < STATISTIC_NUM_SLOTS; k++)
{
- int ntxt = stats->numvalues[k];
+ int ntxt = stats->numvalues[k];
if (ntxt > 0)
{
* Convert data values to a text string to be inserted
* into the text array.
*/
- Datum stringdatum;
+ Datum stringdatum;
stringdatum =
FunctionCall3(&out_function,
stats->stavalues[k][n],
- ObjectIdGetDatum(stats->attrtype->typelem),
- Int32GetDatum(stats->attr->atttypmod));
+ ObjectIdGetDatum(stats->attrtype->typelem),
+ Int32GetDatum(stats->attr->atttypmod));
txtdatums[n] = DirectFunctionCall1(textin, stringdatum);
pfree(DatumGetPointer(stringdatum));
}
/* XXX knows more than it should about type text: */
arry = construct_array(txtdatums, ntxt,
false, -1, 'i');
- values[i++] = PointerGetDatum(arry); /* stavaluesN */
+ values[i++] = PointerGetDatum(arry); /* stavaluesN */
}
else
{
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.80 2001/09/08 01:10:20 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.81 2001/10/25 05:49:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* True if we've registered an on_shmem_exit cleanup */
static bool unlistenExitRegistered = false;
-bool Trace_notify = false;
+bool Trace_notify = false;
static void Async_UnlistenAll(void);
elog(DEBUG, "Async_Notify: %s", relname);
/* no point in making duplicate entries in the list ... */
- if (! AsyncExistsPendingNotify(relname))
+ if (!AsyncExistsPendingNotify(relname))
{
/*
- * The name list needs to live until end of transaction, so
- * store it in the top transaction context.
+ * The name list needs to live until end of transaction, so store
+ * it in the top transaction context.
*/
- MemoryContext oldcontext;
+ MemoryContext oldcontext;
oldcontext = MemoryContextSwitchTo(TopTransactionContext);
Form_pg_listener listener = (Form_pg_listener) GETSTRUCT(tuple);
if (listener->listenerpid == pid &&
- strncmp(NameStr(listener->relname), relname, NAMEDATALEN) == 0)
+ strncmp(NameStr(listener->relname), relname, NAMEDATALEN) == 0)
{
alreadyListener = true;
/* No need to scan the rest of the table */
Form_pg_listener listener = (Form_pg_listener) GETSTRUCT(tuple);
if (listener->listenerpid == pid &&
- strncmp(NameStr(listener->relname), relname, NAMEDATALEN) == 0)
+ strncmp(NameStr(listener->relname), relname, NAMEDATALEN) == 0)
{
/* Found the matching tuple, delete it */
simple_heap_delete(lRel, &tuple->t_self);
+
/*
- * We assume there can be only one match, so no need
- * to scan the rest of the table
+ * We assume there can be only one match, so no need to scan
+ * the rest of the table
*/
break;
}
char *relname = NameStr(listener->relname);
int32 listenerPID = listener->listenerpid;
- if (! AsyncExistsPendingNotify(relname))
+ if (!AsyncExistsPendingNotify(relname))
continue;
if (listenerPID == MyProcPid)
{
/*
- * Self-notify: no need to bother with table update.
- * Indeed, we *must not* clear the notification field in
- * this path, or we could lose an outside notify, which'd
- * be bad for applications that ignore self-notify messages.
+ * Self-notify: no need to bother with table update. Indeed,
+ * we *must not* clear the notification field in this path, or
+ * we could lose an outside notify, which'd be bad for
+ * applications that ignore self-notify messages.
*/
if (Trace_notify)
/*
* If someone has already notified this listener, we don't
- * bother modifying the table, but we do still send a
- * SIGUSR2 signal, just in case that backend missed the
- * earlier signal for some reason. It's OK to send the
- * signal first, because the other guy can't read
- * pg_listener until we unlock it.
+ * bother modifying the table, but we do still send a SIGUSR2
+ * signal, just in case that backend missed the earlier signal
+ * for some reason. It's OK to send the signal first, because
+ * the other guy can't read pg_listener until we unlock it.
*/
if (kill(listenerPID, SIGUSR2) < 0)
{
/*
- * Get rid of pg_listener entry if it refers to a PID
- * that no longer exists. Presumably, that backend
- * crashed without deleting its pg_listener entries.
- * This code used to only delete the entry if
- * errno==ESRCH, but as far as I can see we should
- * just do it for any failure (certainly at least for
- * EPERM too...)
+ * Get rid of pg_listener entry if it refers to a PID that
+ * no longer exists. Presumably, that backend crashed
+ * without deleting its pg_listener entries. This code
+ * used to only delete the entry if errno==ESRCH, but as
+ * far as I can see we should just do it for any failure
+ * (certainly at least for EPERM too...)
*/
simple_heap_delete(lRel, &lTuple->t_self);
}
if (notifyInterruptEnabled)
{
-
/*
* I'm not sure whether some flavors of Unix might allow another
* SIGUSR2 occurrence to recursively interrupt this routine. To
}
else
{
-
/*
* In this path it is NOT SAFE to do much of anything, except
* this:
ClearPendingNotifies(void)
{
/*
- * We used to have to explicitly deallocate the list members and nodes,
- * because they were malloc'd. Now, since we know they are palloc'd
- * in TopTransactionContext, we need not do that --- they'll go away
- * automatically at transaction exit. We need only reset the list head
- * pointer.
+ * We used to have to explicitly deallocate the list members and
+ * nodes, because they were malloc'd. Now, since we know they are
+ * palloc'd in TopTransactionContext, we need not do that --- they'll
+ * go away automatically at transaction exit. We need only reset the
+ * list head pointer.
*/
pendingNotifies = NIL;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.69 2001/08/21 16:36:01 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.70 2001/10/25 05:49:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
LocalHeapTuple.t_datamcxt = NULL;
LocalHeapTuple.t_data = NULL;
heap_fetch(LocalOldHeap, SnapshotNow, &LocalHeapTuple, &LocalBuffer,
- ScanDesc);
+ ScanDesc);
if (LocalHeapTuple.t_data != NULL)
{
-
/*
* We must copy the tuple because heap_insert() will overwrite
* the commit-status fields of the tuple it's handed, and the
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.145 2001/10/23 17:39:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.146 2001/10/25 05:49:24 momjian Exp $
*
* NOTES
* The PerformAddAttribute() code, like most of the relation
#include "catalog/pg_type.h"
#include "commands/command.h"
#include "commands/trigger.h"
-#include "commands/defrem.h" /* For add constraint unique, primary */
+#include "commands/defrem.h" /* For add constraint unique, primary */
#include "executor/execdefs.h"
#include "executor/executor.h"
#include "miscadmin.h"
#include "parser/parse_expr.h"
#include "parser/parse_oper.h"
#include "parser/parse_relation.h"
-#include "parser/analyze.h" /* For add constraint unique, primary */
+#include "parser/analyze.h" /* For add constraint unique, primary */
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
* destination. This supports MOVE, for example, which will pass in
* dest = None.
*
- * EXCEPTION: if the query's original dest is RemoteInternal (ie, it's
- * a binary cursor) and the request is Remote, we do NOT override the
+ * EXCEPTION: if the query's original dest is RemoteInternal (ie, it's a
+ * binary cursor) and the request is Remote, we do NOT override the
* original dest. This is necessary since a FETCH command will pass
* dest = Remote, not knowing whether the cursor is binary or not.
*/
if (!portal->atEnd)
{
ExecutorRun(queryDesc, estate, EXEC_FOR, (long) count);
+
/*
- * I use CMD_UPDATE, because no CMD_MOVE or the like
- * exists, and I would like to provide the same
- * kind of info as CMD_UPDATE
+ * I use CMD_UPDATE, because no CMD_MOVE or the like exists,
+ * and I would like to provide the same kind of info as
+ * CMD_UPDATE
*/
UpdateCommandInfo(CMD_UPDATE, 0, estate->es_processed);
if (estate->es_processed > 0)
if (!portal->atStart)
{
ExecutorRun(queryDesc, estate, EXEC_BACK, (long) count);
+
/*
- * I use CMD_UPDATE, because no CMD_MOVE or the like
- * exists, and I would like to provide the same
- * kind of info as CMD_UPDATE
+ * I use CMD_UPDATE, because no CMD_MOVE or the like exists,
+ * and I would like to provide the same kind of info as
+ * CMD_UPDATE
*/
UpdateCommandInfo(CMD_UPDATE, 0, estate->es_processed);
if (estate->es_processed > 0)
/*
* find_all_inheritors does the recursive search of the
- * inheritance hierarchy, so all we have to do is process all
- * of the relids in the list that it returns.
+ * inheritance hierarchy, so all we have to do is process all of
+ * the relids in the list that it returns.
*/
foreach(child, children)
{
* Implementation restrictions: because we don't touch the table rows,
* the new column values will initially appear to be NULLs. (This
* happens because the heap tuple access routines always check for
- * attnum > # of attributes in tuple, and return NULL if so.) Therefore
- * we can't support a DEFAULT value in SQL92-compliant fashion, and
- * we also can't allow a NOT NULL constraint.
+ * attnum > # of attributes in tuple, and return NULL if so.)
+ * Therefore we can't support a DEFAULT value in SQL92-compliant
+ * fashion, and we also can't allow a NOT NULL constraint.
*
- * We do allow CHECK constraints, even though these theoretically
- * could fail for NULL rows (eg, CHECK (newcol IS NOT NULL)).
+ * We do allow CHECK constraints, even though these theoretically could
+ * fail for NULL rows (eg, CHECK (newcol IS NOT NULL)).
*/
if (colDef->raw_default || colDef->cooked_default)
elog(ERROR, "Adding columns with defaults is not implemented."
/*
* Add any CHECK constraints attached to the new column.
*
- * To do this we must re-open the rel so that its new attr list
- * gets loaded into the relcache.
+ * To do this we must re-open the rel so that its new attr list gets
+ * loaded into the relcache.
*/
if (colDef->constraints != NIL)
{
return checkok;
}
-
#endif /* _DROP_COLUMN_HACK__ */
/*
heap_freetuple(reltup);
heap_close(rel, NoLock);
#else
- elog(ERROR, "ALTER TABLE / DROP COLUMN is not implemented");
+ elog(ERROR, "ALTER TABLE / DROP COLUMN is not implemented");
#endif /* _DROP_COLUMN_HACK__ */
}
bool inh, List *newConstraints)
{
Relation rel;
- Oid myrelid;
- List *listptr;
+ Oid myrelid;
+ List *listptr;
#ifndef NO_SECURITY
if (!pg_ownercheck(GetUserId(), relationName, RELNAME))
rel = heap_openr(relationName, AccessExclusiveLock);
myrelid = RelationGetRelid(rel);
- if (inh) {
+ if (inh)
+ {
List *child,
*children;
/*
* find_all_inheritors does the recursive search of the
- * inheritance hierarchy, so all we have to do is process all
- * of the relids in the list that it returns.
+ * inheritance hierarchy, so all we have to do is process all of
+ * the relids in the list that it returns.
*/
foreach(child, children)
{
foreach(listptr, newConstraints)
{
- Node *newConstraint = lfirst(listptr);
-
- switch (nodeTag(newConstraint))
- {
- case T_Constraint:
- {
- Constraint *constr = (Constraint *) newConstraint;
+ Node *newConstraint = lfirst(listptr);
- switch (constr->contype)
+ switch (nodeTag(newConstraint))
+ {
+ case T_Constraint:
{
- case CONSTR_CHECK:
- {
- ParseState *pstate;
- bool successful = true;
- HeapScanDesc scan;
- ExprContext *econtext;
- TupleTableSlot *slot;
- HeapTuple tuple;
- RangeTblEntry *rte;
- List *qual;
- Node *expr;
- char *name;
-
- if (constr->name)
- name = constr->name;
- else
- name = "";
-
- /*
- * We need to make a parse state and range
- * table to allow us to transformExpr and
- * fix_opids to get a version of the
- * expression we can pass to ExecQual
- */
- pstate = make_parsestate(NULL);
- rte = addRangeTableEntry(pstate, relationName, NULL,
- false, true);
- addRTEtoQuery(pstate, rte, true, true);
-
- /* Convert the A_EXPR in raw_expr into an EXPR */
- expr = transformExpr(pstate, constr->raw_expr,
- EXPR_COLUMN_FIRST);
-
- /*
- * Make sure it yields a boolean result.
- */
- if (exprType(expr) != BOOLOID)
- elog(ERROR, "CHECK '%s' does not yield boolean result",
- name);
-
- /*
- * Make sure no outside relations are referred
- * to.
- */
- if (length(pstate->p_rtable) != 1)
- elog(ERROR, "Only relation '%s' can be referenced in CHECK",
- relationName);
-
- /*
- * Might as well try to reduce any constant
- * expressions.
- */
- expr = eval_const_expressions(expr);
-
- /* And fix the opids */
- fix_opids(expr);
-
- qual = makeList1(expr);
-
- /* Make tuple slot to hold tuples */
- slot = MakeTupleTableSlot();
- ExecSetSlotDescriptor(slot, RelationGetDescr(rel), false);
- /* Make an expression context for ExecQual */
- econtext = MakeExprContext(slot, CurrentMemoryContext);
-
- /*
- * Scan through the rows now, checking the
- * expression at each row.
- */
- scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL);
-
- while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
+ Constraint *constr = (Constraint *) newConstraint;
+
+ switch (constr->contype)
+ {
+ case CONSTR_CHECK:
{
- ExecStoreTuple(tuple, slot, InvalidBuffer, false);
- if (!ExecQual(qual, econtext, true))
+ ParseState *pstate;
+ bool successful = true;
+ HeapScanDesc scan;
+ ExprContext *econtext;
+ TupleTableSlot *slot;
+ HeapTuple tuple;
+ RangeTblEntry *rte;
+ List *qual;
+ Node *expr;
+ char *name;
+
+ if (constr->name)
+ name = constr->name;
+ else
+ name = "";
+
+ /*
+ * We need to make a parse state and range
+ * table to allow us to transformExpr and
+ * fix_opids to get a version of the
+ * expression we can pass to ExecQual
+ */
+ pstate = make_parsestate(NULL);
+ rte = addRangeTableEntry(pstate, relationName, NULL,
+ false, true);
+ addRTEtoQuery(pstate, rte, true, true);
+
+ /*
+ * Convert the A_EXPR in raw_expr into an
+ * EXPR
+ */
+ expr = transformExpr(pstate, constr->raw_expr,
+ EXPR_COLUMN_FIRST);
+
+ /*
+ * Make sure it yields a boolean result.
+ */
+ if (exprType(expr) != BOOLOID)
+ elog(ERROR, "CHECK '%s' does not yield boolean result",
+ name);
+
+ /*
+ * Make sure no outside relations are
+ * referred to.
+ */
+ if (length(pstate->p_rtable) != 1)
+ elog(ERROR, "Only relation '%s' can be referenced in CHECK",
+ relationName);
+
+ /*
+ * Might as well try to reduce any
+ * constant expressions.
+ */
+ expr = eval_const_expressions(expr);
+
+ /* And fix the opids */
+ fix_opids(expr);
+
+ qual = makeList1(expr);
+
+ /* Make tuple slot to hold tuples */
+ slot = MakeTupleTableSlot();
+ ExecSetSlotDescriptor(slot, RelationGetDescr(rel), false);
+ /* Make an expression context for ExecQual */
+ econtext = MakeExprContext(slot, CurrentMemoryContext);
+
+ /*
+ * Scan through the rows now, checking the
+ * expression at each row.
+ */
+ scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL);
+
+ while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
{
- successful = false;
- break;
+ ExecStoreTuple(tuple, slot, InvalidBuffer, false);
+ if (!ExecQual(qual, econtext, true))
+ {
+ successful = false;
+ break;
+ }
+ ResetExprContext(econtext);
}
- ResetExprContext(econtext);
- }
- heap_endscan(scan);
+ heap_endscan(scan);
- FreeExprContext(econtext);
- pfree(slot);
+ FreeExprContext(econtext);
+ pfree(slot);
- if (!successful)
- elog(ERROR, "AlterTableAddConstraint: rejected due to CHECK constraint %s", name);
+ if (!successful)
+ elog(ERROR, "AlterTableAddConstraint: rejected due to CHECK constraint %s", name);
- /*
- * Call AddRelationRawConstraints to do the
- * real adding -- It duplicates some of the
- * above, but does not check the validity of
- * the constraint against tuples already in
- * the table.
- */
- AddRelationRawConstraints(rel, NIL,
+ /*
+ * Call AddRelationRawConstraints to do
+ * the real adding -- It duplicates some
+ * of the above, but does not check the
+ * validity of the constraint against
+ * tuples already in the table.
+ */
+ AddRelationRawConstraints(rel, NIL,
makeList1(constr));
- break;
- }
- case CONSTR_UNIQUE:
- {
- char *iname = constr->name;
- bool istemp = is_temp_rel_name(relationName);
- List *indexoidlist;
- List *indexoidscan;
- int num_keys;
- bool index_found = false;
- bool index_found_unique = false;
- bool index_found_primary = false;
-
- /* If the constraint name is not specified, generate a name */
- if (iname == NULL) {
- Oid indoid;
- int pass = 0;
- char *typename = palloc(NAMEDATALEN);
- Ident *key;
-
- /* Assume that the length of the attr list is already > 0 */
-
- /* Get the first attribute so we can use its name */
- key = (Ident *)lfirst(constr->keys);
-
- /* Initialise typename to 'key' */
- snprintf(typename, NAMEDATALEN, "key");
-
- for (;;)
- {
- iname = makeObjectName(relationName, key->name, typename);
-
- /* Check for a conflict */
- indoid = RelnameFindRelid(iname);
-
- /* If the oid was not found, then we have a safe name */
- if ((!istemp && !OidIsValid(indoid)) ||
- (istemp && !is_temp_rel_name(iname)))
- break;
-
- /* Found a conflict, so try a new name component */
- pfree(iname);
- snprintf(typename, NAMEDATALEN, "key%d", ++pass);
- }
- }
-
- /* Need to check for unique key already on field(s) */
-
- /*
- * First we check for limited correctness of the
- * constraint
- */
-
- /* Loop over all indices on the relation */
- indexoidlist = RelationGetIndexList(rel);
-
- foreach(indexoidscan, indexoidlist)
- {
- Oid indexoid = lfirsti(indexoidscan);
- HeapTuple indexTuple;
- Form_pg_index indexStruct;
- List *keyl;
- int i;
-
- indexTuple = SearchSysCache(INDEXRELID,
- ObjectIdGetDatum(indexoid),
- 0, 0, 0);
-
- if (!HeapTupleIsValid(indexTuple))
- elog(ERROR, "ALTER TABLE/ADD CONSTRAINT: Index \"%u\" not found",
- indexoid);
- indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
-
- /*
- * Make sure this index has the same number of
- * keys as the constraint -- It obviously won't match otherwise.
- */
- for (i = 0; i < INDEX_MAX_KEYS && indexStruct->indkey[i] != 0; i++)
- ;
- num_keys = length(constr->keys);
-
- if (i == num_keys)
- {
- /* Loop over each key in the constraint and check that there is a
- corresponding key in the index. */
- int keys_matched = 0;
-
- i = 0;
- foreach(keyl, constr->keys)
- {
- Ident *key = lfirst(keyl);
- int keyno = indexStruct->indkey[i];
-
- /* Look at key[i] in the index and check that it is over the same column
- as key[i] in the constraint. This is to differentiate between (a,b)
- and (b,a) */
- if (namestrcmp(attnumAttName(rel, keyno),
- key->name) == 0)
- keys_matched++;
- else
- break;
- i++;
- }
- if (keys_matched == num_keys) {
- index_found = true;
- index_found_unique = indexStruct->indisunique;
- index_found_primary = indexStruct->indisprimary;
- }
- }
- ReleaseSysCache(indexTuple);
- if (index_found_unique || index_found_primary)
- break;
- }
-
- freeList(indexoidlist);
-
- if (index_found_primary)
- elog(ERROR, "Unique primary key already defined on relation \"%s\"", relationName);
- else if (index_found_unique)
- elog(ERROR, "Unique constraint already defined on the specified attributes in relation \"%s\"", relationName);
-
- /* If everything is ok, create the new index (constraint) */
- DefineIndex(
- relationName,
- iname,
- "btree",
- constr->keys,
- true,
- false,
- NULL,
- NIL);
-
- /* Issue notice */
- elog(NOTICE, "ALTER TABLE/ADD UNIQUE will create implicit index '%s' for table '%s'",
- iname, relationName);
- if (index_found)
- elog(NOTICE, "Unique constraint supercedes existing index on relation \"%s\". Drop the existing index to remove redundancy.", relationName);
- pfree(iname);
-
- break;
- }
- default:
- elog(ERROR, "ALTER TABLE / ADD CONSTRAINT is not implemented for that constraint type.");
- }
- break;
- }
- case T_FkConstraint:
- {
- FkConstraint *fkconstraint = (FkConstraint *) newConstraint;
- Relation pkrel;
- HeapScanDesc scan;
- HeapTuple tuple;
- Trigger trig;
- List *list;
- int count;
-
- if (is_temp_rel_name(fkconstraint->pktable_name) &&
- !is_temp_rel_name(relationName))
- elog(ERROR, "ALTER TABLE / ADD CONSTRAINT: Unable to reference temporary table from permanent table constraint.");
-
- /*
- * Grab an exclusive lock on the pk table, so that someone
- * doesn't delete rows out from under us.
- */
-
- pkrel = heap_openr(fkconstraint->pktable_name, AccessExclusiveLock);
- if (pkrel->rd_rel->relkind != RELKIND_RELATION)
- elog(ERROR, "referenced table \"%s\" not a relation",
- fkconstraint->pktable_name);
- heap_close(pkrel, NoLock);
-
- /*
- * First we check for limited correctness of the constraint.
- *
- * NOTE: we assume parser has already checked for existence
- * of an appropriate unique index on the referenced relation,
- * and that the column datatypes are comparable.
- *
- * Scan through each tuple, calling the RI_FKey_Match_Ins
- * (insert trigger) as if that tuple had just been
- * inserted. If any of those fail, it should elog(ERROR)
- * and that's that.
- */
-
- trig.tgoid = 0;
- if (fkconstraint->constr_name)
- trig.tgname = fkconstraint->constr_name;
- else
- trig.tgname = "";
- trig.tgfoid = 0;
- trig.tgtype = 0;
- trig.tgenabled = TRUE;
- trig.tgisconstraint = TRUE;
- trig.tginitdeferred = FALSE;
- trig.tgdeferrable = FALSE;
-
- trig.tgargs = (char **) palloc(
- sizeof(char *) * (4 + length(fkconstraint->fk_attrs)
- + length(fkconstraint->pk_attrs)));
+ break;
+ }
+ case CONSTR_UNIQUE:
+ {
+ char *iname = constr->name;
+ bool istemp = is_temp_rel_name(relationName);
+ List *indexoidlist;
+ List *indexoidscan;
+ int num_keys;
+ bool index_found = false;
+ bool index_found_unique = false;
+ bool index_found_primary = false;
+
+ /*
+ * If the constraint name is not
+ * specified, generate a name
+ */
+ if (iname == NULL)
+ {
+ Oid indoid;
+ int pass = 0;
+ char *typename = palloc(NAMEDATALEN);
+ Ident *key;
+
+ /*
+ * Assume that the length of the attr
+ * list is already > 0
+ */
+
+ /*
+ * Get the first attribute so we can
+ * use its name
+ */
+ key = (Ident *) lfirst(constr->keys);
+
+ /* Initialise typename to 'key' */
+ snprintf(typename, NAMEDATALEN, "key");
+
+ for (;;)
+ {
+ iname = makeObjectName(relationName, key->name, typename);
+
+ /* Check for a conflict */
+ indoid = RelnameFindRelid(iname);
+
+ /*
+ * If the oid was not found, then
+ * we have a safe name
+ */
+ if ((!istemp && !OidIsValid(indoid)) ||
+ (istemp && !is_temp_rel_name(iname)))
+ break;
+
+ /*
+ * Found a conflict, so try a new
+ * name component
+ */
+ pfree(iname);
+ snprintf(typename, NAMEDATALEN, "key%d", ++pass);
+ }
+ }
- if (fkconstraint->constr_name)
- trig.tgargs[0] = fkconstraint->constr_name;
- else
- trig.tgargs[0] = "";
- trig.tgargs[1] = (char *) relationName;
- trig.tgargs[2] = fkconstraint->pktable_name;
- trig.tgargs[3] = fkconstraint->match_type;
- count = 4;
- foreach(list, fkconstraint->fk_attrs)
- {
- Ident *fk_at = lfirst(list);
+ /*
+ * Need to check for unique key already on
+ * field(s)
+ */
- trig.tgargs[count] = fk_at->name;
- count += 2;
- }
- count = 5;
- foreach(list, fkconstraint->pk_attrs)
- {
- Ident *pk_at = lfirst(list);
+ /*
+ * First we check for limited correctness
+ * of the constraint
+ */
- trig.tgargs[count] = pk_at->name;
- count += 2;
- }
- trig.tgnargs = count - 1;
+ /* Loop over all indices on the relation */
+ indexoidlist = RelationGetIndexList(rel);
- scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL);
+ foreach(indexoidscan, indexoidlist)
+ {
+ Oid indexoid = lfirsti(indexoidscan);
+ HeapTuple indexTuple;
+ Form_pg_index indexStruct;
+ List *keyl;
+ int i;
+
+ indexTuple = SearchSysCache(INDEXRELID,
+ ObjectIdGetDatum(indexoid),
+ 0, 0, 0);
+
+ if (!HeapTupleIsValid(indexTuple))
+ elog(ERROR, "ALTER TABLE/ADD CONSTRAINT: Index \"%u\" not found",
+ indexoid);
+ indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
+
+ /*
+ * Make sure this index has the same
+ * number of keys as the constraint --
+ * It obviously won't match otherwise.
+ */
+ for (i = 0; i < INDEX_MAX_KEYS && indexStruct->indkey[i] != 0; i++)
+ ;
+ num_keys = length(constr->keys);
+
+ if (i == num_keys)
+ {
+ /*
+ * Loop over each key in the
+ * constraint and check that there
+ * is a corresponding key in the
+ * index.
+ */
+ int keys_matched = 0;
+
+ i = 0;
+ foreach(keyl, constr->keys)
+ {
+ Ident *key = lfirst(keyl);
+ int keyno = indexStruct->indkey[i];
+
+ /*
+ * Look at key[i] in the index
+ * and check that it is over
+ * the same column as key[i]
+ * in the constraint. This is
+ * to differentiate between
+ * (a,b) and (b,a)
+ */
+ if (namestrcmp(attnumAttName(rel, keyno),
+ key->name) == 0)
+ keys_matched++;
+ else
+ break;
+ i++;
+ }
+ if (keys_matched == num_keys)
+ {
+ index_found = true;
+ index_found_unique = indexStruct->indisunique;
+ index_found_primary = indexStruct->indisprimary;
+ }
+ }
+ ReleaseSysCache(indexTuple);
+ if (index_found_unique || index_found_primary)
+ break;
+ }
- while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
+ freeList(indexoidlist);
+
+ if (index_found_primary)
+ elog(ERROR, "Unique primary key already defined on relation \"%s\"", relationName);
+ else if (index_found_unique)
+ elog(ERROR, "Unique constraint already defined on the specified attributes in relation \"%s\"", relationName);
+
+ /*
+ * If everything is ok, create the new
+ * index (constraint)
+ */
+ DefineIndex(
+ relationName,
+ iname,
+ "btree",
+ constr->keys,
+ true,
+ false,
+ NULL,
+ NIL);
+
+ /* Issue notice */
+ elog(NOTICE, "ALTER TABLE/ADD UNIQUE will create implicit index '%s' for table '%s'",
+ iname, relationName);
+ if (index_found)
+ elog(NOTICE, "Unique constraint supercedes existing index on relation \"%s\". Drop the existing index to remove redundancy.", relationName);
+ pfree(iname);
+
+ break;
+ }
+ default:
+ elog(ERROR, "ALTER TABLE / ADD CONSTRAINT is not implemented for that constraint type.");
+ }
+ break;
+ }
+ case T_FkConstraint:
{
- /* Make a call to the check function */
- /* No parameters are passed, but we do set a context */
- FunctionCallInfoData fcinfo;
- TriggerData trigdata;
-
- MemSet(&fcinfo, 0, sizeof(fcinfo));
- /* We assume RI_FKey_check_ins won't look at flinfo... */
-
- trigdata.type = T_TriggerData;
- trigdata.tg_event = TRIGGER_EVENT_INSERT | TRIGGER_EVENT_ROW;
- trigdata.tg_relation = rel;
- trigdata.tg_trigtuple = tuple;
- trigdata.tg_newtuple = NULL;
- trigdata.tg_trigger = &trig;
-
- fcinfo.context = (Node *) &trigdata;
+ FkConstraint *fkconstraint = (FkConstraint *) newConstraint;
+ Relation pkrel;
+ HeapScanDesc scan;
+ HeapTuple tuple;
+ Trigger trig;
+ List *list;
+ int count;
+
+ if (is_temp_rel_name(fkconstraint->pktable_name) &&
+ !is_temp_rel_name(relationName))
+ elog(ERROR, "ALTER TABLE / ADD CONSTRAINT: Unable to reference temporary table from permanent table constraint.");
+
+ /*
+ * Grab an exclusive lock on the pk table, so that
+ * someone doesn't delete rows out from under us.
+ */
+
+ pkrel = heap_openr(fkconstraint->pktable_name, AccessExclusiveLock);
+ if (pkrel->rd_rel->relkind != RELKIND_RELATION)
+ elog(ERROR, "referenced table \"%s\" not a relation",
+ fkconstraint->pktable_name);
+ heap_close(pkrel, NoLock);
+
+ /*
+ * First we check for limited correctness of the
+ * constraint.
+ *
+ * NOTE: we assume parser has already checked for
+ * existence of an appropriate unique index on the
+ * referenced relation, and that the column datatypes
+ * are comparable.
+ *
+ * Scan through each tuple, calling the RI_FKey_Match_Ins
+ * (insert trigger) as if that tuple had just been
+ * inserted. If any of those fail, it should
+ * elog(ERROR) and that's that.
+ */
+
+ trig.tgoid = 0;
+ if (fkconstraint->constr_name)
+ trig.tgname = fkconstraint->constr_name;
+ else
+ trig.tgname = "";
+ trig.tgfoid = 0;
+ trig.tgtype = 0;
+ trig.tgenabled = TRUE;
+ trig.tgisconstraint = TRUE;
+ trig.tginitdeferred = FALSE;
+ trig.tgdeferrable = FALSE;
+
+ trig.tgargs = (char **) palloc(
+ sizeof(char *) * (4 + length(fkconstraint->fk_attrs)
+ + length(fkconstraint->pk_attrs)));
- RI_FKey_check_ins(&fcinfo);
+ if (fkconstraint->constr_name)
+ trig.tgargs[0] = fkconstraint->constr_name;
+ else
+ trig.tgargs[0] = "";
+ trig.tgargs[1] = (char *) relationName;
+ trig.tgargs[2] = fkconstraint->pktable_name;
+ trig.tgargs[3] = fkconstraint->match_type;
+ count = 4;
+ foreach(list, fkconstraint->fk_attrs)
+ {
+ Ident *fk_at = lfirst(list);
+
+ trig.tgargs[count] = fk_at->name;
+ count += 2;
+ }
+ count = 5;
+ foreach(list, fkconstraint->pk_attrs)
+ {
+ Ident *pk_at = lfirst(list);
+
+ trig.tgargs[count] = pk_at->name;
+ count += 2;
+ }
+ trig.tgnargs = count - 1;
+
+ scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL);
+
+ while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
+ {
+ /* Make a call to the check function */
+
+ /*
+ * No parameters are passed, but we do set a
+ * context
+ */
+ FunctionCallInfoData fcinfo;
+ TriggerData trigdata;
+
+ MemSet(&fcinfo, 0, sizeof(fcinfo));
+
+ /*
+ * We assume RI_FKey_check_ins won't look at
+ * flinfo...
+ */
+
+ trigdata.type = T_TriggerData;
+ trigdata.tg_event = TRIGGER_EVENT_INSERT | TRIGGER_EVENT_ROW;
+ trigdata.tg_relation = rel;
+ trigdata.tg_trigtuple = tuple;
+ trigdata.tg_newtuple = NULL;
+ trigdata.tg_trigger = &trig;
+
+ fcinfo.context = (Node *) &trigdata;
+
+ RI_FKey_check_ins(&fcinfo);
+ }
+ heap_endscan(scan);
+
+ pfree(trig.tgargs);
+ break;
}
- heap_endscan(scan);
-
- pfree(trig.tgargs);
- break;
- }
- default:
- elog(ERROR, "ALTER TABLE / ADD CONSTRAINT unable to determine type of constraint passed");
- }
+ default:
+ elog(ERROR, "ALTER TABLE / ADD CONSTRAINT unable to determine type of constraint passed");
+ }
}
/* Close rel, but keep lock till commit */
bool inh, const char *constrName,
int behavior)
{
- Relation rel;
+ Relation rel;
int deleted;
#ifndef NO_SECURITY
elog(ERROR, "ALTER TABLE: permission denied");
#endif
- /* We don't support CASCADE yet - in fact, RESTRICT
- * doesn't work to the spec either! */
+ /*
+ * We don't support CASCADE yet - in fact, RESTRICT doesn't work to
+ * the spec either!
+ */
if (behavior == CASCADE)
elog(ERROR, "ALTER TABLE / DROP CONSTRAINT does not support the CASCADE keyword");
/*
- * Acquire an exclusive lock on the target relation for
- * the duration of the operation.
+ * Acquire an exclusive lock on the target relation for the duration
+ * of the operation.
*/
rel = heap_openr(relationName, AccessExclusiveLock);
relationName);
/*
- * Since all we have is the name of the constraint, we have to look through
- * all catalogs that could possibly contain a constraint for this relation.
- * We also keep a count of the number of constraints removed.
+ * Since all we have is the name of the constraint, we have to look
+ * through all catalogs that could possibly contain a constraint for
+ * this relation. We also keep a count of the number of constraints
+ * removed.
*/
deleted = 0;
deleted += RemoveCheckConstraint(rel, constrName, inh);
/*
- * Now we remove NULL, UNIQUE, PRIMARY KEY and FOREIGN KEY constraints.
+ * Now we remove NULL, UNIQUE, PRIMARY KEY and FOREIGN KEY
+ * constraints.
*
* Unimplemented.
*/
* Create unique index on chunk_id, chunk_seq.
*
* NOTE: the tuple toaster could actually function with a single-column
- * index on chunk_id only. However, it couldn't be unique then. We
- * want it to be unique as a check against the possibility of duplicate
- * TOAST chunk OIDs. Too, the index might be a little more efficient this
- * way, since btree isn't all that happy with large numbers of equal keys.
+ * index on chunk_id only. However, it couldn't be unique then. We
+ * want it to be unique as a check against the possibility of
+ * duplicate TOAST chunk OIDs. Too, the index might be a little more
+ * efficient this way, since btree isn't all that happy with large
+ * numbers of equal keys.
*/
indexInfo = makeNode(IndexInfo);
true, true);
/*
- * Update toast rel's pg_class entry to show that it has an index.
- * The index OID is stored into the reltoastidxid field for
- * easy access by the tuple toaster.
+ * Update toast rel's pg_class entry to show that it has an index. The
+ * index OID is stored into the reltoastidxid field for easy access by
+ * the tuple toaster.
*/
setRelhasindex(toast_relid, true, true, toast_idxid);
MAXALIGN(data_length);
return (tuple_length > TOAST_TUPLE_THRESHOLD);
}
-
+
/*
*
* LOCK TABLE
void
LockTableCommand(LockStmt *lockstmt)
{
- List *p;
- Relation rel;
-
- /* Iterate over the list and open, lock, and close the relations
- one at a time
+ List *p;
+ Relation rel;
+
+ /*
+ * Iterate over the list and open, lock, and close the relations one
+ * at a time
*/
- foreach(p, lockstmt->rellist)
- {
- char* relname = strVal(lfirst(p));
- int aclresult;
-
- rel = heap_openr(relname, NoLock);
-
- if (rel->rd_rel->relkind != RELKIND_RELATION)
- elog(ERROR, "LOCK TABLE: %s is not a table",
- relname);
-
- if (lockstmt->mode == AccessShareLock)
- aclresult = pg_aclcheck(relname, GetUserId(),
- ACL_SELECT);
- else
- aclresult = pg_aclcheck(relname, GetUserId(),
- ACL_UPDATE | ACL_DELETE);
+ foreach(p, lockstmt->rellist)
+ {
+ char *relname = strVal(lfirst(p));
+ int aclresult;
- if (aclresult != ACLCHECK_OK)
- elog(ERROR, "LOCK TABLE: permission denied");
+ rel = heap_openr(relname, NoLock);
- LockRelation(rel, lockstmt->mode);
-
- heap_close(rel, NoLock); /* close rel, keep lock */
- }
+ if (rel->rd_rel->relkind != RELKIND_RELATION)
+ elog(ERROR, "LOCK TABLE: %s is not a table",
+ relname);
+
+ if (lockstmt->mode == AccessShareLock)
+ aclresult = pg_aclcheck(relname, GetUserId(),
+ ACL_SELECT);
+ else
+ aclresult = pg_aclcheck(relname, GetUserId(),
+ ACL_UPDATE | ACL_DELETE);
+
+ if (aclresult != ACLCHECK_OK)
+ elog(ERROR, "LOCK TABLE: permission denied");
+
+ LockRelation(rel, lockstmt->mode);
+
+ heap_close(rel, NoLock); /* close rel, keep lock */
+ }
}
* Copyright (c) 1999-2001, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.33 2001/10/03 20:54:20 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.34 2001/10/25 05:49:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
elog(ERROR, "you are not permitted to comment on class '%s'", relname);
/*
- * Open the relation. We do this mainly to acquire a lock that ensures
- * no one else drops the relation before we commit. (If they did, they'd
- * fail to remove the entry we are about to make in pg_description.)
+ * Open the relation. We do this mainly to acquire a lock that
+ * ensures no one else drops the relation before we commit. (If they
+ * did, they'd fail to remove the entry we are about to make in
+ * pg_description.)
*
* heap_openr will complain if it's an index, so we must do this:
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.141 2001/08/10 18:57:34 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.142 2001/10/25 05:49:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifdef MULTIBYTE
static int client_encoding;
static int server_encoding;
-
#endif
{
if (pickup)
{
-
/*
* We want to pick it up - just receive again into dummy
* buffer
* ( = TRUE means we are inserting into the table.)
*
* If
is false, transfer is between the table and the file named
- * . Otherwise, transfer is between the table and our regular
- * input/output stream. The latter could be either stdin/stdout or a
+ * . Otherwise, transfer is between the table and our regular
+ * input/output stream. The latter could be either stdin/stdout or a
* socket, depending on whether we're running under Postmaster control.
*
* Iff , unload or reload in the binary format, as opposed to the
* NULL values as .
*
* When loading in the text format from an input stream (as opposed to
- * a file), recognize a "." on a line by itself as EOF. Also recognize
+ * a file), recognize a "." on a line by itself as EOF. Also recognize
* a stream EOF. When unloading in the text format to an output stream,
* write a "." on a line by itself at the end of the data.
*
}
else
{
-
/*
* If we have a toasted datum, forcibly detoast it to
* avoid memory leakage inside the type's output routine
char *string_start;
int mblen;
int i;
-
#endif
#ifdef MULTIBYTE
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.80 2001/08/16 20:38:53 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.81 2001/10/25 05:49:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
List **supOids, List **supconstr, bool *supHasOids);
static bool change_varattnos_of_a_node(Node *node, const AttrNumber *newattno);
static void StoreCatalogInheritance(Oid relationId, List *supers);
-static int findAttrByName(const char *attributeName, List *schema);
+static int findAttrByName(const char *attributeName, List *schema);
static void setRelhassubclassInRelation(Oid relationId, bool relhassubclass);
* including inherited attributes.
*/
schema = MergeAttributes(schema, stmt->inhRelnames, stmt->istemp,
- &inheritOids, &old_constraints, &parentHasOids);
+ &inheritOids, &old_constraints, &parentHasOids);
numberOfAttributes = length(schema);
if (numberOfAttributes <= 0)
List *constraints = NIL;
bool parentHasOids = false;
bool have_bogus_defaults = false;
- char *bogus_marker = "Bogus!"; /* marks conflicting defaults */
+ char *bogus_marker = "Bogus!"; /* marks conflicting
+ * defaults */
int child_attno;
/*
coldef->colname);
}
}
+
/*
* Reject duplicate names in the list of parents, too.
*/
/*
* Scan the parents left-to-right, and merge their attributes to form
- * a list of inherited attributes (inhSchema). Also check to see if
+ * a list of inherited attributes (inhSchema). Also check to see if
* we need to inherit an OID column.
*/
child_attno = 0;
* the attributes of this parent table. (They are not the same
* for parents after the first one.)
*/
- newattno = (AttrNumber *) palloc(tupleDesc->natts*sizeof(AttrNumber));
+ newattno = (AttrNumber *) palloc(tupleDesc->natts * sizeof(AttrNumber));
for (parent_attno = 1; parent_attno <= tupleDesc->natts;
parent_attno++)
if (exist_attno > 0)
{
/*
- * Yes, try to merge the two column definitions.
- * They must have the same type and typmod.
+ * Yes, try to merge the two column definitions. They must
+ * have the same type and typmod.
*/
elog(NOTICE, "CREATE TABLE: merging multiple inherited definitions of attribute \"%s\"",
attributeName);
if (strcmp(def->typename->name, attributeType) != 0 ||
def->typename->typmod != attribute->atttypmod)
elog(ERROR, "CREATE TABLE: inherited attribute \"%s\" type conflict (%s and %s)",
- attributeName, def->typename->name, attributeType);
+ attributeName, def->typename->name, attributeType);
/* Merge of NOT NULL constraints = OR 'em together */
def->is_not_null |= attribute->attnotnull;
/* Default and other constraints are handled below */
inhSchema = lappend(inhSchema, def);
newattno[parent_attno - 1] = ++child_attno;
}
+
/*
* Copy default if any
*/
}
}
Assert(this_default != NULL);
+
/*
- * If default expr could contain any vars, we'd need to fix
- * 'em, but it can't; so default is ready to apply to child.
+ * If default expr could contain any vars, we'd need to
+ * fix 'em, but it can't; so default is ready to apply to
+ * child.
*
- * If we already had a default from some prior parent,
- * check to see if they are the same. If so, no problem;
- * if not, mark the column as having a bogus default.
- * Below, we will complain if the bogus default isn't
- * overridden by the child schema.
+ * If we already had a default from some prior parent, check
+ * to see if they are the same. If so, no problem; if
+ * not, mark the column as having a bogus default. Below,
+ * we will complain if the bogus default isn't overridden
+ * by the child schema.
*/
Assert(def->raw_default == NULL);
if (def->cooked_default == NULL)
}
}
}
+
/*
* Now copy the constraints of this parent, adjusting attnos using
* the completed newattno[] map
ColumnDef *def;
/*
- * Yes, try to merge the two column definitions.
- * They must have the same type and typmod.
+ * Yes, try to merge the two column definitions. They must
+ * have the same type and typmod.
*/
elog(NOTICE, "CREATE TABLE: merging attribute \"%s\" with inherited definition",
attributeName);
if (strcmp(def->typename->name, attributeType) != 0 ||
def->typename->typmod != newdef->typename->typmod)
elog(ERROR, "CREATE TABLE: attribute \"%s\" type conflict (%s and %s)",
- attributeName, def->typename->name, attributeType);
+ attributeName, def->typename->name, attributeType);
/* Merge of NOT NULL constraints = OR 'em together */
def->is_not_null |= newdef->is_not_null;
/* If new def has a default, override previous default */
if (var->varlevelsup == 0 && var->varno == 1 &&
var->varattno > 0)
{
-
/*
* ??? the following may be a problem when the node is
* multiply referenced though stringToNode() doesn't create
}
if (found)
{
-
/*
* found a later duplicate, so remove this entry.
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.80 2001/09/06 04:57:28 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.81 2001/10/25 05:49:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "utils/syscache.h"
#ifdef MULTIBYTE
-#include "mb/pg_wchar.h" /* encoding check */
+#include "mb/pg_wchar.h" /* encoding check */
#endif
#ifdef MULTIBYTE
/* Some encodings are client only */
- if (!PG_VALID_BE_ENCODING( encoding ))
+ if (!PG_VALID_BE_ENCODING(encoding))
elog(ERROR, "CREATE DATABASE: invalid backend encoding");
#else
Assert(encoding == 0); /* zero is PG_SQL_ASCII */
#endif
+
/*
* Preassign OID for pg_database tuple, so that we can compute db
* path.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.62 2001/10/13 01:35:25 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.63 2001/10/25 05:49:25 momjian Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
case_translate_language_name(const char *input, char *output)
{
/*
- * Translate the input language name to lower case, except if it's "C",
+ * Translate the input language name to lower case, except if it's "C",
* translate to upper case.
*/
int i;
char **prorettype_p, bool *returnsSet_p)
{
/*
- * Examine the "returns" clause returnType of the CREATE FUNCTION statement
- * and return information about it as *prorettype_p and *returnsSet.
+ * Examine the "returns" clause returnType of the CREATE FUNCTION statement
+ * and return information about it as *prorettype_p and *returnsSet.
*/
*prorettype_p = TypeNameToInternalName(returnType);
*returnsSet_p = returnType->setof;
bool *canCache_p, bool *isStrict_p)
{
/*-------------
- * Interpret the parameters *parameters and return their contents as
- * *byte_pct_p, etc.
+ * Interpret the parameters *parameters and return their contents as
+ * *byte_pct_p, etc.
*
- * These parameters supply optional information about a function.
- * All have defaults if not specified.
+ * These parameters supply optional information about a function.
+ * All have defaults if not specified.
*
- * Note: currently, only two of these parameters actually do anything:
+ * Note: currently, only two of these parameters actually do anything:
*
- * * canCache means the optimizer's constant-folder is allowed to
- * pre-evaluate the function when all its inputs are constants.
+ * * canCache means the optimizer's constant-folder is allowed to
+ * pre-evaluate the function when all its inputs are constants.
*
- * * isStrict means the function should not be called when any NULL
- * inputs are present; instead a NULL result value should be assumed.
+ * * isStrict means the function should not be called when any NULL
+ * inputs are present; instead a NULL result value should be assumed.
*
- * The other four parameters are not used anywhere. They used to be
- * used in the "expensive functions" optimizer, but that's been dead code
- * for a long time.
+ * The other four parameters are not used anywhere. They used to be
+ * used in the "expensive functions" optimizer, but that's been dead code
+ * for a long time.
*
- * Since canCache and isStrict are useful for any function, we now allow
- * attributes to be supplied for all functions regardless of language.
+ * Since canCache and isStrict are useful for any function, we now allow
+ * attributes to be supplied for all functions regardless of language.
*------------
*/
List *pl;
*isStrict_p = true;
else if (strcasecmp(param->defname, "trusted") == 0)
{
-
/*
* we don't have untrusted functions any more. The 4.2
* implementation is lousy anyway so I took it out. -ay 10/94
if (strcmp(languageName, "C") == 0)
{
-
/*
* For "C" language, store the file name in probin and, when
* given, the link symbol name in prosrc.
List *parameters)
{
uint16 precedence = 0; /* operator precedence */
- bool canHash = false;/* operator hashes */
+ bool canHash = false; /* operator hashes */
bool isLeftAssociative = true; /* operator is left
* associative */
char *functionName = NULL; /* function for operator */
char *negatorName = NULL; /* optional negator operator name */
char *restrictionName = NULL; /* optional restrict. sel.
* procedure */
- char *joinName = NULL;/* optional join sel. procedure name */
+ char *joinName = NULL; /* optional join sel. procedure name */
char *sortName1 = NULL; /* optional first sort operator */
char *sortName2 = NULL; /* optional second sort operator */
List *pl;
void
DefineType(char *typeName, List *parameters)
{
- int16 internalLength = -1; /* int2 */
- int16 externalLength = -1; /* int2 */
+ int16 internalLength = -1; /* int2 */
+ int16 externalLength = -1; /* int2 */
char *elemName = NULL;
char *inputName = NULL;
char *outputName = NULL;
char delimiter = DEFAULT_TYPDELIM;
char *shadow_type;
List *pl;
- char alignment = 'i'; /* default alignment */
+ char alignment = 'i'; /* default alignment */
char storage = 'p'; /* default TOAST storage method */
/*
char *a = defGetString(defel);
/*
- * Note: if argument was an unquoted identifier, parser will have
- * applied xlateSqlType() to it, so be prepared to recognize
- * translated type names as well as the nominal form.
+ * Note: if argument was an unquoted identifier, parser will
+ * have applied xlateSqlType() to it, so be prepared to
+ * recognize translated type names as well as the nominal
+ * form.
*/
if (strcasecmp(a, "double") == 0)
alignment = 'd';
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994-5, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.66 2001/09/18 01:59:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.67 2001/10/25 05:49:25 momjian Exp $
*
*/
struct timeval endtime;
/*
- * Set up the instrumentation for the top node.
- * This will cascade during plan initialisation
+ * Set up the instrumentation for the top node. This will cascade
+ * during plan initialisation
*/
plan->instrument = InstrAlloc();
CommandCounterIncrement();
gettimeofday(&endtime, NULL);
- endtime.tv_sec -= starttime.tv_sec;
+ endtime.tv_sec -= starttime.tv_sec;
endtime.tv_usec -= starttime.tv_usec;
while (endtime.tv_usec < 0)
{
plan->startup_cost, plan->total_cost,
plan->plan_rows, plan->plan_width);
- if ( plan->instrument && plan->instrument->nloops > 0 )
+ if (plan->instrument && plan->instrument->nloops > 0)
{
- double nloops = plan->instrument->nloops;
+ double nloops = plan->instrument->nloops;
appendStringInfo(str, " (actual time=%.2f..%.2f rows=%.0f loops=%.0f)",
1000.0 * plan->instrument->startup / nloops,
static StringInfo
Explain_PlanToString(Plan *plan, ExplainState *es)
{
- StringInfo str = makeStringInfo();
+ StringInfo str = makeStringInfo();
if (plan != NULL)
explain_outNode(str, plan, 0, es);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.59 2001/10/24 09:28:31 inoue Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.60 2001/10/25 05:49:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
char *accessMethodName, Oid accessMethodId);
static Oid GetAttrOpClass(IndexElem *attribute, Oid attrType,
char *accessMethodName, Oid accessMethodId);
-static Oid GetDefaultOpClass(Oid attrType, Oid accessMethodId);
+static Oid GetDefaultOpClass(Oid attrType, Oid accessMethodId);
/*
* DefineIndex
heapRelationName);
/*
- * look up the access method, verify it can handle the requested features
+ * look up the access method, verify it can handle the requested
+ * features
*/
tuple = SearchSysCache(AMNAME,
PointerGetDatum(accessMethodName),
accessMethodId = tuple->t_data->t_oid;
accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
- if (unique && ! accessMethodForm->amcanunique)
+ if (unique && !accessMethodForm->amcanunique)
elog(ERROR, "DefineIndex: access method \"%s\" does not support UNIQUE indexes",
accessMethodName);
- if (numberOfAttributes > 1 && ! accessMethodForm->amcanmulticol)
+ if (numberOfAttributes > 1 && !accessMethodForm->amcanmulticol)
elog(ERROR, "DefineIndex: access method \"%s\" does not support multi-column indexes",
accessMethodName);
ReleaseSysCache(tuple);
/*
- * Convert the partial-index predicate from parsetree form to
- * an implicit-AND qual expression, for easier evaluation at runtime.
+ * Convert the partial-index predicate from parsetree form to an
+ * implicit-AND qual expression, for easier evaluation at runtime.
* While we are at it, we reduce it to a canonical (CNF or DNF) form
* to simplify the task of proving implications.
*/
* (via the given range table) only to the given base relation oid.
*
* This used to also constrain the form of the predicate to forms that
- * indxpath.c could do something with. However, that seems overly
+ * indxpath.c could do something with. However, that seems overly
* restrictive. One useful application of partial indexes is to apply
* a UNIQUE constraint across a subset of a table, and in that scenario
* any evaluatable predicate will work. So accept any predicate here
{
if (length(rangeTable) != 1 || getrelid(1, rangeTable) != baseRelOid)
elog(ERROR,
- "Partial-index predicates may refer only to the base relation");
+ "Partial-index predicates may refer only to the base relation");
/*
* We don't currently support generation of an actual query plan for a
- * predicate, only simple scalar expressions; hence these restrictions.
+ * predicate, only simple scalar expressions; hence these
+ * restrictions.
*/
if (contain_subplans((Node *) predList))
elog(ERROR, "Cannot use subselect in index predicate");
List *arglist;
int nargs = 0;
int i;
- FuncDetailCode fdresult;
+ FuncDetailCode fdresult;
Oid funcid;
Oid rettype;
bool retset;
/*
* Require that the function be marked cachable. Using a noncachable
- * function for a functional index is highly questionable, since if you
- * aren't going to get the same result for the same data every time,
- * it's not clear what the index entries mean at all.
+ * function for a functional index is highly questionable, since if
+ * you aren't going to get the same result for the same data every
+ * time, it's not clear what the index entries mean at all.
*/
if (!func_iscachable(funcid))
elog(ERROR, "DefineIndex: index function must be marked iscachable");
* (either exactly or binary-compatibly, but prefer an exact match).
*
* We could find more than one binary-compatible match, in which case we
- * require the user to specify which one he wants. If we find more than
- * one exact match, then someone put bogus entries in pg_opclass.
+ * require the user to specify which one he wants. If we find more
+ * than one exact match, then someone put bogus entries in pg_opclass.
*
- * We could use an indexscan here, but since pg_opclass is small
- * and a scan on opcamid won't be very selective, the indexscan would
+ * We could use an indexscan here, but since pg_opclass is small and a
+ * scan on opcamid won't be very selective, the indexscan would
* probably actually be slower than heapscan.
*/
ScanKeyEntryInitialize(&entry[0], 0x0,
if (strcmp(dbname, DatabaseName) != 0)
elog(ERROR, "REINDEX DATABASE: Can be executed only on the currently open database.");
- if (! (superuser() || is_dbadmin(MyDatabaseId)))
+ if (!(superuser() || is_dbadmin(MyDatabaseId)))
elog(ERROR, "REINDEX DATABASE: Permission denied.");
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.63 2001/10/03 20:54:20 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.64 2001/10/25 05:49:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
heap_close(rel, RowExclusiveLock);
}
-
#endif /* NOTYET */
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.58 2001/10/08 18:40:04 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.59 2001/10/25 05:49:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
heap_freetuple(atttup);
/*
- * Update column names of indexes that refer to the column being renamed.
+ * Update column names of indexes that refer to the column being
+ * renamed.
*/
indexoidlist = RelationGetIndexList(targetrelation);
HeapTuple indextup;
/*
- * First check to see if index is a functional index.
- * If so, its column name is a function name and shouldn't
- * be renamed here.
+ * First check to see if index is a functional index. If so, its
+ * column name is a function name and shouldn't be renamed here.
*/
indextup = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(indexoid),
continue;
}
ReleaseSysCache(indextup);
+
/*
- * Okay, look to see if any column name of the index matches
- * the old attribute name.
+ * Okay, look to see if any column name of the index matches the
+ * old attribute name.
*/
atttup = SearchSysCacheCopy(ATTNAME,
ObjectIdGetDatum(indexoid),
/*
* Update the (copied) attribute tuple.
*/
- StrNCpy(NameStr(((Form_pg_attribute) GETSTRUCT(atttup))->attname),
- newattname, NAMEDATALEN);
+ StrNCpy(NameStr(((Form_pg_attribute) GETSTRUCT(atttup))->attname),
+ newattname, NAMEDATALEN);
- simple_heap_update(attrelation, &atttup->t_self, atttup);
+ simple_heap_update(attrelation, &atttup->t_self, atttup);
/* keep system catalog indices current */
- {
- Relation irelations[Num_pg_attr_indices];
-
- CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
- CatalogIndexInsert(irelations, Num_pg_attr_indices, attrelation, atttup);
- CatalogCloseIndices(Num_pg_attr_indices, irelations);
- }
- heap_freetuple(atttup);
+ {
+ Relation irelations[Num_pg_attr_indices];
+
+ CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
+ CatalogIndexInsert(irelations, Num_pg_attr_indices, attrelation, atttup);
+ CatalogCloseIndices(Num_pg_attr_indices, irelations);
+ }
+ heap_freetuple(atttup);
}
freeList(indexoidlist);
*/
if (relkind == RELKIND_VIEW)
{
- char *oldrulename,
- *newrulename;
+ char *oldrulename,
+ *newrulename;
oldrulename = MakeRetrieveViewRuleName(oldrelname);
newrulename = MakeRetrieveViewRuleName(newrelname);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.64 2001/09/19 09:48:42 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.65 2001/10/25 05:49:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#else
#define SEQ_MAXVALUE ((int64) 0x7FFFFFFFFFFFFFFF)
#endif
-#else /* INT64_IS_BUSTED */
+#else /* INT64_IS_BUSTED */
#define SEQ_MAXVALUE ((int64) 0x7FFFFFFF)
-#endif /* INT64_IS_BUSTED */
+#endif /* INT64_IS_BUSTED */
#define SEQ_MINVALUE (-SEQ_MAXVALUE)
heap_insert(rel, tuple);
/*
- * After crash REDO of heap_insert above would re-init page and
- * our magic number would be lost. We have to log sequence creation.
- * This means two log records instead of one -:(
+ * After crash REDO of heap_insert above would re-init page and our
+ * magic number would be lost. We have to log sequence creation. This
+ * means two log records instead of one -:(
*/
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
START_CRIT_SECTION();
{
- xl_seq_rec xlrec;
- XLogRecPtr recptr;
- XLogRecData rdata[2];
- Form_pg_sequence newseq = (Form_pg_sequence) GETSTRUCT(tuple);
+ xl_seq_rec xlrec;
+ XLogRecPtr recptr;
+ XLogRecData rdata[2];
+ Form_pg_sequence newseq = (Form_pg_sequence) GETSTRUCT(tuple);
/* We do not log first nextval call, so "advance" sequence here */
newseq->is_called = true;
if (strlen(seqname) >= NAMEDATALEN)
{
#ifdef MULTIBYTE
- int len;
+ int len;
- len = pg_mbcliplen(seqname, rawlen, NAMEDATALEN-1);
+ len = pg_mbcliplen(seqname, rawlen, NAMEDATALEN - 1);
seqname[len] = '\0';
#else
- seqname[NAMEDATALEN-1] = '\0';
+ seqname[NAMEDATALEN - 1] = '\0';
#endif
}
if (elm != (SeqTable) NULL)
{
-
/*
* We are using a seqtable entry left over from a previous xact;
* must check for relid change.
}
else
{
-
/*
* Time to make a new seqtable entry. These entries live as long
* as the backend does, so we use plain malloc for them.
for (elm = seqtab; elm != (SeqTable) NULL; elm = elm->next)
{
rel = elm->rel;
- if (rel != (Relation) NULL) /* opened in current xact */
+ if (rel != (Relation) NULL) /* opened in current xact */
{
elm->rel = (Relation) NULL;
heap_close(rel, AccessShareLock);
{
DefElem *defel = (DefElem *) lfirst(option);
- if (strcmp(defel->defname, "increment")==0)
+ if (strcmp(defel->defname, "increment") == 0)
increment_by = defel;
- else if (strcmp(defel->defname, "start")==0)
+ else if (strcmp(defel->defname, "start") == 0)
last_value = defel;
- else if (strcmp(defel->defname, "maxvalue")==0)
+ else if (strcmp(defel->defname, "maxvalue") == 0)
max_value = defel;
- else if (strcmp(defel->defname, "minvalue")==0)
+ else if (strcmp(defel->defname, "minvalue") == 0)
min_value = defel;
- else if (strcmp(defel->defname, "cache")==0)
+ else if (strcmp(defel->defname, "cache") == 0)
cache_value = defel;
- else if (strcmp(defel->defname, "cycle")==0)
+ else if (strcmp(defel->defname, "cycle") == 0)
{
if (defel->arg != (Node *) NULL)
elog(ERROR, "DefineSequence: CYCLE ??");
if (new->increment_by > 0)
new->max_value = SEQ_MAXVALUE; /* ascending seq */
else
- new->max_value = -1; /* descending seq */
+ new->max_value = -1; /* descending seq */
}
else
new->max_value = get_param(max_value);
return (int64) intVal(def->arg);
/*
- * Values too large for int4 will be represented as Float constants
- * by the lexer. Accept these if they are valid int8 strings.
+ * Values too large for int4 will be represented as Float constants by
+ * the lexer. Accept these if they are valid int8 strings.
*/
if (IsA(def->arg, Float))
return DatumGetInt64(DirectFunctionCall1(int8in,
- CStringGetDatum(strVal(def->arg))));
+ CStringGetDatum(strVal(def->arg))));
/* Shouldn't get here unless parser messed up */
elog(ERROR, "DefineSequence: \"%s\" value must be integer", def->defname);
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.96 2001/08/23 23:06:37 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.97 2001/10/25 05:49:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static void InsertTrigger(TriggerDesc *trigdesc, Trigger *trigger, int indx);
static HeapTuple GetTupleForTrigger(EState *estate,
- ResultRelInfo *relinfo,
- ItemPointer tid,
- TupleTableSlot **newSlot);
+ ResultRelInfo *relinfo,
+ ItemPointer tid,
+ TupleTableSlot **newSlot);
static HeapTuple ExecCallTriggerFunc(TriggerData *trigdata,
- FmgrInfo *finfo,
- MemoryContext per_tuple_context);
+ FmgrInfo *finfo,
+ MemoryContext per_tuple_context);
static void DeferredTriggerSaveEvent(ResultRelInfo *relinfo, int event,
- HeapTuple oldtup, HeapTuple newtup);
+ HeapTuple oldtup, HeapTuple newtup);
static void DeferredTriggerExecute(DeferredTriggerEvent event, int itemno,
- Relation rel, FmgrInfo *finfo,
- MemoryContext per_tuple_context);
+ Relation rel, FmgrInfo *finfo,
+ MemoryContext per_tuple_context);
void
constrrelid = InvalidOid;
else
{
-
/*
* NoLock is probably sufficient here, since we're only
* interested in getting the relation's OID...
MemoryContext oldContext;
/*
- * We cache fmgr lookup info, to avoid making the lookup
- * again on each call.
+ * We cache fmgr lookup info, to avoid making the lookup again on each
+ * call.
*/
if (finfo->fn_oid == InvalidOid)
fmgr_info(trigdata->tg_trigger->tgfoid, finfo);
LocTriggerData.tg_newtuple = NULL;
for (i = 0; i < ntrigs; i++)
{
- Trigger *trigger = &trigdesc->triggers[tgindx[i]];
+ Trigger *trigger = &trigdesc->triggers[tgindx[i]];
if (!trigger->tgenabled)
continue;
LocTriggerData.tg_trigtuple = oldtuple = newtuple;
LocTriggerData.tg_trigger = trigger;
newtuple = ExecCallTriggerFunc(&LocTriggerData,
- relinfo->ri_TrigFunctions + tgindx[i],
+ relinfo->ri_TrigFunctions + tgindx[i],
GetPerTupleMemoryContext(estate));
if (oldtuple != newtuple && oldtuple != trigtuple)
heap_freetuple(oldtuple);
LocTriggerData.tg_newtuple = NULL;
for (i = 0; i < ntrigs; i++)
{
- Trigger *trigger = &trigdesc->triggers[tgindx[i]];
+ Trigger *trigger = &trigdesc->triggers[tgindx[i]];
if (!trigger->tgenabled)
continue;
LocTriggerData.tg_trigtuple = trigtuple;
LocTriggerData.tg_trigger = trigger;
newtuple = ExecCallTriggerFunc(&LocTriggerData,
- relinfo->ri_TrigFunctions + tgindx[i],
+ relinfo->ri_TrigFunctions + tgindx[i],
GetPerTupleMemoryContext(estate));
if (newtuple == NULL)
break;
LocTriggerData.tg_relation = relinfo->ri_RelationDesc;
for (i = 0; i < ntrigs; i++)
{
- Trigger *trigger = &trigdesc->triggers[tgindx[i]];
+ Trigger *trigger = &trigdesc->triggers[tgindx[i]];
if (!trigger->tgenabled)
continue;
LocTriggerData.tg_newtuple = oldtuple = newtuple;
LocTriggerData.tg_trigger = trigger;
newtuple = ExecCallTriggerFunc(&LocTriggerData,
- relinfo->ri_TrigFunctions + tgindx[i],
+ relinfo->ri_TrigFunctions + tgindx[i],
GetPerTupleMemoryContext(estate));
if (oldtuple != newtuple && oldtuple != intuple)
heap_freetuple(oldtuple);
else if (!(ItemPointerEquals(&(tuple.t_self), tid)))
{
TupleTableSlot *epqslot = EvalPlanQual(estate,
- relinfo->ri_RangeTableIndex,
- &(tuple.t_self));
+ relinfo->ri_RangeTableIndex,
+ &(tuple.t_self));
if (!(TupIsNull(epqslot)))
{
static void
deferredTriggerAddEvent(DeferredTriggerEvent event)
{
-
/*
* Since the event list could grow quite long, we keep track of the
* list tail and append there, rather than just doing a stupid
* single trigger function.
*
* Frequently, this will be fired many times in a row for triggers of
- * a single relation. Therefore, we cache the open relation and provide
+ * a single relation. Therefore, we cache the open relation and provide
* fmgr lookup cache space at the caller level.
*
* event: event currently being fired.
}
/*
- * So let's fire it... but first, open the correct relation
- * if this is not the same relation as before.
+ * So let's fire it... but first, open the correct relation if
+ * this is not the same relation as before.
*/
if (rel == NULL || rel->rd_id != event->dte_relid)
{
heap_close(rel, NoLock);
if (finfo)
pfree(finfo);
+
/*
* We assume that an appropriate lock is still held by the
* executor, so grab no new lock here.
*/
rel = heap_open(event->dte_relid, NoLock);
+
/*
* Allocate space to cache fmgr lookup info for triggers
* of this relation.
void
DeferredTriggerEndQuery(void)
{
-
/*
* Ignore call if we aren't in a transaction.
*/
void
DeferredTriggerEndXact(void)
{
-
/*
* Ignore call if we aren't in a transaction.
*/
void
DeferredTriggerAbortXact(void)
{
-
/*
* Ignore call if we aren't in a transaction.
*/
{
if (!IsTransactionBlock())
{
-
/*
* ... outside of a transaction block
*
}
else
{
-
/*
* ... inside of a transaction block
*
new_event->dte_n_items = ntriggers;
for (i = 0; i < ntriggers; i++)
{
- Trigger *trigger = &trigdesc->triggers[tgindx[i]];
+ Trigger *trigger = &trigdesc->triggers[tgindx[i]];
new_event->dte_item[i].dti_tgoid = trigger->tgoid;
new_event->dte_item[i].dti_state =
*/
for (i = 0; i < ntriggers; i++)
{
- Trigger *trigger = &trigdesc->triggers[tgindx[i]];
+ Trigger *trigger = &trigdesc->triggers[tgindx[i]];
bool is_ri_trigger;
bool key_unchanged;
if (key_unchanged)
{
-
/*
* The key hasn't changed, so no need later to invoke
* the trigger at all. But remember other states from
if (prev_event->dte_event &
TRIGGER_DEFERRED_ROW_INSERTED)
{
-
/*
* This is a row inserted during our
* transaction. So any key value is considered
}
else
{
-
/*
* This is a row, previously updated. So if
* this key has been changed before, we still
}
else
{
-
/*
* Bomb out if this key has been changed before.
* Otherwise remember that we do so.
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.84 2001/09/19 09:48:42 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.85 2001/10/25 05:49:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
/*
* ExclusiveLock ensures no one modifies pg_shadow while we read it,
- * and that only one backend rewrites the flat file at a time. It's
+ * and that only one backend rewrites the flat file at a time. It's
* OK to allow normal reads of pg_shadow in parallel, however.
*/
Relation rel = heap_openr(ShadowRelationName, ExclusiveLock);
sysid_exists = false,
havesysid = false;
int max_id;
- List *item, *option;
- char *password = NULL; /* PostgreSQL user password */
- bool encrypt_password = Password_encryption; /* encrypt password? */
- char encrypted_password[MD5_PASSWD_LEN+1];
- int sysid = 0; /* PgSQL system id (valid if havesysid) */
- bool createdb = false; /* Can the user create databases? */
- bool createuser = false; /* Can this user create users? */
- List *groupElts = NIL; /* The groups the user is a member of */
- char *validUntil = NULL; /* The time the login is valid until */
+ List *item,
+ *option;
+ char *password = NULL; /* PostgreSQL user password */
+ bool encrypt_password = Password_encryption; /* encrypt password? */
+ char encrypted_password[MD5_PASSWD_LEN + 1];
+ int sysid = 0; /* PgSQL system id (valid if havesysid) */
+ bool createdb = false; /* Can the user create databases? */
+ bool createuser = false; /* Can this user create users? */
+ List *groupElts = NIL; /* The groups the user is a member of */
+ char *validUntil = NULL; /* The time the login is valid
+ * until */
DefElem *dpassword = NULL;
DefElem *dsysid = NULL;
DefElem *dcreatedb = NULL;
/* Extract options from the statement node tree */
foreach(option, stmt->options)
{
- DefElem *defel = (DefElem *) lfirst(option);
+ DefElem *defel = (DefElem *) lfirst(option);
if (strcmp(defel->defname, "password") == 0 ||
strcmp(defel->defname, "encryptedPassword") == 0 ||
- strcmp(defel->defname, "unencryptedPassword") == 0) {
+ strcmp(defel->defname, "unencryptedPassword") == 0)
+ {
if (dpassword)
elog(ERROR, "CREATE USER: conflicting options");
dpassword = defel;
else if (strcmp(defel->defname, "unencryptedPassword") == 0)
encrypt_password = false;
}
- else if (strcmp(defel->defname, "sysid") == 0) {
+ else if (strcmp(defel->defname, "sysid") == 0)
+ {
if (dsysid)
elog(ERROR, "CREATE USER: conflicting options");
dsysid = defel;
}
- else if (strcmp(defel->defname, "createdb") == 0) {
+ else if (strcmp(defel->defname, "createdb") == 0)
+ {
if (dcreatedb)
elog(ERROR, "CREATE USER: conflicting options");
dcreatedb = defel;
}
- else if (strcmp(defel->defname, "createuser") == 0) {
+ else if (strcmp(defel->defname, "createuser") == 0)
+ {
if (dcreateuser)
elog(ERROR, "CREATE USER: conflicting options");
dcreateuser = defel;
}
- else if (strcmp(defel->defname, "groupElts") == 0) {
+ else if (strcmp(defel->defname, "groupElts") == 0)
+ {
if (dgroupElts)
elog(ERROR, "CREATE USER: conflicting options");
dgroupElts = defel;
}
- else if (strcmp(defel->defname, "validUntil") == 0) {
+ else if (strcmp(defel->defname, "validUntil") == 0)
+ {
if (dvalidUntil)
elog(ERROR, "CREATE USER: conflicting options");
dvalidUntil = defel;
}
else
- elog(ERROR,"CREATE USER: option \"%s\" not recognized",
+ elog(ERROR, "CREATE USER: option \"%s\" not recognized",
defel->defname);
}
elog(ERROR, "CREATE USER: sysid %d is already assigned", sysid);
/* If no sysid given, use max existing id + 1 */
- if (! havesysid)
+ if (!havesysid)
sysid = max_id + 1;
/*
else
{
if (!EncryptMD5(password, stmt->user, strlen(stmt->user),
- encrypted_password))
+ encrypted_password))
elog(ERROR, "CREATE USER: password encryption failed");
new_record[Anum_pg_shadow_passwd - 1] =
DirectFunctionCall1(textin, CStringGetDatum(encrypted_password));
HeapTuple tuple,
new_tuple;
bool null;
- List *option;
- char *password = NULL; /* PostgreSQL user password */
- bool encrypt_password = Password_encryption; /* encrypt password? */
- char encrypted_password[MD5_PASSWD_LEN+1];
- int createdb = -1; /* Can the user create databases? */
- int createuser = -1; /* Can this user create users? */
- char *validUntil = NULL; /* The time the login is valid until */
+ List *option;
+ char *password = NULL; /* PostgreSQL user password */
+ bool encrypt_password = Password_encryption; /* encrypt password? */
+ char encrypted_password[MD5_PASSWD_LEN + 1];
+ int createdb = -1; /* Can the user create databases? */
+ int createuser = -1; /* Can this user create users? */
+ char *validUntil = NULL; /* The time the login is valid
+ * until */
DefElem *dpassword = NULL;
DefElem *dcreatedb = NULL;
DefElem *dcreateuser = NULL;
DefElem *dvalidUntil = NULL;
/* Extract options from the statement node tree */
- foreach(option,stmt->options)
+ foreach(option, stmt->options)
{
- DefElem *defel = (DefElem *) lfirst(option);
+ DefElem *defel = (DefElem *) lfirst(option);
if (strcmp(defel->defname, "password") == 0 ||
strcmp(defel->defname, "encryptedPassword") == 0 ||
- strcmp(defel->defname, "unencryptedPassword") == 0) {
+ strcmp(defel->defname, "unencryptedPassword") == 0)
+ {
if (dpassword)
elog(ERROR, "ALTER USER: conflicting options");
dpassword = defel;
else if (strcmp(defel->defname, "unencryptedPassword") == 0)
encrypt_password = false;
}
- else if (strcmp(defel->defname, "createdb") == 0) {
+ else if (strcmp(defel->defname, "createdb") == 0)
+ {
if (dcreatedb)
elog(ERROR, "ALTER USER: conflicting options");
dcreatedb = defel;
}
- else if (strcmp(defel->defname, "createuser") == 0) {
+ else if (strcmp(defel->defname, "createuser") == 0)
+ {
if (dcreateuser)
elog(ERROR, "ALTER USER: conflicting options");
dcreateuser = defel;
}
- else if (strcmp(defel->defname, "validUntil") == 0) {
+ else if (strcmp(defel->defname, "validUntil") == 0)
+ {
if (dvalidUntil)
elog(ERROR, "ALTER USER: conflicting options");
dvalidUntil = defel;
}
else
- elog(ERROR,"ALTER USER: option \"%s\" not recognized",
+ elog(ERROR, "ALTER USER: option \"%s\" not recognized",
defel->defname);
}
/*
* createuser (superuser) and catupd
*
- * XXX It's rather unclear how to handle catupd. It's probably
- * best to keep it equal to the superuser status, otherwise you
- * could end up with a situation where no existing superuser can
- * alter the catalogs, including pg_shadow!
+ * XXX It's rather unclear how to handle catupd. It's probably best to
+ * keep it equal to the superuser status, otherwise you could end up
+ * with a situation where no existing superuser can alter the
+ * catalogs, including pg_shadow!
*/
if (createuser < 0)
{
else
{
if (!EncryptMD5(password, stmt->user, strlen(stmt->user),
- encrypted_password))
+ encrypted_password))
elog(ERROR, "CREATE USER: password encryption failed");
new_record[Anum_pg_shadow_passwd - 1] =
DirectFunctionCall1(textin, CStringGetDatum(encrypted_password));
if (HeapTupleIsValid(tmp_tuple = heap_getnext(scan, 0)))
{
- char *dbname;
+ char *dbname;
datum = heap_getattr(tmp_tuple, Anum_pg_database_datname,
pg_dsc, &null);
foreach(option, stmt->options)
{
- DefElem *defel = (DefElem *) lfirst(option);
+ DefElem *defel = (DefElem *) lfirst(option);
- if (strcmp(defel->defname, "sysid") == 0) {
+ if (strcmp(defel->defname, "sysid") == 0)
+ {
if (dsysid)
elog(ERROR, "CREATE GROUP: conflicting options");
dsysid = defel;
}
- else if (strcmp(defel->defname, "userElts") == 0) {
+ else if (strcmp(defel->defname, "userElts") == 0)
+ {
if (duserElts)
elog(ERROR, "CREATE GROUP: conflicting options");
duserElts = defel;
}
else
- elog(ERROR,"CREATE GROUP: option \"%s\" not recognized",
+ elog(ERROR, "CREATE GROUP: option \"%s\" not recognized",
defel->defname);
}
datum = heap_getattr(tuple, Anum_pg_group_grosysid,
pg_group_dsc, &null);
Assert(!null);
- if (havesysid) /* customized id wanted */
+ if (havesysid) /* customized id wanted */
sysid_exists = (DatumGetInt32(datum) == sysid);
else
{
userarray = palloc(ARR_OVERHEAD(1) + length(newlist) * sizeof(int32));
userarray->size = ARR_OVERHEAD(1) + length(newlist) * sizeof(int32);
userarray->flags = 0;
- ARR_NDIM(userarray) = 1;/* one dimensional array */
+ ARR_NDIM(userarray) = 1; /* one dimensional array */
ARR_LBOUND(userarray)[0] = 1; /* axis starts at one */
ARR_DIMS(userarray)[0] = length(newlist); /* axis is this long */
/* fill the array */
if (!member(v, newlist))
newlist = lappend(newlist, v);
else
+
/*
* we silently assume here that this error will only come
* up in a ALTER GROUP statement
* The postgres vacuum cleaner.
*
* This file includes the "full" version of VACUUM, as well as control code
- * used by all three of full VACUUM, lazy VACUUM, and ANALYZE. See
+ * used by all three of full VACUUM, lazy VACUUM, and ANALYZE. See
* vacuumlazy.c and analyze.c for the rest of the code for the latter two.
*
*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.209 2001/09/04 19:12:05 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.210 2001/10/25 05:49:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef struct VacPageListData
{
- BlockNumber empty_end_pages; /* Number of "empty" end-pages */
- int num_pages; /* Number of pages in pagedesc */
+ BlockNumber empty_end_pages; /* Number of "empty" end-pages */
+ int num_pages; /* Number of pages in pagedesc */
int num_allocated_pages; /* Number of allocated pages in
* pagedesc */
- VacPage *pagedesc; /* Descriptions of pages */
+ VacPage *pagedesc; /* Descriptions of pages */
} VacPageListData;
typedef VacPageListData *VacPageList;
typedef struct VRelStats
{
- BlockNumber rel_pages;
+ BlockNumber rel_pages;
double rel_tuples;
Size min_tlen;
Size max_tlen;
static void vacuum_shutdown(VacuumStmt *vacstmt);
static VRelList getrels(Name VacRelP, const char *stmttype);
static void vac_update_dbstats(Oid dbid,
- TransactionId vacuumXID,
- TransactionId frozenXID);
+ TransactionId vacuumXID,
+ TransactionId frozenXID);
static void vac_truncate_clog(TransactionId vacuumXID,
- TransactionId frozenXID);
+ TransactionId frozenXID);
static void vacuum_rel(Oid relid, VacuumStmt *vacstmt);
static void full_vacuum_rel(Relation onerel, VacuumStmt *vacstmt);
static void scan_heap(VRelStats *vacrelstats, Relation onerel,
- VacPageList vacuum_pages, VacPageList fraged_pages);
+ VacPageList vacuum_pages, VacPageList fraged_pages);
static void repair_frag(VRelStats *vacrelstats, Relation onerel,
- VacPageList vacuum_pages, VacPageList fraged_pages,
- int nindexes, Relation *Irel);
+ VacPageList vacuum_pages, VacPageList fraged_pages,
+ int nindexes, Relation *Irel);
static void vacuum_heap(VRelStats *vacrelstats, Relation onerel,
- VacPageList vacpagelist);
+ VacPageList vacpagelist);
static void vacuum_page(Relation onerel, Buffer buffer, VacPage vacpage);
static void vacuum_index(VacPageList vacpagelist, Relation indrel,
- double num_tuples, int keep_tuples);
+ double num_tuples, int keep_tuples);
static void scan_index(Relation indrel, double num_tuples);
static bool tid_reaped(ItemPointer itemptr, void *state);
static bool dummy_tid_reaped(ItemPointer itemptr, void *state);
static void vac_update_fsm(Relation onerel, VacPageList fraged_pages,
- BlockNumber rel_pages);
+ BlockNumber rel_pages);
static VacPage copy_vac_page(VacPage vacpage);
static void vpage_insert(VacPageList vacpagelist, VacPage vpnew);
static void *vac_bsearch(const void *key, const void *base,
- size_t nelem, size_t size,
- int (*compar) (const void *, const void *));
+ size_t nelem, size_t size,
+ int (*compar) (const void *, const void *));
static int vac_cmp_blk(const void *left, const void *right);
static int vac_cmp_offno(const void *left, const void *right);
static int vac_cmp_vtlinks(const void *left, const void *right);
vacuum_init(vacstmt);
/*
- * Process each selected relation. We are careful to process
- * each relation in a separate transaction in order to avoid holding
- * too many locks at one time. Also, if we are doing VACUUM ANALYZE,
- * the ANALYZE part runs as a separate transaction from the VACUUM
- * to further reduce locking.
+ * Process each selected relation. We are careful to process each
+ * relation in a separate transaction in order to avoid holding too
+ * many locks at one time. Also, if we are doing VACUUM ANALYZE, the
+ * ANALYZE part runs as a separate transaction from the VACUUM to
+ * further reduce locking.
*/
for (cur = vrl; cur != (VRelList) NULL; cur = cur->vrl_next)
{
if (vacstmt->vacuum && vacstmt->vacrel == NULL)
{
/*
- * Compute the initially applicable OldestXmin and FreezeLimit XIDs,
- * so that we can record these values at the end of the VACUUM.
- * Note that individual tables may well be processed with newer values,
- * but we can guarantee that no (non-shared) relations are processed
- * with older ones.
+ * Compute the initially applicable OldestXmin and FreezeLimit
+ * XIDs, so that we can record these values at the end of the
+ * VACUUM. Note that individual tables may well be processed with
+ * newer values, but we can guarantee that no (non-shared)
+ * relations are processed with older ones.
*
* It is okay to record non-shared values in pg_database, even though
* we may vacuum shared relations with older cutoffs, because only
* the minimum of the values present in pg_database matters. We
- * can be sure that shared relations have at some time been vacuumed
- * with cutoffs no worse than the global minimum; for, if there is
- * a backend in some other DB with xmin = OLDXMIN that's determining
- * the cutoff with which we vacuum shared relations, it is not possible
- * for that database to have a cutoff newer than OLDXMIN recorded in
- * pg_database.
+ * can be sure that shared relations have at some time been
+ * vacuumed with cutoffs no worse than the global minimum; for, if
+ * there is a backend in some other DB with xmin = OLDXMIN that's
+ * determining the cutoff with which we vacuum shared relations,
+ * it is not possible for that database to have a cutoff newer
+ * than OLDXMIN recorded in pg_database.
*/
vacuum_set_xid_limits(vacstmt, false,
&initialOldestXmin, &initialFreezeLimit);
}
/*
- * If we did a complete vacuum or analyze, then flush the init file that
- * relcache.c uses to save startup time. The next backend startup will
- * rebuild the init file with up-to-date information from pg_class.
- * This lets the optimizer see the stats that we've collected for certain
- * critical system indexes. See relcache.c for more details.
+ * If we did a complete vacuum or analyze, then flush the init file
+ * that relcache.c uses to save startup time. The next backend startup
+ * will rebuild the init file with up-to-date information from
+ * pg_class. This lets the optimizer see the stats that we've
+ * collected for certain critical system indexes. See relcache.c for
+ * more details.
*
* Ignore any failure to unlink the file, since it might not be there if
* no backend has been started since the last vacuum.
pgcform->relpages = (int32) num_pages;
pgcform->reltuples = num_tuples;
pgcform->relhasindex = hasindex;
+
/*
- * If we have discovered that there are no indexes, then there's
- * no primary key either. This could be done more thoroughly...
+ * If we have discovered that there are no indexes, then there's no
+ * primary key either. This could be done more thoroughly...
*/
if (!hasindex)
pgcform->relhaspkey = false;
* seems to be in danger of wrapping around.
*
* The passed XIDs are simply the ones I just wrote into my pg_database
- * entry. They're used to initialize the "min" calculations.
+ * entry. They're used to initialize the "min" calculations.
*
* This routine is shared by full and lazy VACUUM. Note that it is only
* applied after a database-wide VACUUM operation.
/*
* Determine the type of lock we want --- hard exclusive lock for a
* FULL vacuum, but just ShareUpdateExclusiveLock for concurrent
- * vacuum. Either way, we can be sure that no other backend is vacuuming
- * the same table.
+ * vacuum. Either way, we can be sure that no other backend is
+ * vacuuming the same table.
*/
lmode = vacstmt->full ? AccessExclusiveLock : ShareUpdateExclusiveLock;
/*
- * Open the class, get an appropriate lock on it, and check permissions.
+ * Open the class, get an appropriate lock on it, and check
+ * permissions.
*
* We allow the user to vacuum a table if he is superuser, the table
* owner, or the database owner (but in the latter case, only if it's
- * not a shared relation). pg_ownercheck includes the superuser case.
+ * not a shared relation). pg_ownercheck includes the superuser case.
*
* Note we choose to treat permissions failure as a NOTICE and keep
* trying to vacuum the rest of the DB --- is this appropriate?
*/
onerel = heap_open(relid, lmode);
- if (! (pg_ownercheck(GetUserId(), RelationGetRelationName(onerel),
- RELNAME) ||
- (is_dbadmin(MyDatabaseId) && !onerel->rd_rel->relisshared)))
+ if (!(pg_ownercheck(GetUserId(), RelationGetRelationName(onerel),
+ RELNAME) ||
+ (is_dbadmin(MyDatabaseId) && !onerel->rd_rel->relisshared)))
{
elog(NOTICE, "Skipping \"%s\" --- only table or database owner can VACUUM it",
RelationGetRelationName(onerel));
/*
* If the relation has a secondary toast rel, vacuum that too while we
* still hold the session lock on the master table. Note however that
- * "analyze" will not get done on the toast table. This is good,
- * because the toaster always uses hardcoded index access and statistics
- * are totally unimportant for toast relations.
+ * "analyze" will not get done on the toast table. This is good,
+ * because the toaster always uses hardcoded index access and
+ * statistics are totally unimportant for toast relations.
*/
if (toast_relid != InvalidOid)
vacuum_rel(toast_relid, vacstmt);
vacrelstats->hasindex = true;
#ifdef NOT_USED
+
/*
* reindex in VACUUM is dangerous under WAL. ifdef out until it
* becomes safe.
char *relname;
VacPage vacpage,
vacpagecopy;
- BlockNumber empty_pages,
+ BlockNumber empty_pages,
new_pages,
changed_pages,
empty_end_pages;
switch (HeapTupleSatisfiesVacuum(tuple.t_data, OldestXmin))
{
case HEAPTUPLE_DEAD:
- tupgone = true; /* we can delete the tuple */
+ tupgone = true; /* we can delete the tuple */
break;
case HEAPTUPLE_LIVE:
+
/*
- * Tuple is good. Consider whether to replace its xmin
- * value with FrozenTransactionId.
+ * Tuple is good. Consider whether to replace its
+ * xmin value with FrozenTransactionId.
*/
if (TransactionIdIsNormal(tuple.t_data->t_xmin) &&
TransactionIdPrecedes(tuple.t_data->t_xmin,
}
break;
case HEAPTUPLE_RECENTLY_DEAD:
+
/*
- * If tuple is recently deleted then we must not remove
- * it from relation.
+ * If tuple is recently deleted then we must not
+ * remove it from relation.
*/
nkeep += 1;
+
/*
* If we do shrinking and this tuple is updated one
* then remember it to construct updated tuple
}
break;
case HEAPTUPLE_INSERT_IN_PROGRESS:
+
/*
- * This should not happen, since we hold exclusive lock
- * on the relation; shouldn't we raise an error?
+ * This should not happen, since we hold exclusive
+ * lock on the relation; shouldn't we raise an error?
*/
elog(NOTICE, "Rel %s: TID %u/%u: InsertTransactionInProgress %u - can't shrink relation",
relname, blkno, offnum, tuple.t_data->t_xmin);
do_shrinking = false;
break;
case HEAPTUPLE_DELETE_IN_PROGRESS:
+
/*
- * This should not happen, since we hold exclusive lock
- * on the relation; shouldn't we raise an error?
+ * This should not happen, since we hold exclusive
+ * lock on the relation; shouldn't we raise an error?
*/
elog(NOTICE, "Rel %s: TID %u/%u: DeleteTransactionInProgress %u - can't shrink relation",
relname, blkno, offnum, tuple.t_data->t_xmax);
if (tuple.t_len > max_tlen)
max_tlen = tuple.t_len;
}
- } /* scan along page */
+ } /* scan along page */
if (tempPage != (Page) NULL)
{
}
free_size += vacpage->free;
+
/*
* Add the page to fraged_pages if it has a useful amount of free
- * space. "Useful" means enough for a minimal-sized tuple.
- * But we don't know that accurately near the start of the relation,
- * so add pages unconditionally if they have >= BLCKSZ/10 free space.
+ * space. "Useful" means enough for a minimal-sized tuple. But we
+ * don't know that accurately near the start of the relation, so
+ * add pages unconditionally if they have >= BLCKSZ/10 free space.
*/
- do_frag = (vacpage->free >= min_tlen || vacpage->free >= BLCKSZ/10);
+ do_frag = (vacpage->free >= min_tlen || vacpage->free >= BLCKSZ / 10);
if (do_reap || do_frag)
{
fraged_pages->empty_end_pages = empty_end_pages;
/*
- * Clear the fraged_pages list if we found we couldn't shrink.
- * Else, remove any "empty" end-pages from the list, and compute
- * usable free space = free space in remaining pages.
+ * Clear the fraged_pages list if we found we couldn't shrink. Else,
+ * remove any "empty" end-pages from the list, and compute usable free
+ * space = free space in remaining pages.
*/
if (do_shrinking)
{
CommandId myCID;
Buffer buf,
cur_buffer;
- BlockNumber nblocks,
+ BlockNumber nblocks,
blkno;
- BlockNumber last_move_dest_block = 0,
+ BlockNumber last_move_dest_block = 0,
last_vacuum_block;
Page page,
ToPage = NULL;
resultRelInfo = makeNode(ResultRelInfo);
resultRelInfo->ri_RangeTableIndex = 1; /* dummy */
resultRelInfo->ri_RelationDesc = onerel;
- resultRelInfo->ri_TrigDesc = NULL; /* we don't fire triggers */
+ resultRelInfo->ri_TrigDesc = NULL; /* we don't fire triggers */
ExecOpenIndices(resultRelInfo);
/*
* Scan pages backwards from the last nonempty page, trying to move
* tuples down to lower pages. Quit when we reach a page that we have
- * moved any tuples onto, or the first page if we haven't moved anything,
- * or when we find a page we cannot completely empty (this last condition
- * is handled by "break" statements within the loop).
+ * moved any tuples onto, or the first page if we haven't moved
+ * anything, or when we find a page we cannot completely empty (this
+ * last condition is handled by "break" statements within the loop).
*
* NB: this code depends on the vacuum_pages and fraged_pages lists being
* in order by blkno.
blkno--)
{
/*
- * Forget fraged_pages pages at or after this one; they're no longer
- * useful as move targets, since we only want to move down. Note
- * that since we stop the outer loop at last_move_dest_block, pages
- * removed here cannot have had anything moved onto them already.
+ * Forget fraged_pages pages at or after this one; they're no
+ * longer useful as move targets, since we only want to move down.
+ * Note that since we stop the outer loop at last_move_dest_block,
+ * pages removed here cannot have had anything moved onto them
+ * already.
*
- * Also note that we don't change the stored fraged_pages list,
- * only our local variable num_fraged_pages; so the forgotten pages
- * are still available to be loaded into the free space map later.
+ * Also note that we don't change the stored fraged_pages list, only
+ * our local variable num_fraged_pages; so the forgotten pages are
+ * still available to be loaded into the free space map later.
*/
while (num_fraged_pages > 0 &&
- fraged_pages->pagedesc[num_fraged_pages-1]->blkno >= blkno)
+ fraged_pages->pagedesc[num_fraged_pages - 1]->blkno >= blkno)
{
- Assert(fraged_pages->pagedesc[num_fraged_pages-1]->offsets_used == 0);
+ Assert(fraged_pages->pagedesc[num_fraged_pages - 1]->offsets_used == 0);
--num_fraged_pages;
}
* tuples to another places.
*/
if ((tuple.t_data->t_infomask & HEAP_UPDATED &&
- !TransactionIdPrecedes(tuple.t_data->t_xmin, OldestXmin)) ||
+ !TransactionIdPrecedes(tuple.t_data->t_xmin, OldestXmin)) ||
(!(tuple.t_data->t_infomask & HEAP_XMAX_INVALID) &&
!(ItemPointerEquals(&(tuple.t_self),
&(tuple.t_data->t_ctid)))))
ItemPointerGetOffsetNumber(&Ctid));
if (!ItemIdIsUsed(Citemid))
{
-
/*
* This means that in the middle of chain there
* was tuple updated by older (than OldestXmin)
/* All done ? */
if (!(tp.t_data->t_infomask & HEAP_UPDATED) ||
- TransactionIdPrecedes(tp.t_data->t_xmin, OldestXmin))
+ TransactionIdPrecedes(tp.t_data->t_xmin, OldestXmin))
break;
/* Well, try to find tuple with old row version */
/*
* We are not going to move any more tuples across pages, but we still
* need to apply vacuum_page to compact free space in the remaining
- * pages in vacuum_pages list. Note that some of these pages may also
- * be in the fraged_pages list, and may have had tuples moved onto them;
- * if so, we already did vacuum_page and needn't do it again.
+ * pages in vacuum_pages list. Note that some of these pages may also
+ * be in the fraged_pages list, and may have had tuples moved onto
+ * them; if so, we already did vacuum_page and needn't do it again.
*/
for (i = 0, curpage = vacuum_pages->pagedesc;
i < vacuumed_pages;
}
/*
- * Now scan all the pages that we moved tuples onto and update
- * tuple status bits. This is not really necessary, but will save time
- * for future transactions examining these tuples.
+ * Now scan all the pages that we moved tuples onto and update tuple
+ * status bits. This is not really necessary, but will save time for
+ * future transactions examining these tuples.
*
* XXX Notice that this code fails to clear HEAP_MOVED_OFF tuples from
- * pages that were move source pages but not move dest pages. One also
- * wonders whether it wouldn't be better to skip this step and let the
- * tuple status updates happen someplace that's not holding an exclusive
- * lock on the relation.
+ * pages that were move source pages but not move dest pages. One
+ * also wonders whether it wouldn't be better to skip this step and
+ * let the tuple status updates happen someplace that's not holding an
+ * exclusive lock on the relation.
*/
checked_moved = 0;
for (i = 0, curpage = fraged_pages->pagedesc;
if (vacpage->blkno == (blkno - 1) &&
vacpage->offsets_free > 0)
{
- OffsetNumber unbuf[BLCKSZ/sizeof(OffsetNumber)];
+ OffsetNumber unbuf[BLCKSZ / sizeof(OffsetNumber)];
OffsetNumber *unused = unbuf;
int uncnt;
if (blkno < nblocks)
{
blkno = smgrtruncate(DEFAULT_SMGR, onerel, blkno);
- onerel->rd_nblocks = blkno; /* update relcache immediately */
+ onerel->rd_nblocks = blkno; /* update relcache immediately */
onerel->rd_targblock = InvalidBlockNumber;
vacrelstats->rel_pages = blkno; /* set new number of blocks */
}
{
Buffer buf;
VacPage *vacpage;
- BlockNumber relblocks;
+ BlockNumber relblocks;
int nblocks;
int i;
RelationGetRelationName(onerel),
vacrelstats->rel_pages, relblocks);
relblocks = smgrtruncate(DEFAULT_SMGR, onerel, relblocks);
- onerel->rd_nblocks = relblocks; /* update relcache immediately */
+ onerel->rd_nblocks = relblocks; /* update relcache immediately */
onerel->rd_targblock = InvalidBlockNumber;
vacrelstats->rel_pages = relblocks; /* set new number of
* blocks */
static void
vacuum_page(Relation onerel, Buffer buffer, VacPage vacpage)
{
- OffsetNumber unbuf[BLCKSZ/sizeof(OffsetNumber)];
+ OffsetNumber unbuf[BLCKSZ / sizeof(OffsetNumber)];
OffsetNumber *unused = unbuf;
int uncnt;
Page page = BufferGetPage(buffer);
/*
* Even though we're not planning to delete anything, use the
- * ambulkdelete call, so that the scan happens within the index AM
- * for more speed.
+ * ambulkdelete call, so that the scan happens within the index AM for
+ * more speed.
*/
stats = index_bulk_delete(indrel, dummy_tid_reaped, NULL);
vac_show_rusage(&ru0));
/*
- * Check for tuple count mismatch. If the index is partial, then
- * it's OK for it to have fewer tuples than the heap; else we got trouble.
+ * Check for tuple count mismatch. If the index is partial, then it's
+ * OK for it to have fewer tuples than the heap; else we got trouble.
*/
if (stats->num_index_tuples != num_tuples)
{
if (stats->num_index_tuples > num_tuples ||
- ! vac_is_partial_index(indrel))
+ !vac_is_partial_index(indrel))
elog(NOTICE, "Index %s: NUMBER OF INDEX' TUPLES (%.0f) IS NOT THE SAME AS HEAP' (%.0f).\
\n\tRecreate the index.",
RelationGetRelationName(indrel),
vac_show_rusage(&ru0));
/*
- * Check for tuple count mismatch. If the index is partial, then
- * it's OK for it to have fewer tuples than the heap; else we got trouble.
+ * Check for tuple count mismatch. If the index is partial, then it's
+ * OK for it to have fewer tuples than the heap; else we got trouble.
*/
if (stats->num_index_tuples != num_tuples + keep_tuples)
{
if (stats->num_index_tuples > num_tuples + keep_tuples ||
- ! vac_is_partial_index(indrel))
+ !vac_is_partial_index(indrel))
elog(NOTICE, "Index %s: NUMBER OF INDEX' TUPLES (%.0f) IS NOT THE SAME AS HEAP' (%.0f).\
\n\tRecreate the index.",
RelationGetRelationName(indrel),
static bool
tid_reaped(ItemPointer itemptr, void *state)
{
- VacPageList vacpagelist = (VacPageList) state;
+ VacPageList vacpagelist = (VacPageList) state;
OffsetNumber ioffno;
OffsetNumber *voff;
VacPage vp,
{
pages[i] = fraged_pages->pagedesc[i]->blkno;
spaceAvail[i] = fraged_pages->pagedesc[i]->free;
+
/*
- * fraged_pages may contain entries for pages that we later decided
- * to truncate from the relation; don't enter them into the map!
+ * fraged_pages may contain entries for pages that we later
+ * decided to truncate from the relation; don't enter them into
+ * the map!
*/
if (pages[i] >= rel_pages)
{
/* allocate a VacPageData entry */
newvacpage = (VacPage) palloc(sizeof(VacPageData) +
- vacpage->offsets_free * sizeof(OffsetNumber));
+ vacpage->offsets_free * sizeof(OffsetNumber));
/* fill it in */
if (vacpage->offsets_free > 0)
/*
* vac_bsearch: just like standard C library routine bsearch(),
* except that we first test to see whether the target key is outside
- * the range of the table entries. This case is handled relatively slowly
+ * the range of the table entries. This case is handled relatively slowly
* by the normal binary search algorithm (ie, no faster than any other key)
* but it occurs often enough in VACUUM to be worth optimizing.
*/
Form_pg_index indexStruct;
/*
- * If the index's AM doesn't support nulls, it's partial for our purposes
+ * If the index's AM doesn't support nulls, it's partial for our
+ * purposes
*/
- if (! indrel->rd_am->amindexnulls)
+ if (!indrel->rd_am->amindexnulls)
return true;
/* Otherwise, look to see if there's a partial-index predicate */
cachetuple = SearchSysCache(INDEXRELID,
- ObjectIdGetDatum(RelationGetRelid(indrel)),
+ ObjectIdGetDatum(RelationGetRelid(indrel)),
0, 0, 0);
if (!HeapTupleIsValid(cachetuple))
elog(ERROR, "vac_is_partial_index: index %u not found",
snprintf(result, sizeof(result),
"CPU %d.%02ds/%d.%02du sec elapsed %d.%02d sec.",
(int) (ru1.ru.ru_stime.tv_sec - ru0->ru.ru_stime.tv_sec),
- (int) (ru1.ru.ru_stime.tv_usec - ru0->ru.ru_stime.tv_usec) / 10000,
+ (int) (ru1.ru.ru_stime.tv_usec - ru0->ru.ru_stime.tv_usec) / 10000,
(int) (ru1.ru.ru_utime.tv_sec - ru0->ru.ru_utime.tv_sec),
- (int) (ru1.ru.ru_utime.tv_usec - ru0->ru.ru_utime.tv_usec) / 10000,
+ (int) (ru1.ru.ru_utime.tv_usec - ru0->ru.ru_utime.tv_usec) / 10000,
(int) (ru1.tv.tv_sec - ru0->tv.tv_sec),
(int) (ru1.tv.tv_usec - ru0->tv.tv_usec) / 10000);
*
* We can limit the storage for page free space to MaxFSMPages entries,
* since that's the most the free space map will be willing to remember
- * anyway. If the relation has fewer than that many pages with free space,
- * life is easy: just build an array of per-page info. If it has more,
+ * anyway. If the relation has fewer than that many pages with free space,
+ * life is easy: just build an array of per-page info. If it has more,
* we store the free space info as a heap ordered by amount of free space,
* so that we can discard the pages with least free space to ensure we never
* have more than MaxFSMPages entries in all. The surviving page entries
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.8 2001/09/29 04:02:22 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.9 2001/10/25 05:49:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* Space/time tradeoff parameters: do these need to be user-tunable?
*
* A page with less than PAGE_SPACE_THRESHOLD free space will be forgotten
- * immediately, and not even passed to the free space map. Removing the
+ * immediately, and not even passed to the free space map. Removing the
* uselessly small entries early saves cycles, and in particular reduces
* the amount of time we spend holding the FSM lock when we finally call
* MultiRecordFreeSpace. Since the FSM will ignore pages below its own
typedef struct LVRelStats
{
/* Overall statistics about rel */
- BlockNumber rel_pages;
+ BlockNumber rel_pages;
double rel_tuples;
- BlockNumber nonempty_pages; /* actually, last nonempty page + 1 */
+ BlockNumber nonempty_pages; /* actually, last nonempty page + 1 */
/* List of TIDs of tuples we intend to delete */
/* NB: this list is ordered by TID address */
- int num_dead_tuples; /* current # of entries */
- int max_dead_tuples; /* # slots allocated in array */
- ItemPointer dead_tuples; /* array of ItemPointerData */
+ int num_dead_tuples; /* current # of entries */
+ int max_dead_tuples; /* # slots allocated in array */
+ ItemPointer dead_tuples; /* array of ItemPointerData */
/* Array or heap of per-page info about free space */
/* We use a simple array until it fills up, then convert to heap */
- bool fs_is_heap; /* are we using heap organization? */
- int num_free_pages; /* current # of entries */
- int max_free_pages; /* # slots allocated in arrays */
- BlockNumber *free_pages; /* array or heap of block numbers */
- Size *free_spaceavail; /* array or heap of available space */
+ bool fs_is_heap; /* are we using heap organization? */
+ int num_free_pages; /* current # of entries */
+ int max_free_pages; /* # slots allocated in arrays */
+ BlockNumber *free_pages; /* array or heap of block numbers */
+ Size *free_spaceavail; /* array or heap of available space */
} LVRelStats;
/* non-export function prototypes */
static void lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
- Relation *Irel, int nindexes);
+ Relation *Irel, int nindexes);
static void lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats);
static void lazy_scan_index(Relation indrel, LVRelStats *vacrelstats);
static void lazy_vacuum_index(Relation indrel, LVRelStats *vacrelstats);
-static int lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
- int tupindex, LVRelStats *vacrelstats);
+static int lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
+ int tupindex, LVRelStats *vacrelstats);
static void lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats);
static BlockNumber count_nondeletable_pages(Relation onerel,
- LVRelStats *vacrelstats);
+ LVRelStats *vacrelstats);
static void lazy_space_alloc(LVRelStats *vacrelstats, BlockNumber relblocks);
static void lazy_record_dead_tuple(LVRelStats *vacrelstats,
- ItemPointer itemptr);
+ ItemPointer itemptr);
static void lazy_record_free_space(LVRelStats *vacrelstats,
- BlockNumber page, Size avail);
+ BlockNumber page, Size avail);
static bool lazy_tid_reaped(ItemPointer itemptr, void *state);
static bool dummy_tid_reaped(ItemPointer itemptr, void *state);
static void lazy_update_fsm(Relation onerel, LVRelStats *vacrelstats);
Relation *Irel;
int nindexes;
bool hasindex;
- BlockNumber possibly_freeable;
+ BlockNumber possibly_freeable;
/* initialize */
if (vacstmt->verbose)
/*
* Optionally truncate the relation.
*
- * Don't even think about it unless we have a shot at releasing a
- * goodly number of pages. Otherwise, the time taken isn't worth it.
+ * Don't even think about it unless we have a shot at releasing a goodly
+ * number of pages. Otherwise, the time taken isn't worth it.
*/
possibly_freeable = vacrelstats->rel_pages - vacrelstats->nonempty_pages;
if (possibly_freeable > vacrelstats->rel_pages / REL_TRUNCATE_FRACTION)
blkno;
HeapTupleData tuple;
char *relname;
- BlockNumber empty_pages,
+ BlockNumber empty_pages,
changed_pages;
double num_tuples,
tups_vacuumed,
int prev_dead_count;
/*
- * If we are close to overrunning the available space for dead-tuple
- * TIDs, pause and do a cycle of vacuuming before we tackle this page.
+ * If we are close to overrunning the available space for
+ * dead-tuple TIDs, pause and do a cycle of vacuuming before we
+ * tackle this page.
*/
if ((vacrelstats->max_dead_tuples - vacrelstats->num_dead_tuples) < MAX_TUPLES_PER_PAGE &&
vacrelstats->num_dead_tuples > 0)
switch (HeapTupleSatisfiesVacuum(tuple.t_data, OldestXmin))
{
case HEAPTUPLE_DEAD:
- tupgone = true; /* we can delete the tuple */
+ tupgone = true; /* we can delete the tuple */
break;
case HEAPTUPLE_LIVE:
+
/*
- * Tuple is good. Consider whether to replace its xmin
- * value with FrozenTransactionId.
+ * Tuple is good. Consider whether to replace its
+ * xmin value with FrozenTransactionId.
*
- * NB: Since we hold only a shared buffer lock here,
- * we are assuming that TransactionId read/write
- * is atomic. This is not the only place that makes
- * such an assumption. It'd be possible to avoid the
+ * NB: Since we hold only a shared buffer lock here, we
+ * are assuming that TransactionId read/write is
+ * atomic. This is not the only place that makes such
+ * an assumption. It'd be possible to avoid the
* assumption by momentarily acquiring exclusive lock,
* but for the moment I see no need to.
*/
}
break;
case HEAPTUPLE_RECENTLY_DEAD:
+
/*
- * If tuple is recently deleted then we must not remove
- * it from relation.
+ * If tuple is recently deleted then we must not
+ * remove it from relation.
*/
nkeep += 1;
break;
num_tuples += 1;
hastup = true;
}
- } /* scan along page */
+ } /* scan along page */
/*
- * If we remembered any tuples for deletion, then the page will
- * be visited again by lazy_vacuum_heap, which will compute and
+ * If we remembered any tuples for deletion, then the page will be
+ * visited again by lazy_vacuum_heap, which will compute and
* record its post-compaction free space. If not, then we're done
* with this page, so remember its free space as-is.
*/
/* Remove tuples from heap */
lazy_vacuum_heap(onerel, vacrelstats);
}
- else if (! did_vacuum_index)
+ else if (!did_vacuum_index)
{
/* Scan indexes just to update pg_class statistics about them */
for (i = 0; i < nindexes; i++)
tupindex = 0;
while (tupindex < vacrelstats->num_dead_tuples)
{
- BlockNumber tblk;
+ BlockNumber tblk;
Buffer buf;
Page page;
lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
int tupindex, LVRelStats *vacrelstats)
{
- OffsetNumber unbuf[BLCKSZ/sizeof(OffsetNumber)];
+ OffsetNumber unbuf[BLCKSZ / sizeof(OffsetNumber)];
OffsetNumber *unused = unbuf;
int uncnt;
Page page = BufferGetPage(buffer);
START_CRIT_SECTION();
for (; tupindex < vacrelstats->num_dead_tuples; tupindex++)
{
- BlockNumber tblk;
- OffsetNumber toff;
+ BlockNumber tblk;
+ OffsetNumber toff;
tblk = ItemPointerGetBlockNumber(&vacrelstats->dead_tuples[tupindex]);
if (tblk != blkno)
vac_init_rusage(&ru0);
/*
- * If the index is not partial, skip the scan, and just assume it
- * has the same number of tuples as the heap.
+ * If the index is not partial, skip the scan, and just assume it has
+ * the same number of tuples as the heap.
*/
- if (! vac_is_partial_index(indrel))
+ if (!vac_is_partial_index(indrel))
{
vac_update_relstats(RelationGetRelid(indrel),
RelationGetNumberOfBlocks(indrel),
}
/*
- * If index is unsafe for concurrent access, must lock it;
- * but a shared lock should be sufficient.
+ * If index is unsafe for concurrent access, must lock it; but a
+ * shared lock should be sufficient.
*/
- if (! indrel->rd_am->amconcurrent)
+ if (!indrel->rd_am->amconcurrent)
LockRelation(indrel, AccessShareLock);
/*
* Even though we're not planning to delete anything, use the
- * ambulkdelete call, so that the scan happens within the index AM
- * for more speed.
+ * ambulkdelete call, so that the scan happens within the index AM for
+ * more speed.
*/
stats = index_bulk_delete(indrel, dummy_tid_reaped, NULL);
/*
* Release lock acquired above.
*/
- if (! indrel->rd_am->amconcurrent)
+ if (!indrel->rd_am->amconcurrent)
UnlockRelation(indrel, AccessShareLock);
if (!stats)
/*
* If index is unsafe for concurrent access, must lock it.
*/
- if (! indrel->rd_am->amconcurrent)
+ if (!indrel->rd_am->amconcurrent)
LockRelation(indrel, AccessExclusiveLock);
/* Do bulk deletion */
/*
* Release lock acquired above.
*/
- if (! indrel->rd_am->amconcurrent)
+ if (!indrel->rd_am->amconcurrent)
UnlockRelation(indrel, AccessExclusiveLock);
/* now update statistics in pg_class */
static void
lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
{
- BlockNumber old_rel_pages = vacrelstats->rel_pages;
- BlockNumber new_rel_pages;
+ BlockNumber old_rel_pages = vacrelstats->rel_pages;
+ BlockNumber new_rel_pages;
BlockNumber *pages;
Size *spaceavail;
int n;
vac_init_rusage(&ru0);
/*
- * We need full exclusive lock on the relation in order to do truncation.
- * If we can't get it, give up rather than waiting --- we don't want
- * to block other backends, and we don't want to deadlock (which is
- * quite possible considering we already hold a lower-grade lock).
+ * We need full exclusive lock on the relation in order to do
+ * truncation. If we can't get it, give up rather than waiting --- we
+ * don't want to block other backends, and we don't want to deadlock
+ * (which is quite possible considering we already hold a lower-grade
+ * lock).
*/
- if (! ConditionalLockRelation(onerel, AccessExclusiveLock))
+ if (!ConditionalLockRelation(onerel, AccessExclusiveLock))
return;
/*
/*
* Scan backwards from the end to verify that the end pages actually
- * contain nothing we need to keep. This is *necessary*, not optional,
- * because other backends could have added tuples to these pages whilst
- * we were vacuuming.
+ * contain nothing we need to keep. This is *necessary*, not
+ * optional, because other backends could have added tuples to these
+ * pages whilst we were vacuuming.
*/
new_rel_pages = count_nondeletable_pages(onerel, vacrelstats);
* Do the physical truncation.
*/
new_rel_pages = smgrtruncate(DEFAULT_SMGR, onerel, new_rel_pages);
- onerel->rd_nblocks = new_rel_pages; /* update relcache immediately */
+ onerel->rd_nblocks = new_rel_pages; /* update relcache immediately */
onerel->rd_targblock = InvalidBlockNumber;
- vacrelstats->rel_pages = new_rel_pages; /* save new number of blocks */
+ vacrelstats->rel_pages = new_rel_pages; /* save new number of
+ * blocks */
/*
* Drop free-space info for removed blocks; these must not get entered
switch (HeapTupleSatisfiesVacuum(tuple.t_data, OldestXmin))
{
case HEAPTUPLE_DEAD:
- tupgone = true; /* we can delete the tuple */
+ tupgone = true; /* we can delete the tuple */
break;
case HEAPTUPLE_LIVE:
/* Shouldn't be necessary to re-freeze anything */
break;
case HEAPTUPLE_RECENTLY_DEAD:
+
/*
- * If tuple is recently deleted then we must not remove
- * it from relation.
+ * If tuple is recently deleted then we must not
+ * remove it from relation.
*/
break;
case HEAPTUPLE_INSERT_IN_PROGRESS:
hastup = true;
break; /* can stop scanning */
}
- } /* scan along page */
+ } /* scan along page */
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
/*
* If we fall out of the loop, all the previously-thought-to-be-empty
- * pages really are; we need not bother to look at the last known-nonempty
- * page.
+ * pages really are; we need not bother to look at the last
+ * known-nonempty page.
*/
return vacrelstats->nonempty_pages;
}
ItemPointer itemptr)
{
/*
- * The array shouldn't overflow under normal behavior,
- * but perhaps it could if we are given a really small VacuumMem.
- * In that case, just forget the last few tuples.
+ * The array shouldn't overflow under normal behavior, but perhaps it
+ * could if we are given a really small VacuumMem. In that case, just
+ * forget the last few tuples.
*/
if (vacrelstats->num_dead_tuples < vacrelstats->max_dead_tuples)
{
*/
/* If we haven't yet converted the array to heap organization, do it */
- if (! vacrelstats->fs_is_heap)
+ if (!vacrelstats->fs_is_heap)
{
/*
* Scan backwards through the array, "sift-up" each value into its
- * correct position. We can start the scan at n/2-1 since each entry
- * above that position has no children to worry about.
+ * correct position. We can start the scan at n/2-1 since each
+ * entry above that position has no children to worry about.
*/
- int l = n / 2;
+ int l = n / 2;
while (--l >= 0)
{
- BlockNumber R = pages[l];
+ BlockNumber R = pages[l];
Size K = spaceavail[l];
int i; /* i is where the "hole" is */
i = l;
for (;;)
{
- int j = 2*i + 1;
+ int j = 2 * i + 1;
if (j >= n)
break;
- if (j+1 < n && spaceavail[j] > spaceavail[j+1])
+ if (j + 1 < n && spaceavail[j] > spaceavail[j + 1])
j++;
if (K <= spaceavail[j])
break;
if (avail > spaceavail[0])
{
/*
- * Notionally, we replace the zero'th entry with the new data,
- * and then sift-up to maintain the heap property. Physically,
- * the new data doesn't get stored into the arrays until we find
- * the right location for it.
+ * Notionally, we replace the zero'th entry with the new data, and
+ * then sift-up to maintain the heap property. Physically, the
+ * new data doesn't get stored into the arrays until we find the
+ * right location for it.
*/
- int i = 0; /* i is where the "hole" is */
+ int i = 0; /* i is where the "hole" is */
for (;;)
{
- int j = 2*i + 1;
+ int j = 2 * i + 1;
if (j >= n)
break;
- if (j+1 < n && spaceavail[j] > spaceavail[j+1])
+ if (j + 1 < n && spaceavail[j] > spaceavail[j + 1])
j++;
if (avail <= spaceavail[j])
break;
lazy_tid_reaped(ItemPointer itemptr, void *state)
{
LVRelStats *vacrelstats = (LVRelStats *) state;
- ItemPointer res;
+ ItemPointer res;
res = (ItemPointer) bsearch((void *) itemptr,
(void *) vacrelstats->dead_tuples,
lazy_update_fsm(Relation onerel, LVRelStats *vacrelstats)
{
/*
- * Since MultiRecordFreeSpace doesn't currently impose any restrictions
- * on the ordering of the input, we can just pass it the arrays as-is,
- * whether they are in heap or linear order.
+ * Since MultiRecordFreeSpace doesn't currently impose any
+ * restrictions on the ordering of the input, we can just pass it the
+ * arrays as-is, whether they are in heap or linear order.
*/
MultiRecordFreeSpace(&onerel->rd_node,
0, MaxBlockNumber,
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.54 2001/10/18 17:30:14 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.55 2001/10/25 05:49:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
DBDate = strdup(DBDate);
- /* Parse desired setting into DateStyle/EuroDates
- * Use parse_datestyle_internal() to avoid any palloc() issues per above
- * - thomas 2001-10-15
+ /*
+ * Parse desired setting into DateStyle/EuroDates Use
+ * parse_datestyle_internal() to avoid any palloc() issues per above -
+ * thomas 2001-10-15
*/
parse_datestyle_internal(DBDate);
foreach(arg, args)
{
- A_Const *p;
+ A_Const *p;
Assert(IsA(arg, List));
p = lfirst(arg);
Interval *interval;
interval = DatumGetIntervalP(DirectFunctionCall3(interval_in,
- CStringGetDatum(p->val.val.str),
- ObjectIdGetDatum(InvalidOid),
- Int32GetDatum(-1)));
+ CStringGetDatum(p->val.val.str),
+ ObjectIdGetDatum(InvalidOid),
+ Int32GetDatum(-1)));
if (interval->month != 0)
elog(ERROR, "SET TIME ZONE illegal INTERVAL; month not allowed");
CTimeZone = interval->time;
}
else if (strcmp(type->name, "float8") == 0)
{
- float8 time;
+ float8 time;
time = DatumGetFloat8(DirectFunctionCall1(float8in, CStringGetDatum(p->val.val.str)));
CTimeZone = time * 3600;
}
- /* We do not actually generate an integer constant in gram.y so this is not used... */
+
+ /*
+ * We do not actually generate an integer constant in gram.y
+ * so this is not used...
+ */
else if (strcmp(type->name, "int4") == 0)
{
- int32 time;
+ int32 time;
time = p->val.val.ival;
CTimeZone = time * 3600;
static bool
show_timezone(void)
{
- char *tzn;
+ char *tzn;
if (HasCTZSet)
{
- Interval interval;
+ Interval interval;
interval.month = 0;
interval.time = CTimeZone;
tzn = DatumGetCString(DirectFunctionCall1(interval_out, IntervalPGetDatum(&interval)));
}
else
- {
tzn = getenv("TZ");
- }
if (tzn != NULL)
elog(NOTICE, "Time zone is '%s'", tzn);
reset_timezone(void)
{
if (HasCTZSet)
- {
HasCTZSet = false;
- }
/* no time zone has been set in this session? */
else if (defaultTZ == NULL)
static bool
parse_XactIsoLevel(List *args)
{
- char *value;
+ char *value;
if (args == NULL)
return reset_XactIsoLevel();
static bool
parse_random_seed(List *args)
{
- char *value;
- double seed = 0;
+ char *value;
+ double seed = 0;
if (args == NULL)
return reset_random_seed();
static bool
parse_client_encoding(List *args)
{
- char *value;
+ char *value;
+
#ifdef MULTIBYTE
- int encoding;
+ int encoding;
#endif
if (args == NULL)
}
#else
if (value &&
- strcasecmp(value, pg_get_client_encoding_name()) != 0)
+ strcasecmp(value, pg_get_client_encoding_name()) != 0)
elog(ERROR, "Client encoding %s is not supported", value);
#endif
return TRUE;
parse_random_seed(args);
else
{
- /* For routines defined somewhere else,
- * go ahead and extract the string argument
- * to match the original interface definition.
+ /*
+ * For routines defined somewhere else, go ahead and extract the
+ * string argument to match the original interface definition.
* Later, we can change this code too...
*/
- char *value;
+ char *value;
- value = ((args != NULL)? ((A_Const *) lfirst(args))->val.val.str: NULL);
+ value = ((args != NULL) ? ((A_Const *) lfirst(args))->val.val.str : NULL);
if (strcasecmp(name, "session_authorization") == 0)
SetSessionAuthorization(value);
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: view.c,v 1.57 2001/08/16 20:38:53 tgl Exp $
+ * $Id: view.c,v 1.58 2001/10/25 05:49:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
RuleStmt *replace_rule;
RuleStmt *append_rule;
RuleStmt *delete_rule;
-
#endif
retrieve_rule = FormViewRetrieveRule(viewName, viewParse);
replace_rule = FormViewReplaceRule(viewName, viewParse);
append_rule = FormViewAppendRule(viewName, viewParse);
delete_rule = FormViewDeleteRule(viewName, viewParse);
-
#endif
DefineQueryRewrite(retrieve_rule);
void
DefineView(char *viewName, Query *viewParse)
{
-
/*
* Create the "view" relation NOTE: if it already exists, the xact
* will be aborted.
void
RemoveView(char *viewName)
{
-
/*
* We just have to drop the relation; the associated rules will be
* cleaned up automatically.
* ExecInitTee
* ExecEndTee
*
- * $Id: nodeTee.c,v 1.10 2001/03/22 06:16:13 momjian Exp $
+ * $Id: nodeTee.c,v 1.11 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
slot = ExecProcNode(childNode, (Plan *) node);
if (!TupIsNull(slot))
{
-
/*
* heap_insert changes something...
*/
teeState->tee_leftScanDesc : teeState->tee_rightScanDesc;
{
-
/*
* move the scandesc forward so we don't re-read this
* tuple later
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: execAmi.c,v 1.59 2001/09/18 01:59:06 tgl Exp $
+ * $Id: execAmi.c,v 1.60 2001/10/25 05:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
for (i = 0; i < numIndices; i++)
{
-
/*
* shut down each of the index scans and close each of the
* index relations
{
switch (nodeTag(node))
{
- case T_SeqScan:
+ case T_SeqScan:
ExecSeqMarkPos((SeqScan *) node);
break;
{
switch (nodeTag(node))
{
- case T_SeqScan:
+ case T_SeqScan:
ExecSeqRestrPos((SeqScan *) node);
break;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/Attic/execFlatten.c,v 1.14 2001/01/24 19:42:53 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/Attic/execFlatten.c,v 1.15 2001/10/25 05:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifdef SETS_FIXED
static bool FjoinBumpOuterNodes(TargetEntry *tlist, ExprContext *econtext,
DatumPtr results, char *nulls);
-
#endif
*/
if (!fjNode->fj_initialized)
{
-
/*
* Initialize all of the Outer nodes
*/
}
else
{
-
/*
* If we're already initialized, all we need to do is get the next
* inner result and pair it up with the existing outer node result
}
return false;
}
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.28 2001/05/27 20:48:51 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.29 2001/10/25 05:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
resjunk = resdom->resjunk;
if (!resjunk)
{
-
/*
* make a copy of the resdom node, changing its resno.
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.148 2001/09/18 01:59:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.149 2001/10/25 05:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static void
ExecCheckQueryPerms(CmdType operation, Query *parseTree, Plan *plan)
{
-
/*
* Check RTEs in the query's primary rangetable.
*/
if (rte->checkForWrite)
{
-
/*
* Note: write access in a SELECT context means SELECT FOR UPDATE.
* Right now we don't distinguish that from true update as far as
if (resultRelations != NIL)
{
-
/*
* Multiple result relations (due to inheritance)
* parseTree->resultRelations identifies them all
}
else
{
-
/*
* Single result relation identified by
* parseTree->resultRelation
}
else
{
-
/*
* if no result relation, then set state appropriately
*/
/*
* initialize the executor "tuple" table. We need slots for all the
- * plan nodes, plus possibly output slots for the junkfilter(s).
- * At this point we aren't sure if we need junkfilters, so just add
- * slots for them unconditionally.
+ * plan nodes, plus possibly output slots for the junkfilter(s). At
+ * this point we aren't sure if we need junkfilters, so just add slots
+ * for them unconditionally.
*/
{
int nSlots = ExecCountSlotsNode(plan);
if (junk_filter_needed)
{
-
/*
* If there are multiple result relations, each one needs its
* own junk filter. Note this is only possible for
j = ExecInitJunkFilter(subplan->targetlist,
ExecGetTupType(subplan),
- ExecAllocTableSlot(estate->es_tupleTable));
+ ExecAllocTableSlot(estate->es_tupleTable));
resultRelInfo->ri_junkFilter = j;
resultRelInfo++;
subplans = lnext(subplans);
j = ExecInitJunkFilter(plan->targetlist,
tupType,
- ExecAllocTableSlot(estate->es_tupleTable));
+ ExecAllocTableSlot(estate->es_tupleTable));
estate->es_junkFilter = j;
if (estate->es_result_relation_info)
estate->es_result_relation_info->ri_junkFilter = j;
if (!parseTree->isPortal)
{
-
/*
* a select into table
*/
if (parseTree->into != NULL)
{
-
/*
* create the "into" relation
*/
newTuple = ExecRemoveJunk(junkfilter, slot);
slot = ExecStoreTuple(newTuple, /* tuple to store */
- junkfilter->jf_resultSlot, /* dest slot */
+ junkfilter->jf_resultSlot, /* dest slot */
InvalidBuffer, /* this tuple has no
* buffer */
true); /* tuple should be pfreed */
/* BEFORE ROW INSERT Triggers */
if (resultRelInfo->ri_TrigDesc &&
- resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_INSERT] > 0)
+ resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_INSERT] > 0)
{
HeapTuple newtuple;
if (newtuple != tuple) /* modified by Trigger(s) */
{
-
/*
* Insert modified tuple into tuple table slot, replacing the
* original. We assume that it was allocated in per-tuple
/* BEFORE ROW DELETE Triggers */
if (resultRelInfo->ri_TrigDesc &&
- resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_DELETE] > 0)
+ resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_DELETE] > 0)
{
bool dodelete;
/* BEFORE ROW UPDATE Triggers */
if (resultRelInfo->ri_TrigDesc &&
- resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_UPDATE] > 0)
+ resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_UPDATE] > 0)
{
HeapTuple newtuple;
if (newtuple != tuple) /* modified by Trigger(s) */
{
-
/*
* Insert modified tuple into tuple table slot, replacing the
* original. We assume that it was allocated in per-tuple
/*
* Check the constraints of the tuple
*
- * If we generate a new candidate tuple after EvalPlanQual testing,
- * we must loop back here and recheck constraints. (We don't need to
- * redo triggers, however. If there are any BEFORE triggers then
- * trigger.c will have done mark4update to lock the correct tuple,
- * so there's no need to do them again.)
+ * If we generate a new candidate tuple after EvalPlanQual testing, we
+ * must loop back here and recheck constraints. (We don't need to
+ * redo triggers, however. If there are any BEFORE triggers then
+ * trigger.c will have done mark4update to lock the correct tuple, so
+ * there's no need to do them again.)
*/
lreplace:;
if (resultRelationDesc->rd_att->constr)
*tupleid = ctid;
tuple = ExecRemoveJunk(estate->es_junkFilter, epqslot);
slot = ExecStoreTuple(tuple,
- estate->es_junkFilter->jf_resultSlot,
+ estate->es_junkFilter->jf_resultSlot,
InvalidBuffer, true);
goto lreplace;
}
*/
if (estate->es_result_relation_info != NULL &&
estate->es_result_relation_info->ri_RangeTableIndex == rti)
- {
relation = estate->es_result_relation_info->ri_RelationDesc;
- }
else
{
List *l;
*tid = tuple.t_self;
/*
- * Need to run a recheck subquery. Find or create a PQ stack entry.
+ * Need to run a recheck subquery. Find or create a PQ stack entry.
*/
epq = (evalPlanQual *) estate->es_evalPlanQual;
rtsize = length(estate->es_range_table);
{
newepq = (evalPlanQual *) palloc(sizeof(evalPlanQual));
newepq->free = NULL;
+
/*
- * Each stack level has its own copy of the plan tree. This
+ * Each stack level has its own copy of the plan tree. This
* is wasteful, but necessary as long as plan nodes point to
- * exec state nodes rather than vice versa. Note that copyfuncs.c
- * doesn't attempt to copy the exec state nodes, which is a good
- * thing in this situation.
+ * exec state nodes rather than vice versa. Note that
+ * copyfuncs.c doesn't attempt to copy the exec state nodes,
+ * which is a good thing in this situation.
*/
newepq->plan = copyObject(estate->es_origPlan);
+
/*
* Init stack level's EState. We share top level's copy of
- * es_result_relations array and other non-changing status.
- * We need our own tupletable, es_param_exec_vals, and other
+ * es_result_relations array and other non-changing status. We
+ * need our own tupletable, es_param_exec_vals, and other
* changeable state.
*/
epqstate = &(newepq->estate);
sizeof(ParamExecData));
epqstate->es_tupleTable = NULL;
epqstate->es_per_tuple_exprcontext = NULL;
+
/*
- * Each epqstate must have its own es_evTupleNull state,
- * but all the stack entries share es_evTuple state. This
- * allows sub-rechecks to inherit the value being examined by
- * an outer recheck.
+ * Each epqstate must have its own es_evTupleNull state, but
+ * all the stack entries share es_evTuple state. This allows
+ * sub-rechecks to inherit the value being examined by an
+ * outer recheck.
*/
epqstate->es_evTupleNull = (bool *) palloc(rtsize * sizeof(bool));
if (epq == NULL)
epqstate = &(epq->estate);
/*
- * Ok - we're requested for the same RTE. Unfortunately we still
- * have to end and restart execution of the plan, because ExecReScan
+ * Ok - we're requested for the same RTE. Unfortunately we still have
+ * to end and restart execution of the plan, because ExecReScan
* wouldn't ensure that upper plan nodes would reset themselves. We
- * could make that work if insertion of the target tuple were integrated
- * with the Param mechanism somehow, so that the upper plan nodes know
- * that their children's outputs have changed.
+ * could make that work if insertion of the target tuple were
+ * integrated with the Param mechanism somehow, so that the upper plan
+ * nodes know that their children's outputs have changed.
*/
if (endNode)
{
}
/*
- * free old RTE' tuple, if any, and store target tuple where relation's
- * scan node will see it
+ * free old RTE' tuple, if any, and store target tuple where
+ * relation's scan node will see it
*/
if (epqstate->es_evTuple[rti - 1] != NULL)
heap_freetuple(epqstate->es_evTuple[rti - 1]);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.27 2001/09/18 01:59:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.28 2001/10/25 05:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
switch (nodeTag(node))
{
- /*
- * control nodes
- */
+ /*
+ * control nodes
+ */
case T_Result:
result = ExecResult((Result *) node);
break;
switch (nodeTag(node))
{
- /*
- * control nodes
- */
+ /*
+ * control nodes
+ */
case T_Result:
ExecEndResult((Result *) node);
break;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.88 2001/09/21 00:11:30 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.89 2001/10/25 05:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static Datum ExecEvalCase(CaseExpr *caseExpr, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalNullTest(NullTest *ntest, ExprContext *econtext,
- bool *isNull, ExprDoneCond *isDone);
+ bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalBooleanTest(BooleanTest *btest, ExprContext *econtext,
- bool *isNull, ExprDoneCond *isDone);
+ bool *isNull, ExprDoneCond *isDone);
/*----------
}
else
{
-
/*
* Empty refexpr indicates we are doing an INSERT into an array
* column. For now, we just take the refassgnexpr (which the
* the entire tuple; we give back a whole slot so that callers know
* what the tuple looks like.
*
- * XXX this is a horrid crock: since the pointer to the slot might
- * live longer than the current evaluation context, we are forced to
- * copy the tuple and slot into a long-lived context --- we use
+ * XXX this is a horrid crock: since the pointer to the slot might live
+ * longer than the current evaluation context, we are forced to copy
+ * the tuple and slot into a long-lived context --- we use
* TransactionCommandContext which should be safe enough. This
* represents a serious memory leak if many such tuples are processed
* in one command, however. We ought to redesign the representation
matchFound = 0;
if (paramList != NULL)
{
-
/*
* search for an entry in 'paramList' that matches the
* `expression'.
if (!matchFound)
{
-
/*
* ooops! we couldn't find this parameter in the parameter list.
* Signal an error
result = ExecEvalExpr(ntest->arg, econtext, isNull, isDone);
switch (ntest->nulltesttype)
- {
- case IS_NULL:
- if (*isNull)
- {
- *isNull = false;
- return BoolGetDatum(true);
- }
- else
- return BoolGetDatum(false);
- case IS_NOT_NULL:
- if (*isNull)
- {
- *isNull = false;
- return BoolGetDatum(false);
- }
- else
- return BoolGetDatum(true);
- default:
- elog(ERROR, "ExecEvalNullTest: unexpected nulltesttype %d",
- (int) ntest->nulltesttype);
- return (Datum) 0; /* keep compiler quiet */
- }
+ {
+ case IS_NULL:
+ if (*isNull)
+ {
+ *isNull = false;
+ return BoolGetDatum(true);
+ }
+ else
+ return BoolGetDatum(false);
+ case IS_NOT_NULL:
+ if (*isNull)
+ {
+ *isNull = false;
+ return BoolGetDatum(false);
+ }
+ else
+ return BoolGetDatum(true);
+ default:
+ elog(ERROR, "ExecEvalNullTest: unexpected nulltesttype %d",
+ (int) ntest->nulltesttype);
+ return (Datum) 0; /* keep compiler quiet */
+ }
}
/* ----------------------------------------------------------------
result = ExecEvalExpr(btest->arg, econtext, isNull, isDone);
switch (btest->booltesttype)
- {
- case IS_TRUE:
- if (*isNull)
- {
- *isNull = false;
- return BoolGetDatum(false);
- }
- else if (DatumGetBool(result))
- return BoolGetDatum(true);
+ {
+ case IS_TRUE:
+ if (*isNull)
+ {
+ *isNull = false;
+ return BoolGetDatum(false);
+ }
+ else if (DatumGetBool(result))
+ return BoolGetDatum(true);
else
- return BoolGetDatum(false);
- case IS_NOT_TRUE:
- if (*isNull)
- {
- *isNull = false;
- return BoolGetDatum(true);
- }
- else if (DatumGetBool(result))
- return BoolGetDatum(false);
+ return BoolGetDatum(false);
+ case IS_NOT_TRUE:
+ if (*isNull)
+ {
+ *isNull = false;
+ return BoolGetDatum(true);
+ }
+ else if (DatumGetBool(result))
+ return BoolGetDatum(false);
else
- return BoolGetDatum(true);
- case IS_FALSE:
- if (*isNull)
- {
- *isNull = false;
- return BoolGetDatum(false);
- }
- else if (DatumGetBool(result))
- return BoolGetDatum(false);
+ return BoolGetDatum(true);
+ case IS_FALSE:
+ if (*isNull)
+ {
+ *isNull = false;
+ return BoolGetDatum(false);
+ }
+ else if (DatumGetBool(result))
+ return BoolGetDatum(false);
else
- return BoolGetDatum(true);
- case IS_NOT_FALSE:
- if (*isNull)
- {
- *isNull = false;
- return BoolGetDatum(true);
- }
- else if (DatumGetBool(result))
- return BoolGetDatum(true);
+ return BoolGetDatum(true);
+ case IS_NOT_FALSE:
+ if (*isNull)
+ {
+ *isNull = false;
+ return BoolGetDatum(true);
+ }
+ else if (DatumGetBool(result))
+ return BoolGetDatum(true);
else
- return BoolGetDatum(false);
- case IS_UNKNOWN:
- if (*isNull)
- {
- *isNull = false;
- return BoolGetDatum(true);
- }
+ return BoolGetDatum(false);
+ case IS_UNKNOWN:
+ if (*isNull)
+ {
+ *isNull = false;
+ return BoolGetDatum(true);
+ }
else
- return BoolGetDatum(false);
- case IS_NOT_UNKNOWN:
- if (*isNull)
- {
- *isNull = false;
- return BoolGetDatum(false);
- }
+ return BoolGetDatum(false);
+ case IS_NOT_UNKNOWN:
+ if (*isNull)
+ {
+ *isNull = false;
+ return BoolGetDatum(false);
+ }
else
- return BoolGetDatum(true);
- default:
- elog(ERROR, "ExecEvalBooleanTest: unexpected booltesttype %d",
- (int) btest->booltesttype);
- return (Datum) 0; /* keep compiler quiet */
- }
+ return BoolGetDatum(true);
+ default:
+ elog(ERROR, "ExecEvalBooleanTest: unexpected booltesttype %d",
+ (int) btest->booltesttype);
+ return (Datum) 0; /* keep compiler quiet */
+ }
}
/* ----------------------------------------------------------------
break;
case T_NullTest:
retDatum = ExecEvalNullTest((NullTest *) expression,
- econtext,
- isNull,
- isDone);
+ econtext,
+ isNull,
+ isDone);
break;
case T_BooleanTest:
retDatum = ExecEvalBooleanTest((BooleanTest *) expression,
- econtext,
- isNull,
- isDone);
+ econtext,
+ isNull,
+ isDone);
break;
default:
* generating multiple tuples, when one or more tlist items return
* sets. (We expect the caller to call us again if we return:
*
- * isDone = ExprMultipleResult.)
+ * isDone = ExprMultipleResult.)
*/
if (nodomains > NPREALLOCDOMAINS)
{
if (haveDoneSets)
{
-
/*
* note: can't get here unless we verified isDone != NULL
*/
if (*isDone == ExprSingleResult)
{
-
/*
* all sets are done, so report that tlist expansion is
* complete.
}
else
{
-
/*
* We have some done and some undone sets. Restart the done
* ones so that we can deliver a tuple (if possible).
if (itemIsDone[resind] == ExprEndResult)
{
-
/*
* Oh dear, this item is returning an empty
* set. Guess we can't make a tuple after all.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.17 2001/03/22 06:16:12 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.18 2001/10/25 05:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
if (!qual || ExecQual(qual, econtext, false))
{
-
/*
* Found a satisfactory scan tuple.
*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.48 2001/03/22 06:16:12 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.49 2001/10/25 05:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Assert(table != NULL);
/*
- * if our table is full we have to allocate a larger size table.
- * Since ExecAllocTableSlot() is only called before the table is ever
- * used to store tuples, we don't have to worry about the contents of
- * the old table. If this changes, then we will have to preserve the
+ * if our table is full we have to allocate a larger size table. Since
+ * ExecAllocTableSlot() is only called before the table is ever used
+ * to store tuples, we don't have to worry about the contents of the
+ * old table. If this changes, then we will have to preserve the
* contents. -cim 6/23/90
*
* Unfortunately, we *cannot* do this. All of the nodes in the plan that
Buffer buffer,
bool shouldFree)
{
-
/*
* sanity checks
*/
slot->val = (HeapTuple) NULL;
- slot->ttc_shouldFree = true;/* probably useless code... */
+ slot->ttc_shouldFree = true; /* probably useless code... */
/*
* Drop the pin on the referenced buffer, if there is one.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.77 2001/07/16 05:06:58 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.78 2001/10/25 05:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
NTupleReplaced = 0;
NIndexTupleProcessed = 0;
}
-
#endif
/* ----------------------------------------------------------------
(NTupleReplaced == 1) ? "" : "s");
fprintf(statfp, "\n");
}
-
#endif
/* ----------------------------------------------------------------
/*
* Open (and lock, if necessary) the index relation
*
- * If the index AM is not safe for concurrent updates, obtain
- * an exclusive lock on the index to lock out other updaters as
- * well as readers (index_beginscan places AccessShareLock).
- * We will release this lock in ExecCloseIndices.
+ * If the index AM is not safe for concurrent updates, obtain an
+ * exclusive lock on the index to lock out other updaters as well
+ * as readers (index_beginscan places AccessShareLock). We will
+ * release this lock in ExecCloseIndices.
*
* If the index AM supports concurrent updates, we obtain no lock
* here at all, which is a tad weird, but safe since any critical
- * operation on the index (like deleting it) will acquire exclusive
- * lock on the parent table. Perhaps someday we should acquire
- * RowExclusiveLock on the index here?
+ * operation on the index (like deleting it) will acquire
+ * exclusive lock on the parent table. Perhaps someday we should
+ * acquire RowExclusiveLock on the index here?
*
* If there are multiple not-concurrent-safe indexes, all backends
- * must lock the indexes in the same order or we will get deadlocks
- * here during concurrent updates. This is guaranteed by
- * RelationGetIndexList(), which promises to return the index list
- * in OID order.
+ * must lock the indexes in the same order or we will get
+ * deadlocks here during concurrent updates. This is guaranteed
+ * by RelationGetIndexList(), which promises to return the index
+ * list in OID order.
*/
indexDesc = index_open(indexOid);
- if (! indexDesc->rd_am->amconcurrent)
+ if (!indexDesc->rd_am->amconcurrent)
LockRelation(indexDesc, AccessExclusiveLock);
/*
continue;
/* Drop lock, if one was acquired by ExecOpenIndices */
- if (! indexDescs[i]->rd_am->amconcurrent)
+ if (!indexDescs[i]->rd_am->amconcurrent)
UnlockRelation(indexDescs[i], AccessExclusiveLock);
index_close(indexDescs[i]);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.45 2001/03/22 06:16:12 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.46 2001/10/25 05:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
typedef enum
{
- F_EXEC_START, F_EXEC_RUN, F_EXEC_DONE
+ F_EXEC_START, F_EXEC_RUN, F_EXEC_DONE
} ExecStatus;
typedef struct local_es
}
else
{
-
/*
* This is a hack. We assume here that any function returning a
* tuple returns it by reference. This needs to be fixed, since
static void
postquel_start(execution_state *es)
{
-
/*
* Do nothing for utility commands. (create, destroy...) DZ -
* 30-8-1996
if (es->qd->operation == CMD_UTILITY)
{
-
/*
* Process a utility command. (create, destroy...) DZ - 30-8-1996
*/
static void
postquel_end(execution_state *es)
{
-
/*
* Do nothing for utility commands. (create, destroy...) DZ -
* 30-8-1996
*/
if (fcache->returnsTuple)
{
-
/*
* XXX do we need to remove junk attrs from the result tuple?
* Probably OK to leave them, as long as they are at the end.
*/
if (es == (execution_state *) NULL)
{
-
/*
* Reset the execution states to start over again
*/
/*-------------------------------------------------------------------------
*
* instrument.c
- * functions for instrumentation of plan execution
+ * functions for instrumentation of plan execution
*
*
* Copyright (c) 2001, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/instrument.c,v 1.1 2001/09/18 01:59:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/instrument.c,v 1.2 2001/10/25 05:49:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Instrumentation *
InstrAlloc(void)
{
- Instrumentation *instr = palloc( sizeof(Instrumentation) );
+ Instrumentation *instr = palloc(sizeof(Instrumentation));
- memset( instr, 0, sizeof(Instrumentation) );
+ memset(instr, 0, sizeof(Instrumentation));
return instr;
}
InstrStopNode(Instrumentation *instr, bool returnedTuple)
{
struct timeval endtime;
-
+
if (!instr)
return;
elog(DEBUG, "InstrStopNode without start");
return;
}
-
+
gettimeofday(&endtime, NULL);
-
- instr->counter.tv_sec += endtime.tv_sec - instr->starttime.tv_sec;
+
+ instr->counter.tv_sec += endtime.tv_sec - instr->starttime.tv_sec;
instr->counter.tv_usec += endtime.tv_usec - instr->starttime.tv_usec;
/* Normalize after each add to avoid overflow/underflow of tv_usec */
}
/* Finish a run cycle for a plan node */
-void
+void
InstrEndLoop(Instrumentation *instr)
{
- double totaltime;
+ double totaltime;
if (!instr)
return;
/* Accumulate statistics */
totaltime = (double) instr->counter.tv_sec +
- (double) instr->counter.tv_usec / 1000000.0;
+ (double) instr->counter.tv_usec / 1000000.0;
instr->startup += instr->firsttuple;
- instr->total += totaltime;
+ instr->total += totaltime;
instr->ntuples += instr->tuplecount;
instr->nloops += 1;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.77 2001/03/22 06:16:12 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.78 2001/10/25 05:49:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
typedef struct AggStatePerAggData
{
-
/*
* These values are set up during ExecInitAgg() and do not change
* thereafter:
*/
if (aggref->aggdistinct)
{
-
/*
* In case of rescan, maybe there could be an uncompleted sort
* operation? Clean it up if so.
{
if (isNull)
{
-
/*
* For a strict transfn, nothing happens at a NULL input
* tuple; we just keep the prior transValue. However, if the
}
if (peraggstate->noTransValue)
{
-
/*
* transValue has not been initialized. This is the first
* non-NULL input value. We use it as the initial value for
}
if (peraggstate->transValueIsNull)
{
-
/*
* Don't call a strict function with NULL inputs. Note it is
* possible to get here despite the above tests, if the
while (tuplesort_getdatum(peraggstate->sortstate, true,
&newVal, &isNull))
{
-
/*
* DISTINCT always suppresses nulls, per SQL spec, regardless of
* the transition function's strictness.
finalize_aggregate(AggStatePerAgg peraggstate,
Datum *resultVal, bool *resultIsNull)
{
-
/*
* Apply the agg's finalfn if one is provided, else return transValue.
*/
aggstate->numaggs = numaggs = length(aggstate->aggs);
if (numaggs <= 0)
{
-
/*
* This used to be treated as an error, but we can't do that
* anymore because constant-expression simplification could
*/
if (peraggstate->transfn.fn_strict && peraggstate->initValueIsNull)
{
-
/*
* Note: use the type from the input expression here, not
* aggform->aggbasetype, because the latter might be 0.
if (aggref->aggdistinct)
{
-
/*
* Note: use the type from the input expression here, not
* aggform->aggbasetype, because the latter might be 0.
ExecCountSlotsAgg(Agg *node)
{
return ExecCountSlotsNode(outerPlan(node)) +
- ExecCountSlotsNode(innerPlan(node)) +
- AGG_NSLOTS;
+ ExecCountSlotsNode(innerPlan(node)) +
+ AGG_NSLOTS;
}
void
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.42 2001/05/15 00:33:36 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.43 2001/10/25 05:49:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (whichplan < appendstate->as_firstplan)
{
-
/*
* if scanning in reverse, we start at the last scan in the list
* and then proceed back to the first.. in any case we inform
}
else if (whichplan > appendstate->as_lastplan)
{
-
/*
* as above, end the scan if we go beyond the last scan in our
* list..
}
else
{
-
/*
* initialize the scan
*
node->appendstate = appendstate;
/*
- * Do we want to scan just one subplan? (Special case for EvalPlanQual)
- * XXX pretty dirty way of determining that this case applies ...
+ * Do we want to scan just one subplan? (Special case for
+ * EvalPlanQual) XXX pretty dirty way of determining that this case
+ * applies ...
*/
if (node->isTarget && estate->es_evTuple != NULL)
{
- int tplan;
+ int tplan;
tplan = estate->es_result_relation_info - estate->es_result_relations;
Assert(tplan >= 0 && tplan < nplans);
if (!TupIsNull(result))
{
-
/*
* if the subplan gave us something then place a copy of whatever
* we get into our result slot and return it.
}
else
{
-
/*
* .. go on to the "next" subplan in the appropriate direction and
* try processing again (recursively)
Plan *subnode;
subnode = (Plan *) nth(i, node->appendplans);
+
/*
* ExecReScan doesn't know about my subplans, so I have to do
* changed-parameter signaling myself.
*/
if (node->plan.chgParam != NULL)
SetChangedParamList(subnode, node->plan.chgParam);
+
/*
- * if chgParam of subnode is not null then plan will be re-scanned by
- * first ExecProcNode.
+ * if chgParam of subnode is not null then plan will be re-scanned
+ * by first ExecProcNode.
*/
if (subnode->chgParam == NULL)
{
* locate group boundaries.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.43 2001/03/22 06:16:12 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.44 2001/10/25 05:49:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
else
{
-
/*
* Compare with first tuple and see if this tuple is of the
* same group.
grpstate->eqfunctions,
econtext->ecxt_per_tuple_memory))
{
-
/*
* No; save the tuple to return it next time, and return
* NULL
* Look up the equality functions needed for execTuplesMatch.
* The result is a palloc'd array.
*/
-FmgrInfo *
+FmgrInfo *
execTuplesMatchPrepare(TupleDesc tupdesc,
int numCols,
AttrNumber *matchColIdx)
* Portions Copyright (c) 1994, Regents of the University of California
*
*
- * $Id: nodeHash.c,v 1.59 2001/08/13 19:50:11 tgl Exp $
+ * $Id: nodeHash.c,v 1.60 2001/10/25 05:49:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (nbatch > 0)
{
-
/*
* Open temp files for inner batches, if needed. Note that file
* buffers are palloc'd in regular executor context.
ExecCountSlotsHash(Hash *node)
{
return ExecCountSlotsNode(outerPlan(node)) +
- ExecCountSlotsNode(innerPlan(node)) +
- HASH_NSLOTS;
+ ExecCountSlotsNode(innerPlan(node)) +
+ HASH_NSLOTS;
}
/* ---------------------------------------------------------------
if (nbatch > 0)
{
-
/*
* allocate and initialize the file arrays in hashCxt
*/
*/
if (bucketno < hashtable->nbuckets)
{
-
/*
* put the tuple in hash table
*/
}
else
{
-
/*
* put the tuple into a tmp file for other batches
*/
MemoryContext oldContext;
/*
- * We reset the eval context each time to reclaim any memory leaked
- * in the hashkey expression or hashFunc itself.
+ * We reset the eval context each time to reclaim any memory leaked in
+ * the hashkey expression or hashFunc itself.
*/
ResetExprContext(econtext);
else
{
/*
- * If this is a variable length type, then 'key' points to a "struct
- * varlena" and len == -1. NOTE: VARSIZE returns the "real" data
- * length plus the sizeof the "vl_len" attribute of varlena (the
- * length information). 'key' points to the beginning of the varlena
- * struct, so we have to use "VARDATA" to find the beginning of
- * the "real" data. Also, we have to be careful to detoast the
- * datum if it's toasted. (We don't worry about freeing the detoasted
- * copy; that happens for free when the per-tuple memory context
- * is reset in ExecHashGetBucket.)
+ * If this is a variable length type, then 'key' points to a
+ * "struct varlena" and len == -1. NOTE: VARSIZE returns the
+ * "real" data length plus the sizeof the "vl_len" attribute of
+ * varlena (the length information). 'key' points to the beginning
+ * of the varlena struct, so we have to use "VARDATA" to find the
+ * beginning of the "real" data. Also, we have to be careful to
+ * detoast the datum if it's toasted. (We don't worry about
+ * freeing the detoasted copy; that happens for free when the
+ * per-tuple memory context is reset in ExecHashGetBucket.)
*/
unsigned char *k;
void
ExecReScanHash(Hash *node, ExprContext *exprCtxt, Plan *parent)
{
-
/*
* if chgParam of subnode is not null then plan will be re-scanned by
* first ExecProcNode.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.38 2001/03/22 06:16:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.39 2001/10/25 05:49:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
for (;;)
{
-
/*
* If we don't have an outer tuple, get the next one
*/
hjstate);
if (TupIsNull(outerTupleSlot))
{
-
/*
* when the last batch runs out, clean up and exit
*/
if (batch > 0)
{
-
/*
* Need to postpone this outer tuple to a later batch.
* Save it in the corresponding outer-batch file.
if (!hjstate->hj_MatchedOuter &&
node->join.jointype == JOIN_LEFT)
{
-
/*
* We are doing an outer join and there were no join matches
* for this outer tuple. Generate a fake join tuple with
if (ExecQual(otherqual, econtext, false))
{
-
/*
* qualification was satisfied so we project and return
* the slot containing the result tuple using
ExecCountSlotsHashJoin(HashJoin *node)
{
return ExecCountSlotsNode(outerPlan(node)) +
- ExecCountSlotsNode(innerPlan(node)) +
- HASHJOIN_NSLOTS;
+ ExecCountSlotsNode(innerPlan(node)) +
+ HASHJOIN_NSLOTS;
}
/* ----------------------------------------------------------------
if (newbatch > 1)
{
-
/*
* We no longer need the previous outer batch file; close it right
* away to free disk space.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.62 2001/07/15 22:48:17 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.63 2001/10/25 05:49:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
qual = lnext(qual);
}
if (!prev_matches)
- return slot;/* OK to return tuple */
+ return slot; /* OK to return tuple */
/* Duplicate tuple, so drop it and loop back for another */
ExecClearTuple(slot);
}
if (econtext)
{
-
/*
* If we are being passed an outer tuple, save it for runtime key
* calc
run_keys = runtimeKeyInfo[i];
for (j = 0; j < n_keys; j++)
{
-
/*
* If we have a run-time key, then extract the run-time
* expression and evaluate it with respect to the current
Expr *clause; /* one clause of index qual */
Oper *op; /* operator used in clause */
Node *leftop; /* expr on lhs of operator */
- Node *rightop;/* expr on rhs ... */
+ Node *rightop; /* expr on rhs ... */
bits16 flags = 0;
- int scanvar;/* which var identifies varattno */
+ int scanvar; /* which var identifies varattno */
AttrNumber varattno = 0; /* att number used in scan */
Oid opid; /* operator id used in scan */
Datum scanvalue = 0; /* value used in scan (if const) */
if (IsA(leftop, Var) &&var_is_rel((Var *) leftop))
{
-
/*
* if the leftop is a "rel-var", then it means that it is
* a var node which tells us which attribute to use for
}
else if (IsA(leftop, Const))
{
-
/*
* if the leftop is a const node then it means it
* identifies the value to place in our scan key.
}
else
{
-
/*
* otherwise, the leftop contains an expression evaluable
* at runtime to figure out the value to place in our scan
if (IsA(rightop, Var) &&var_is_rel((Var *) rightop))
{
-
/*
* here we make sure only one op identifies the
* scan-attribute...
}
else if (IsA(rightop, Const))
{
-
/*
* if the rightop is a const node then it means it
* identifies the value to place in our scan key.
}
else
{
-
/*
* otherwise, the rightop contains an expression evaluable
* at runtime to figure out the value to place in our scan
ExecOpenScanR(indexOid, /* relation */
numScanKeys[i], /* nkeys */
scanKeys[i], /* scan key */
- true, /* is index */
+ true, /* is index */
direction, /* scan direction */
estate->es_snapshot,
&(relationDescs[i]), /* return: rel desc */
ExecCountSlotsIndexScan(IndexScan *node)
{
return ExecCountSlotsNode(outerPlan((Plan *) node)) +
- ExecCountSlotsNode(innerPlan((Plan *) node)) + INDEXSCAN_NSLOTS;
+ ExecCountSlotsNode(innerPlan((Plan *) node)) + INDEXSCAN_NSLOTS;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeLimit.c,v 1.7 2001/08/06 18:05:07 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeLimit.c,v 1.8 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
for (;;)
{
-
/*
* If we have reached the subplan EOF or the limit, just quit.
*
* here is for position > netlimit not position >= netlimit.
*
* Similarly, when scanning backwards, we must re-fetch the last
- * tuple in the offset region before we can return NULL.
- * Otherwise we won't be correctly aligned to start going forward
- * again. So, although you might think we can quit when position
- * equals offset + 1, we have to fetch a subplan tuple first, and
- * then exit when position = offset.
+ * tuple in the offset region before we can return NULL. Otherwise
+ * we won't be correctly aligned to start going forward again.
+ * So, although you might think we can quit when position equals
+ * offset + 1, we have to fetch a subplan tuple first, and then
+ * exit when position = offset.
*/
if (ScanDirectionIsForward(direction))
{
slot = ExecProcNode(outerPlan, (Plan *) node);
if (TupIsNull(slot))
{
-
/*
* We are at start or end of the subplan. Update local state
* appropriately, but always return NULL.
ExecCountSlotsLimit(Limit *node)
{
return ExecCountSlotsNode(outerPlan(node)) +
- ExecCountSlotsNode(innerPlan(node)) +
- LIMIT_NSLOTS;
+ ExecCountSlotsNode(innerPlan(node)) +
+ LIMIT_NSLOTS;
}
/* ----------------------------------------------------------------
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.36 2001/05/27 20:42:19 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.37 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
ExecCountSlotsMaterial(Material *node)
{
return ExecCountSlotsNode(outerPlan((Plan *) node)) +
- ExecCountSlotsNode(innerPlan((Plan *) node)) +
- MATERIAL_NSLOTS;
+ ExecCountSlotsNode(innerPlan((Plan *) node)) +
+ MATERIAL_NSLOTS;
}
/* ----------------------------------------------------------------
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.45 2001/03/23 04:49:53 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.46 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
foreach(qualcdr, qualCopy)
{
-
/*
* first get the current (op .. ..) list
*/
printf("******** \n");
}
-
#endif
/* ----------------------------------------------------------------
default:
elog(ERROR, "ExecMergeJoin: unsupported join type %d",
(int) node->join.jointype);
- doFillOuter = false;/* keep compiler quiet */
+ doFillOuter = false; /* keep compiler quiet */
doFillInner = false;
break;
}
*/
for (;;)
{
-
/*
* get the current state of the join and do things accordingly.
* Note: The join states are highlighted with 32-* comments for
switch (mergestate->mj_JoinState)
{
-
/*
* EXEC_MJ_INITIALIZE means that this is the first time
* ExecMergeJoin() has been called and so we have to fetch
MJ_printf("ExecMergeJoin: outer subplan is empty\n");
if (doFillInner)
{
-
/*
* Need to emit right-join tuples for remaining
* inner tuples. We set MatchedInner = true to
MJ_printf("ExecMergeJoin: inner subplan is empty\n");
if (doFillOuter)
{
-
/*
* Need to emit left-join tuples for all outer
* tuples, including the one we just fetched. We
if (qualResult)
{
-
/*
* qualification succeeded. now form the desired
* projection tuple and return the slot containing
if (doFillInner && !mergestate->mj_MatchedInner)
{
-
/*
* Generate a fake join tuple with nulls for the outer
* tuple, and return it if it passes the non-join
if (ExecQual(otherqual, econtext, false))
{
-
/*
* qualification succeeded. now form the desired
* projection tuple and return the slot containing
if (doFillOuter && !mergestate->mj_MatchedOuter)
{
-
/*
* Generate a fake join tuple with nulls for the inner
* tuple, and return it if it passes the non-join
if (ExecQual(otherqual, econtext, false))
{
-
/*
* qualification succeeded. now form the desired
* projection tuple and return the slot containing
innerTupleSlot = mergestate->mj_InnerTupleSlot;
if (doFillInner && !TupIsNull(innerTupleSlot))
{
-
/*
* Need to emit right-join tuples for remaining
* inner tuples.
if (qualResult)
{
-
/*
* the merge clause matched so now we restore the
* inner scan position to the first mark, and loop
{
if (doFillOuter)
{
-
/*
* Need to emit left-join tuples for remaining
* outer tuples.
if (doFillOuter && !mergestate->mj_MatchedOuter)
{
-
/*
* Generate a fake join tuple with nulls for the inner
* tuple, and return it if it passes the non-join
if (ExecQual(otherqual, econtext, false))
{
-
/*
* qualification succeeded. now form the desired
* projection tuple and return the slot containing
innerTupleSlot = mergestate->mj_InnerTupleSlot;
if (doFillInner && !TupIsNull(innerTupleSlot))
{
-
/*
* Need to emit right-join tuples for remaining
* inner tuples.
if (doFillInner && !mergestate->mj_MatchedInner)
{
-
/*
* Generate a fake join tuple with nulls for the outer
* tuple, and return it if it passes the non-join
if (ExecQual(otherqual, econtext, false))
{
-
/*
* qualification succeeded. now form the desired
* projection tuple and return the slot containing
outerTupleSlot = mergestate->mj_OuterTupleSlot;
if (doFillOuter && !TupIsNull(outerTupleSlot))
{
-
/*
* Need to emit left-join tuples for remaining
* outer tuples.
if (!mergestate->mj_MatchedInner)
{
-
/*
* Generate a fake join tuple with nulls for the outer
* tuple, and return it if it passes the non-join
if (ExecQual(otherqual, econtext, false))
{
-
/*
* qualification succeeded. now form the desired
* projection tuple and return the slot containing
if (!mergestate->mj_MatchedOuter)
{
-
/*
* Generate a fake join tuple with nulls for the inner
* tuple, and return it if it passes the non-join
if (ExecQual(otherqual, econtext, false))
{
-
/*
* qualification succeeded. now form the desired
* projection tuple and return the slot containing
ExecCountSlotsMergeJoin(MergeJoin *node)
{
return ExecCountSlotsNode(outerPlan((Plan *) node)) +
- ExecCountSlotsNode(innerPlan((Plan *) node)) +
- MERGEJOIN_NSLOTS;
+ ExecCountSlotsNode(innerPlan((Plan *) node)) +
+ MERGEJOIN_NSLOTS;
}
/* ----------------------------------------------------------------
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.24 2001/03/22 06:16:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.25 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
for (;;)
{
-
/*
* If we don't have an outer tuple, get the next one and reset the
* inner scan.
if (!nlstate->nl_MatchedOuter &&
node->join.jointype == JOIN_LEFT)
{
-
/*
* We are doing an outer join and there were no join
* matches for this outer tuple. Generate a fake join
if (ExecQual(otherqual, econtext, false))
{
-
/*
* qualification was satisfied so we project and
* return the slot containing the result tuple using
if (otherqual == NIL || ExecQual(otherqual, econtext, false))
{
-
/*
* qualification was satisfied so we project and return
* the slot containing the result tuple using
ExecCountSlotsNestLoop(NestLoop *node)
{
return ExecCountSlotsNode(outerPlan(node)) +
- ExecCountSlotsNode(innerPlan(node)) +
- NESTLOOP_NSLOTS;
+ ExecCountSlotsNode(innerPlan(node)) +
+ NESTLOOP_NSLOTS;
}
/* ----------------------------------------------------------------
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.19 2001/03/22 06:16:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.20 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (outerPlan != NULL)
{
-
/*
* retrieve tuples from the outer plan until there are no
* more.
}
else
{
-
/*
* if we don't have an outer plan, then we are just generating
* the results from a constant target list. Do it only once.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.31 2001/07/15 22:48:18 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.32 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
TupleTableSlot *
ExecSeqScan(SeqScan *node)
{
-
/*
* use SeqNext as access method
*/
ExecCountSlotsSeqScan(SeqScan *node)
{
return ExecCountSlotsNode(outerPlan(node)) +
- ExecCountSlotsNode(innerPlan(node)) +
- SEQSCAN_NSLOTS;
+ ExecCountSlotsNode(innerPlan(node)) +
+ SEQSCAN_NSLOTS;
}
/* ----------------------------------------------------------------
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeSetOp.c,v 1.4 2001/03/22 06:16:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeSetOp.c,v 1.5 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (TupIsNull(resultTupleSlot))
{
-
/*
* First of group: save a copy in result slot, and reset
* duplicate-counters for new group.
}
else if (setopstate->subplan_done)
{
-
/*
* Reached end of input, so finish processing final group
*/
}
else
{
-
/*
* Else test if the new tuple and the previously saved tuple
* match.
if (endOfGroup)
{
-
/*
* We've reached the end of the group containing resultTuple.
* Decide how many copies (if any) to emit. This logic is
}
else
{
-
/*
* Current tuple is member of same group as resultTuple. Count
* it in the appropriate counter.
ExecCountSlotsSetOp(SetOp *node)
{
return ExecCountSlotsNode(outerPlan(node)) +
- ExecCountSlotsNode(innerPlan(node)) +
- SETOP_NSLOTS;
+ ExecCountSlotsNode(innerPlan(node)) +
+ SETOP_NSLOTS;
}
/* ----------------------------------------------------------------
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.34 2001/05/27 20:42:19 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.35 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
ExecCountSlotsSort(Sort *node)
{
return ExecCountSlotsNode(outerPlan((Plan *) node)) +
- ExecCountSlotsNode(innerPlan((Plan *) node)) +
- SORT_NSLOTS;
+ ExecCountSlotsNode(innerPlan((Plan *) node)) +
+ SORT_NSLOTS;
}
/* ----------------------------------------------------------------
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.31 2001/09/18 01:59:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.32 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (!found)
{
-
/*
* deal with empty subplan result. result/isNull were previously
* initialized correctly for all sublink types except EXPR and
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.10 2001/09/18 01:59:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.11 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
direction = estate->es_direction;
/*
- * We need not support EvalPlanQual here, since we are not scanning
- * a real relation.
+ * We need not support EvalPlanQual here, since we are not scanning a
+ * real relation.
*/
/*
TupleTableSlot *
ExecSubqueryScan(SubqueryScan *node)
{
-
/*
* use SubqueryNext as access method
*/
* The subplan has its own tuple table and must not be counted here!
*/
return ExecCountSlotsNode(outerPlan(node)) +
- ExecCountSlotsNode(innerPlan(node)) +
- SUBQUERYSCAN_NSLOTS;
+ ExecCountSlotsNode(innerPlan(node)) +
+ SUBQUERYSCAN_NSLOTS;
}
/* ----------------------------------------------------------------
*/
if (node->scan.plan.chgParam != NULL)
SetChangedParamList(node->subplan, node->scan.plan.chgParam);
+
/*
* if chgParam of subnode is not null then plan will be re-scanned by
* first ExecProcNode.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.19 2001/09/29 07:57:06 inoue Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.20 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "access/heapam.h"
#include "parser/parsetree.h"
-static int TidListCreate(List *, ExprContext *, ItemPointerData []);
+static int TidListCreate(List *, ExprContext *, ItemPointerData[]);
static TupleTableSlot *TidNext(TidScan *node);
static int
bool bBackward;
int tidNumber;
- ItemPointerData* tidList;
+ ItemPointerData *tidList;
/*
* extract necessary information from tid scan node
TupleTableSlot *
ExecTidScan(TidScan *node)
{
-
/*
* use TidNext as access method
*/
{
EState *estate;
TidScanState *tidstate;
- ItemPointerData* tidList;
+ ItemPointerData *tidList;
tidstate = node->tidstate;
estate = node->scan.plan.state;
tidstate = node->tidstate;
tidstate->tss_TidPtr = tidstate->tss_MarkTidPtr;
}
-
#endif
/* ----------------------------------------------------------------
{
TidScanState *tidstate;
CommonScanState *scanstate;
- ItemPointerData* tidList;
+ ItemPointerData *tidList;
int numTids;
int tidPtr;
List *rangeTable;
ExecCountSlotsTidScan(TidScan *node)
{
return ExecCountSlotsNode(outerPlan((Plan *) node)) +
- ExecCountSlotsNode(innerPlan((Plan *) node)) + TIDSCAN_NSLOTS;
+ ExecCountSlotsNode(innerPlan((Plan *) node)) + TIDSCAN_NSLOTS;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.32 2001/03/22 06:16:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.33 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
for (;;)
{
-
/*
* fetch a tuple from the outer subplan
*/
ExecCountSlotsUnique(Unique *node)
{
return ExecCountSlotsNode(outerPlan(node)) +
- ExecCountSlotsNode(innerPlan(node)) +
- UNIQUE_NSLOTS;
+ ExecCountSlotsNode(innerPlan(node)) +
+ UNIQUE_NSLOTS;
}
/* ----------------------------------------------------------------
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.59 2001/10/23 17:38:25 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.60 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Datum *Values, char *Nulls, int tcount);
static void _SPI_cursor_operation(Portal portal, bool forward, int count,
- CommandDest dest);
+ CommandDest dest);
static _SPI_plan *_SPI_copy_plan(_SPI_plan *plan, int location);
extern int ShowExecutorStats;
extern void ResetUsage(void);
extern void ShowUsage(void);
-
#endif
/* =================== interface functions =================== */
int
SPI_freeplan(void *plan)
{
- _SPI_plan *spiplan = (_SPI_plan *)plan;
+ _SPI_plan *spiplan = (_SPI_plan *) plan;
if (plan == NULL)
return SPI_ERROR_ARGUMENT;
return res + 1;
}
- sysatt = SystemAttributeByName(fname, true /* "oid" will be accepted */);
+ sysatt = SystemAttributeByName(fname, true /* "oid" will be accepted */ );
if (sysatt != NULL)
return sysatt->attnum;
Portal
SPI_cursor_open(char *name, void *plan, Datum *Values, char *Nulls)
{
- static int unnamed_portal_count = 0;
-
- _SPI_plan *spiplan = (_SPI_plan *)plan;
- List *qtlist = spiplan->qtlist;
- List *ptlist = spiplan->ptlist;
- Query *queryTree;
- Plan *planTree;
- QueryDesc *queryDesc;
- EState *eState;
- TupleDesc attinfo;
- MemoryContext oldcontext;
- Portal portal;
- char portalname[64];
- int k;
+ static int unnamed_portal_count = 0;
+
+ _SPI_plan *spiplan = (_SPI_plan *) plan;
+ List *qtlist = spiplan->qtlist;
+ List *ptlist = spiplan->ptlist;
+ Query *queryTree;
+ Plan *planTree;
+ QueryDesc *queryDesc;
+ EState *eState;
+ TupleDesc attinfo;
+ MemoryContext oldcontext;
+ Portal portal;
+ char portalname[64];
+ int k;
/* Ensure that the plan contains only one regular SELECT query */
if (length(ptlist) != 1)
elog(ERROR, "cannot open multi-query plan as cursor");
- queryTree = (Query *)lfirst(qtlist);
- planTree = (Plan *)lfirst(ptlist);
+ queryTree = (Query *) lfirst(qtlist);
+ planTree = (Plan *) lfirst(ptlist);
if (queryTree->commandType != CMD_SELECT)
elog(ERROR, "plan in SPI_cursor_open() is not a SELECT");
{
for (;;)
{
- unnamed_portal_count++;
+ unnamed_portal_count++;
if (unnamed_portal_count < 0)
unnamed_portal_count = 0;
sprintf(portalname, "", unnamed_portal_count);
/* Switch to portals memory and copy the parsetree and plan to there */
oldcontext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
- queryTree = copyObject(queryTree);
- planTree = copyObject(planTree);
+ queryTree = copyObject(queryTree);
+ planTree = copyObject(planTree);
/* Modify the parsetree to be a cursor */
queryTree->isPortal = true;
- queryTree->into = pstrdup(name);
+ queryTree->into = pstrdup(name);
queryTree->isBinary = false;
-
+
/* Create the QueryDesc object and the executor state */
queryDesc = CreateQueryDesc(queryTree, planTree, SPI);
- eState = CreateExecutorState();
+ eState = CreateExecutorState();
/* If the plan has parameters, put them into the executor state */
if (spiplan->nargs > 0)
{
- ParamListInfo paramLI = (ParamListInfo) palloc((spiplan->nargs + 1) *
- sizeof(ParamListInfoData));
+ ParamListInfo paramLI = (ParamListInfo) palloc((spiplan->nargs + 1) *
+ sizeof(ParamListInfoData));
+
eState->es_param_list_info = paramLI;
for (k = 0; k < spiplan->nargs; paramLI++, k++)
{
- paramLI->kind = PARAM_NUM;
- paramLI->id = k + 1;
- paramLI->isnull = (Nulls && Nulls[k] == 'n');
- paramLI->value = Values[k];
+ paramLI->kind = PARAM_NUM;
+ paramLI->id = k + 1;
+ paramLI->isnull = (Nulls && Nulls[k] == 'n');
+ paramLI->value = Values[k];
}
paramLI->kind = PARAM_INVALID;
}
tuptable->vals = (HeapTuple *) palloc(tuptable->alloced * sizeof(HeapTuple));
tuptable->tupdesc = CreateTupleDescCopy(tupdesc);
}
- else
+ else
{
MemoryContextSwitchTo(tuptable->tuptabcxt);
tuptable->free = 256;
tuptable->alloced += tuptable->free;
tuptable->vals = (HeapTuple *) repalloc(tuptable->vals,
- tuptable->alloced * sizeof(HeapTuple));
+ tuptable->alloced * sizeof(HeapTuple));
}
}
*/
static void
_SPI_cursor_operation(Portal portal, bool forward, int count,
- CommandDest dest)
+ CommandDest dest)
{
- QueryDesc *querydesc;
- EState *estate;
- MemoryContext oldcontext;
- CommandDest olddest;
+ QueryDesc *querydesc;
+ EState *estate;
+ MemoryContext oldcontext;
+ CommandDest olddest;
/* Check that the portal is valid */
if (!PortalIsValid(portal))
/* Switch to the portals memory context */
oldcontext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
- querydesc = PortalGetQueryDesc(portal);
- estate = PortalGetState(portal);
+ querydesc = PortalGetQueryDesc(portal);
+ estate = PortalGetState(portal);
/* Save the queries command destination and set it to SPI (for fetch) */
/* or None (for move) */
{
if (!portal->atEnd)
{
- ExecutorRun(querydesc, estate, EXEC_FOR, (long)count);
+ ExecutorRun(querydesc, estate, EXEC_FOR, (long) count);
_SPI_current->processed = estate->es_processed;
if (estate->es_processed > 0)
portal->atStart = false;
/* Put the result into place for access by caller */
SPI_processed = _SPI_current->processed;
- SPI_tuptable = _SPI_current->tuptable;
+ SPI_tuptable = _SPI_current->tuptable;
/* Pop the SPI stack */
_SPI_end_call(true);
static int
_SPI_end_call(bool procmem)
{
-
/*
* We' returning to procedure where _SPI_curid == _SPI_connected - 1
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/lib/Attic/bit.c,v 1.13 2001/03/22 03:59:29 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/lib/Attic/bit.c,v 1.14 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
BitArraySetBit(BitArray bitArray, BitIndex bitIndex)
{
bitArray[bitIndex / BITS_PER_BYTE] |=
- (1 << (BITS_PER_BYTE - 1 - (bitIndex % BITS_PER_BYTE)));
+ (1 << (BITS_PER_BYTE - 1 - (bitIndex % BITS_PER_BYTE)));
}
void
BitArrayClearBit(BitArray bitArray, BitIndex bitIndex)
{
bitArray[bitIndex / BITS_PER_BYTE] &=
- ~(1 << (BITS_PER_BYTE - 1 - (bitIndex % BITS_PER_BYTE)));
+ ~(1 << (BITS_PER_BYTE - 1 - (bitIndex % BITS_PER_BYTE)));
}
bool
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/lib/Attic/lispsort.c,v 1.14 2001/01/24 19:42:55 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/lib/Attic/lispsort.c,v 1.15 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
return output;
}
-
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: stringinfo.c,v 1.28 2001/03/22 06:16:13 momjian Exp $
+ * $Id: stringinfo.c,v 1.29 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
for (;;)
{
-
/*
* Try to format the given string into the available space; but if
* there's hardly any space, don't bother trying, just fall
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.69 2001/10/18 22:44:37 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.70 2001/10/25 05:49:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifdef USE_PAM
#include
-
-#define PGSQL_PAM_SERVICE "postgresql" /* Service name passed to PAM */
-static int CheckPAMAuth(Port *port, char *user, char *password);
-static int pam_passwd_conv_proc(int num_msg, const struct pam_message **msg,
- struct pam_response **resp, void *appdata_ptr);
+#define PGSQL_PAM_SERVICE "postgresql" /* Service name passed to PAM */
+
+static int CheckPAMAuth(Port *port, char *user, char *password);
+static int pam_passwd_conv_proc(int num_msg, const struct pam_message ** msg,
+ struct pam_response ** resp, void *appdata_ptr);
static struct pam_conv pam_passw_conv = {
- &pam_passwd_conv_proc,
- NULL
+ &pam_passwd_conv_proc,
+ NULL
};
-static char * pam_passwd = NULL; /* Workaround for Solaris 2.6 brokenness */
-static Port * pam_port_cludge; /* Workaround for passing "Port
- * *port" into pam_passwd_conv_proc */
-#endif /* USE_PAM */
+static char *pam_passwd = NULL; /* Workaround for Solaris 2.6 brokenness */
+static Port *pam_port_cludge; /* Workaround for passing "Port *port"
+ * into pam_passwd_conv_proc */
+#endif /* USE_PAM */
#ifdef KRB4
/*----------------------------------------------------------------
const char *authmethod = "Unknown auth method:";
/*
- * If we failed due to EOF from client, just quit; there's no point
- * in trying to send a message to the client, and not much point in
+ * If we failed due to EOF from client, just quit; there's no point in
+ * trying to send a message to the client, and not much point in
* logging the failure in the postmaster log. (Logging the failure
* might be desirable, were it not for the fact that libpq closes the
* connection unceremoniously if challenged for a password when it
- * hasn't got one to send. We'll get a useless log entry for
- * every psql connection under password auth, even if it's perfectly
+ * hasn't got one to send. We'll get a useless log entry for every
+ * psql connection under password auth, even if it's perfectly
* successful, if we log STATUS_EOF events.)
*/
if (status == STATUS_EOF)
case uaPAM:
authmethod = "PAM";
break;
-#endif /* USE_PAM */
+#endif /* USE_PAM */
}
elog(FATAL, "%s authentication failed for user \"%s\"",
void
ClientAuthentication(Port *port)
{
- int status = STATUS_ERROR;
+ int status = STATUS_ERROR;
/*
* Get the authentication method to use for this frontend/database
switch (port->auth_method)
{
case uaReject:
- /*
- * This could have come from an explicit "reject" entry in
- * pg_hba.conf, but more likely it means there was no
- * matching entry. Take pity on the poor user and issue a
- * helpful error message. NOTE: this is not a security
- * breach, because all the info reported here is known at
- * the frontend and must be assumed known to bad guys.
- * We're merely helping out the less clueful good guys.
- */
- {
- const char *hostinfo = "localhost";
- if (port->raddr.sa.sa_family == AF_INET)
- hostinfo = inet_ntoa(port->raddr.in.sin_addr);
- elog(FATAL,
- "No pg_hba.conf entry for host %s, user %s, database %s",
- hostinfo, port->user, port->database);
- break;
- }
+ /*
+ * This could have come from an explicit "reject" entry in
+ * pg_hba.conf, but more likely it means there was no matching
+ * entry. Take pity on the poor user and issue a helpful
+ * error message. NOTE: this is not a security breach,
+ * because all the info reported here is known at the frontend
+ * and must be assumed known to bad guys. We're merely helping
+ * out the less clueful good guys.
+ */
+ {
+ const char *hostinfo = "localhost";
+
+ if (port->raddr.sa.sa_family == AF_INET)
+ hostinfo = inet_ntoa(port->raddr.in.sin_addr);
+ elog(FATAL,
+ "No pg_hba.conf entry for host %s, user %s, database %s",
+ hostinfo, port->user, port->database);
+ break;
+ }
case uaKrb4:
sendAuthRequest(port, AUTH_REQ_KRB4);
case uaIdent:
#if !defined(SO_PEERCRED) && (defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS)))
+
/*
- * If we are doing ident on unix-domain sockets,
- * use SCM_CREDS only if it is defined and SO_PEERCRED isn't.
+ * If we are doing ident on unix-domain sockets, use SCM_CREDS
+ * only if it is defined and SO_PEERCRED isn't.
*/
#if defined(HAVE_STRUCT_FCRED) || defined(HAVE_STRUCT_SOCKCRED)
+
/*
- * Receive credentials on next message receipt, BSD/OS, NetBSD.
- * We need to set this before the client sends the next packet.
+ * Receive credentials on next message receipt, BSD/OS,
+ * NetBSD. We need to set this before the client sends the
+ * next packet.
*/
{
- int on = 1;
+ int on = 1;
+
if (setsockopt(port->sock, 0, LOCAL_CREDS, &on, sizeof(on)) < 0)
elog(FATAL,
"pg_local_sendauth: can't do setsockopt: %s\n", strerror(errno));
}
#endif
- if (port->raddr.sa.sa_family == AF_UNIX)
+ if (port->raddr.sa.sa_family == AF_UNIX)
sendAuthRequest(port, AUTH_REQ_SCM_CREDS);
#endif
status = authident(port);
case uaCrypt:
sendAuthRequest(port, AUTH_REQ_CRYPT);
status = recv_and_check_password_packet(port);
- break;
-
+ break;
+
case uaPassword:
sendAuthRequest(port, AUTH_REQ_PASSWORD);
status = recv_and_check_password_packet(port);
pam_port_cludge = port;
status = CheckPAMAuth(port, port->user, "");
break;
-#endif /* USE_PAM */
+#endif /* USE_PAM */
case uaTrust:
status = STATUS_OK;
/* Add the salt for encrypted passwords. */
if (areq == AUTH_REQ_MD5)
- {
pq_sendbytes(&buf, port->md5Salt, 4);
- }
else if (areq == AUTH_REQ_CRYPT)
- {
pq_sendbytes(&buf, port->cryptSalt, 2);
- }
pq_endmessage(&buf);
pq_flush();
*/
static int
-pam_passwd_conv_proc (int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr)
+pam_passwd_conv_proc(int num_msg, const struct pam_message ** msg, struct pam_response ** resp, void *appdata_ptr)
{
StringInfoData buf;
- int32 len;
+ int32 len;
- if (num_msg != 1 || msg[0]->msg_style != PAM_PROMPT_ECHO_OFF) {
- switch(msg[0]->msg_style) {
+ if (num_msg != 1 || msg[0]->msg_style != PAM_PROMPT_ECHO_OFF)
+ {
+ switch (msg[0]->msg_style)
+ {
case PAM_ERROR_MSG:
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pam_passwd_conv_proc: Error from underlying PAM layer: '%s'\n", msg[0]->msg);
+ snprintf(PQerrormsg, PQERRORMSG_LENGTH,
+ "pam_passwd_conv_proc: Error from underlying PAM layer: '%s'\n", msg[0]->msg);
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
return PAM_CONV_ERR;
default:
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pam_passwd_conv_proc: Unexpected PAM conversation %d/'%s'\n",
- msg[0]->msg_style, msg[0]->msg);
+ "pam_passwd_conv_proc: Unexpected PAM conversation %d/'%s'\n",
+ msg[0]->msg_style, msg[0]->msg);
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
return PAM_CONV_ERR;
}
}
- if (!appdata_ptr) {
- /* Workaround for Solaris 2.6 where the PAM library is broken
- * and does not pass appdata_ptr to the conversation routine
+ if (!appdata_ptr)
+ {
+ /*
+ * Workaround for Solaris 2.6 where the PAM library is broken and
+ * does not pass appdata_ptr to the conversation routine
*/
appdata_ptr = pam_passwd;
}
- /* Password wasn't passed to PAM the first time around - let's go
- * ask the client to send a password, which we then stuff into
- * PAM.
+ /*
+ * Password wasn't passed to PAM the first time around - let's go ask
+ * the client to send a password, which we then stuff into PAM.
*/
- if(strlen(appdata_ptr) == 0) {
+ if (strlen(appdata_ptr) == 0)
+ {
sendAuthRequest(pam_port_cludge, AUTH_REQ_PASSWORD);
- if (pq_eof() == EOF || pq_getint(&len, 4) == EOF) {
- return PAM_CONV_ERR; /* client didn't want to send password */
+ if (pq_eof() == EOF || pq_getint(&len, 4) == EOF)
+ {
+ return PAM_CONV_ERR; /* client didn't want to send password */
}
- initStringInfo(&buf);
- pq_getstr(&buf);
- if (DebugLvl > 5)
+ initStringInfo(&buf);
+ pq_getstr(&buf);
+ if (DebugLvl > 5)
fprintf(stderr, "received PAM packet with len=%d, pw=%s\n",
- len, buf.data);
+ len, buf.data);
- if(strlen(buf.data) == 0) {
+ if (strlen(buf.data) == 0)
+ {
snprintf(PQerrormsg, PQERRORMSG_LENGTH, "pam_passwd_conv_proc: no password\n");
fputs(PQerrormsg, stderr);
return PAM_CONV_ERR;
appdata_ptr = buf.data;
}
- /* Explicitly not using palloc here - PAM will free this memory in
+ /*
+ * Explicitly not using palloc here - PAM will free this memory in
* pam_end()
*/
*resp = calloc(num_msg, sizeof(struct pam_response));
- if (!*resp) {
+ if (!*resp)
+ {
snprintf(PQerrormsg, PQERRORMSG_LENGTH, "pam_passwd_conv_proc: Out of memory!\n");
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
- if(buf.data)
+ if (buf.data)
pfree(buf.data);
- return PAM_CONV_ERR;
+ return PAM_CONV_ERR;
}
(*resp)[0].resp = strdup((char *) appdata_ptr);
static int
CheckPAMAuth(Port *port, char *user, char *password)
{
- int retval;
+ int retval;
pam_handle_t *pamh = NULL;
/*
- * Apparently, Solaris 2.6 is broken, and needs ugly static
- * variable workaround
+ * Apparently, Solaris 2.6 is broken, and needs ugly static variable
+ * workaround
*/
pam_passwd = password;
- /* Set the application data portion of the conversation struct
- * This is later used inside the PAM conversation to pass the
- * password to the authentication module.
+ /*
+ * Set the application data portion of the conversation struct This is
+ * later used inside the PAM conversation to pass the password to the
+ * authentication module.
*/
- pam_passw_conv.appdata_ptr = (char*) password; /* from password above, not allocated */
+ pam_passw_conv.appdata_ptr = (char *) password; /* from password above,
+ * not allocated */
/* Optionally, one can set the service name in pg_hba.conf */
- if(port->auth_arg[0] == '\0') {
+ if (port->auth_arg[0] == '\0')
retval = pam_start(PGSQL_PAM_SERVICE, "pgsql@", &pam_passw_conv, &pamh);
- } else {
+ else
retval = pam_start(port->auth_arg, "pgsql@", &pam_passw_conv, &pamh);
- }
- if (retval != PAM_SUCCESS) {
+ if (retval != PAM_SUCCESS)
+ {
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "CheckPAMAuth: Failed to create PAM authenticator: '%s'\n",
- pam_strerror(pamh, retval));
+ "CheckPAMAuth: Failed to create PAM authenticator: '%s'\n",
+ pam_strerror(pamh, retval));
fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
- pam_passwd = NULL; /* Unset pam_passwd */
+ pqdebug("%s", PQerrormsg);
+ pam_passwd = NULL; /* Unset pam_passwd */
return STATUS_ERROR;
}
- if (retval == PAM_SUCCESS) {
+ if (retval == PAM_SUCCESS)
retval = pam_set_item(pamh, PAM_USER, user);
- } else {
+ else
+ {
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "CheckPAMAuth: pam_set_item(PAM_USER) failed: '%s'\n",
- pam_strerror(pamh, retval));
+ "CheckPAMAuth: pam_set_item(PAM_USER) failed: '%s'\n",
+ pam_strerror(pamh, retval));
fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
- pam_passwd = NULL; /* Unset pam_passwd */
+ pqdebug("%s", PQerrormsg);
+ pam_passwd = NULL; /* Unset pam_passwd */
return STATUS_ERROR;
}
- if (retval == PAM_SUCCESS) {
+ if (retval == PAM_SUCCESS)
retval = pam_set_item(pamh, PAM_CONV, &pam_passw_conv);
- } else {
+ else
+ {
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "CheckPAMAuth: pam_set_item(PAM_CONV) failed: '%s'\n",
- pam_strerror(pamh, retval));
+ "CheckPAMAuth: pam_set_item(PAM_CONV) failed: '%s'\n",
+ pam_strerror(pamh, retval));
fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
- pam_passwd = NULL; /* Unset pam_passwd */
+ pqdebug("%s", PQerrormsg);
+ pam_passwd = NULL; /* Unset pam_passwd */
return STATUS_ERROR;
}
- if (retval == PAM_SUCCESS) {
+ if (retval == PAM_SUCCESS)
retval = pam_authenticate(pamh, 0);
- } else {
+ else
+ {
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "CheckPAMAuth: pam_authenticate failed: '%s'\n",
- pam_strerror(pamh, retval));
+ "CheckPAMAuth: pam_authenticate failed: '%s'\n",
+ pam_strerror(pamh, retval));
fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
- pam_passwd = NULL; /* Unset pam_passwd */
+ pqdebug("%s", PQerrormsg);
+ pam_passwd = NULL; /* Unset pam_passwd */
return STATUS_ERROR;
}
- if (retval == PAM_SUCCESS) {
+ if (retval == PAM_SUCCESS)
retval = pam_acct_mgmt(pamh, 0);
- } else {
+ else
+ {
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "CheckPAMAuth: pam_acct_mgmt failed: '%s'\n",
- pam_strerror(pamh, retval));
+ "CheckPAMAuth: pam_acct_mgmt failed: '%s'\n",
+ pam_strerror(pamh, retval));
fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
- pam_passwd = NULL; /* Unset pam_passwd */
+ pqdebug("%s", PQerrormsg);
+ pam_passwd = NULL; /* Unset pam_passwd */
return STATUS_ERROR;
}
- if (retval == PAM_SUCCESS) {
+ if (retval == PAM_SUCCESS)
+ {
retval = pam_end(pamh, retval);
- if(retval != PAM_SUCCESS) {
+ if (retval != PAM_SUCCESS)
+ {
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "CheckPAMAuth: Failed to release PAM authenticator: '%s'\n",
- pam_strerror(pamh, retval));
+ "CheckPAMAuth: Failed to release PAM authenticator: '%s'\n",
+ pam_strerror(pamh, retval));
fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ pqdebug("%s", PQerrormsg);
}
- pam_passwd = NULL; /* Unset pam_passwd */
+ pam_passwd = NULL; /* Unset pam_passwd */
return (retval == PAM_SUCCESS ? STATUS_OK : STATUS_ERROR);
- } else {
- return STATUS_ERROR;
}
+ else
+ return STATUS_ERROR;
}
-
-#endif /* USE_PAM */
+#endif /* USE_PAM */
/*
return STATUS_EOF; /* client didn't want to send password */
initStringInfo(&buf);
- if (pq_getstr(&buf) == EOF) /* receive password */
+ if (pq_getstr(&buf) == EOF) /* receive password */
{
pfree(buf.data);
return STATUS_EOF;
case uaReject:
#ifdef USE_PAM
case uaPAM:
-#endif /* USE_PAM */
+#endif /* USE_PAM */
status = STATUS_ERROR;
break;
* Dec 17, 1997 - Todd A. Brandys
* Orignal Version Completed.
*
- * $Id: crypt.c,v 1.38 2001/09/21 20:31:45 tgl Exp $
+ * $Id: crypt.c,v 1.39 2001/10/25 05:49:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
while (fgets(buffer, 256, pwd_file) != NULL)
{
-
/*
* We must remove the return char at the end of the string, as
* this will affect the correct parsing of the password entry.
if (isMD5(passwd) && port->auth_method != uaMD5)
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "Password is stored MD5 encrypted. "
- "'password' and 'crypt' auth methods cannot be used.\n");
+ "Password is stored MD5 encrypted. "
+ "'password' and 'crypt' auth methods cannot be used.\n");
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
return STATUS_ERROR;
switch (port->auth_method)
{
case uaMD5:
- crypt_pwd = palloc(MD5_PASSWD_LEN+1);
+ crypt_pwd = palloc(MD5_PASSWD_LEN + 1);
if (isMD5(passwd))
{
if (!EncryptMD5(passwd + strlen("md5"),
- (char *)port->md5Salt,
+ (char *) port->md5Salt,
sizeof(port->md5Salt), crypt_pwd))
{
pfree(crypt_pwd);
}
else
{
- char *crypt_pwd2 = palloc(MD5_PASSWD_LEN+1);
+ char *crypt_pwd2 = palloc(MD5_PASSWD_LEN + 1);
if (!EncryptMD5(passwd, port->user, strlen(port->user),
crypt_pwd2))
}
break;
case uaCrypt:
- {
- char salt[3];
- StrNCpy(salt, port->cryptSalt,3);
- crypt_pwd = crypt(passwd, salt);
- break;
- }
+ {
+ char salt[3];
+
+ StrNCpy(salt, port->cryptSalt, 3);
+ crypt_pwd = crypt(passwd, salt);
+ break;
+ }
default:
crypt_pwd = passwd;
break;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.74 2001/09/26 19:57:01 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.75 2001/10/25 05:49:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
* These variables hold the pre-parsed contents of the hba and ident
* configuration files. Each is a list of sublists, one sublist for
- * each (non-empty, non-comment) line of the file. Each sublist's
+ * each (non-empty, non-comment) line of the file. Each sublist's
* first item is an integer line number (so we can give somewhat-useful
* location info in error messages). Remaining items are palloc'd strings,
* one string per token on the line. Note there will always be at least
* one token, since blank lines are not entered in the data structure.
*/
static List *hba_lines = NIL; /* pre-parsed contents of hba file */
-static List *ident_lines = NIL; /* pre-parsed contents of ident file */
+static List *ident_lines = NIL; /* pre-parsed contents of ident file */
/*
/*
- * Grab one token out of fp. Tokens are strings of non-blank
- * characters bounded by blank characters, beginning of line, and end
- * of line. Blank means space or tab. Return the token as *buf.
- * Leave file positioned to character immediately after the token or
- * EOF, whichever comes first. If no more tokens on line, return null
- * string as *buf and position file to beginning of next line or EOF,
- * whichever comes first.
+ * Grab one token out of fp. Tokens are strings of non-blank
+ * characters bounded by blank characters, beginning of line, and end
+ * of line. Blank means space or tab. Return the token as *buf.
+ * Leave file positioned to character immediately after the token or
+ * EOF, whichever comes first. If no more tokens on line, return null
+ * string as *buf and position file to beginning of next line or EOF,
+ * whichever comes first.
*/
static void
next_token(FILE *fp, char *buf, const int bufsz)
{
/*
* build a token in buf of next characters up to EOF, eol, or
- * blank. If the token gets too long, we still parse it correctly,
- * but the excess characters are not stored into *buf.
+ * blank. If the token gets too long, we still parse it
+ * correctly, but the excess characters are not stored into *buf.
*/
while (c != EOF && c != '\n' && !isblank(c))
{
*buf++ = c;
c = getc(fp);
}
+
/*
- * Put back the char right after the token (critical in case it
- * is eol, since we need to detect end-of-line at next call).
+ * Put back the char right after the token (critical in case it is
+ * eol, since we need to detect end-of-line at next call).
*/
if (c != EOF)
ungetc(c, fp);
/*
- * Read the given file and create a list of line sublists.
+ * Read the given file and create a list of line sublists.
*/
static List *
tokenize_file(FILE *file)
{
if (*lines)
{
- List *line, *token;
+ List *line,
+ *token;
foreach(line, *lines)
{
- List *ln = lfirst(line);
+ List *ln = lfirst(line);
/* free the pstrdup'd tokens (don't try it on the line number) */
foreach(token, lnext(ln))
/*
- * Scan the rest of a host record (after the mask field)
- * and return the interpretation of it as *userauth_p, auth_arg, and
- * *error_p. line points to the next token of the line.
+ * Scan the rest of a host record (after the mask field)
+ * and return the interpretation of it as *userauth_p, auth_arg, and
+ * *error_p. line points to the next token of the line.
*/
static void
parse_hba_auth(List *line, UserAuth *userauth_p, char *auth_arg,
bool *error_p)
{
- char *token;
+ char *token;
if (!line)
*error_p = true;
/*
- * Process one line from the hba config file.
+ * Process one line from the hba config file.
*
- * See if it applies to a connection from a host with IP address port->raddr
- * to a database named port->database. If so, return *found_p true
- * and fill in the auth arguments into the appropriate port fields.
- * If not, leave *found_p as it was. If the record has a syntax error,
- * return *error_p true, after issuing a message to stderr. If no error,
- * leave *error_p as it was.
+ * See if it applies to a connection from a host with IP address port->raddr
+ * to a database named port->database. If so, return *found_p true
+ * and fill in the auth arguments into the appropriate port fields.
+ * If not, leave *found_p as it was. If the record has a syntax error,
+ * return *error_p true, after issuing a message to stderr. If no error,
+ * leave *error_p as it was.
*/
static void
parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
{
int line_number;
- char *token;
- char *db;
+ char *token;
+ char *db;
Assert(line != NIL);
line_number = lfirsti(line);
}
else if (strcmp(token, "host") == 0 || strcmp(token, "hostssl") == 0)
{
- struct in_addr file_ip_addr, mask;
+ struct in_addr file_ip_addr,
+ mask;
if (strcmp(token, "hostssl") == 0)
{
/*
- * Scan the (pre-parsed) hba file line by line, looking for a match
+ * Scan the (pre-parsed) hba file line by line, looking for a match
* to the port's connection request.
*/
static bool
check_hba(hbaPort *port)
{
- bool found_entry = false;
- bool error = false;
- List *line;
+ bool found_entry = false;
+ bool error = false;
+ List *line;
- foreach (line, hba_lines)
+ foreach(line, hba_lines)
{
parse_hba(lfirst(line), port, &found_entry, &error);
if (found_entry || error)
if (hba_lines)
free_lines(&hba_lines);
+
/*
- * The name of old config file that better not exist.
- * Fail if config file by old name exists.
- * Put together the full pathname to the old config file.
+ * The name of old config file that better not exist. Fail if config
+ * file by old name exists. Put together the full pathname to the old
+ * config file.
*/
bufsize = (strlen(DataDir) + strlen(OLD_CONF_FILE) + 2) * sizeof(char);
old_conf_file = (char *) palloc(bufsize);
/* Old config file exists. Tell this guy he needs to upgrade. */
close(fd);
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "A file exists by the name used for host-based authentication "
- "in prior releases of Postgres (%s). The name and format of "
- "the configuration file have changed, so this file should be "
- "converted.\n", old_conf_file);
+ "A file exists by the name used for host-based authentication "
+ "in prior releases of Postgres (%s). The name and format of "
+ "the configuration file have changed, so this file should be "
+ "converted.\n", old_conf_file);
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
}
/*
* Process one line from the ident config file.
*
- * Take the line and compare it to the needed map, pg_user and ident_user.
+ * Take the line and compare it to the needed map, pg_user and ident_user.
* *found_p and *error_p are set according to our results.
*/
static void
const char *ident_user, bool *found_p, bool *error_p)
{
int line_number;
- char *token;
- char *file_map;
- char *file_pguser;
- char *file_ident_user;
+ char *token;
+ char *file_map;
+ char *file_pguser;
+ char *file_ident_user;
*found_p = false;
*error_p = false;
/*
- * Scan the (pre-parsed) ident usermap file line by line, looking for a match
+ * Scan the (pre-parsed) ident usermap file line by line, looking for a match
*
- * See if the user with ident username "ident_user" is allowed to act
- * as Postgres user "pguser" according to usermap "usermap_name".
+ * See if the user with ident username "ident_user" is allowed to act
+ * as Postgres user "pguser" according to usermap "usermap_name".
*
- * Special case: For usermap "sameuser", don't look in the usermap
- * file. That's an implied map where "pguser" must be identical to
- * "ident_user" in order to be authorized.
+ * Special case: For usermap "sameuser", don't look in the usermap
+ * file. That's an implied map where "pguser" must be identical to
+ * "ident_user" in order to be authorized.
*
- * Iff authorized, return true.
+ * Iff authorized, return true.
*/
static bool
check_ident_usermap(const char *usermap_name,
const char *pg_user,
const char *ident_user)
{
- List *line;
- bool found_entry = false, error = false;
+ List *line;
+ bool found_entry = false,
+ error = false;
if (usermap_name[0] == '\0')
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "check_ident_usermap: hba configuration file does not "
- "have the usermap field filled in in the entry that pertains "
- "to this connection. That field is essential for Ident-based "
- "authentication.\n");
+ "check_ident_usermap: hba configuration file does not "
+ "have the usermap field filled in in the entry that pertains "
+ "to this connection. That field is essential for Ident-based "
+ "authentication.\n");
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
found_entry = false;
static void
load_ident(void)
{
- FILE *file; /* The map file we have to read */
- char *map_file; /* The name of the map file we have to
- * read */
+ FILE *file; /* The map file we have to read */
+ char *map_file; /* The name of the map file we have to
+ * read */
int bufsize;
if (ident_lines)
/*
- * Parse the string "*ident_response" as a response from a query to an Ident
- * server. If it's a normal response indicating a username, return true
- * and store the username at *ident_user. If it's anything else,
+ * Parse the string "*ident_response" as a response from a query to an Ident
+ * server. If it's a normal response indicating a username, return true
+ * and store the username at *ident_user. If it's anything else,
* return false.
*/
static bool
interpret_ident_response(char *ident_response,
char *ident_user)
{
- char *cursor = ident_response; /* Cursor into *ident_response */
+ char *cursor = ident_response; /* Cursor into
+ * *ident_response */
/*
* Ident's response, in the telnet tradition, should end in crlf
/*
- * Talk to the ident server on host "remote_ip_addr" and find out who
- * owns the tcp connection from his port "remote_port" to port
- * "local_port_addr" on host "local_ip_addr". Return the username the
- * ident server gives as "*ident_user".
+ * Talk to the ident server on host "remote_ip_addr" and find out who
+ * owns the tcp connection from his port "remote_port" to port
+ * "local_port_addr" on host "local_ip_addr". Return the username the
+ * ident server gives as "*ident_user".
*
- * IP addresses and port numbers are in network byte order.
+ * IP addresses and port numbers are in network byte order.
*
- * But iff we're unable to get the information from ident, return false.
+ * But iff we're unable to get the information from ident, return false.
*/
static bool
ident_inet(const struct in_addr remote_ip_addr,
* talk to Ident */
rc; /* Return code from a locally called
* function */
- bool ident_return;
+ bool ident_return;
sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
if (sock_fd == -1)
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "Failed to create socket on which to talk to Ident server. "
- "socket() returned errno = %s (%d)\n", strerror(errno), errno);
+ "Failed to create socket on which to talk to Ident server. "
+ "socket() returned errno = %s (%d)\n", strerror(errno), errno);
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
ident_return = false;
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"Unable to connect to Ident server on the host which is "
- "trying to connect to Postgres "
- "(IP address %s, Port %d). "
- "errno = %s (%d)\n",
- inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(errno), errno);
+ "trying to connect to Postgres "
+ "(IP address %s, Port %d). "
+ "errno = %s (%d)\n",
+ inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(errno), errno);
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
ident_return = false;
if (rc < 0)
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "Unable to send query to Ident server on the host which is "
- "trying to connect to Postgres (Host %s, Port %d),"
- "even though we successfully connected to it. "
- "errno = %s (%d)\n",
- inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(errno), errno);
+ "Unable to send query to Ident server on the host which is "
+ "trying to connect to Postgres (Host %s, Port %d),"
+ "even though we successfully connected to it. "
+ "errno = %s (%d)\n",
+ inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(errno), errno);
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
ident_return = false;
if (rc < 0)
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "Unable to receive response from Ident server "
- "on the host which is "
- "trying to connect to Postgres (Host %s, Port %d),"
- "even though we successfully sent our query to it. "
- "errno = %s (%d)\n",
- inet_ntoa(remote_ip_addr), IDENT_PORT,
- strerror(errno), errno);
+ "Unable to receive response from Ident server "
+ "on the host which is "
+ "trying to connect to Postgres (Host %s, Port %d),"
+ "even though we successfully sent our query to it. "
+ "errno = %s (%d)\n",
+ inet_ntoa(remote_ip_addr), IDENT_PORT,
+ strerror(errno), errno);
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
ident_return = false;
}
/*
- * Ask kernel about the credentials of the connecting process and
- * determine the symbolic name of the corresponding user.
+ * Ask kernel about the credentials of the connecting process and
+ * determine the symbolic name of the corresponding user.
*
- * Returns either true and the username put into "ident_user",
- * or false if we were unable to determine the username.
+ * Returns either true and the username put into "ident_user",
+ * or false if we were unable to determine the username.
*/
static bool
ident_unix(int sock, char *ident_user)
{
#if defined(SO_PEERCRED)
/* Linux style: use getsockopt(SO_PEERCRED) */
- struct ucred peercred;
+ struct ucred peercred;
ACCEPT_TYPE_ARG3 so_len = sizeof(peercred);
struct passwd *pass;
if (pass == NULL)
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "ident_unix: unknown local user with uid %d\n", peercred.uid);
+ "ident_unix: unknown local user with uid %d\n", peercred.uid);
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
return false;
}
- StrNCpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX+1);
+ StrNCpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1);
return true;
/* Credentials structure */
#ifdef HAVE_STRUCT_CMSGCRED
typedef struct cmsgcred Cred;
+
#define cruid cmcred_uid
#elif HAVE_STRUCT_FCRED
typedef struct fcred Cred;
+
#define cruid fc_uid
#elif HAVE_STRUCT_SOCKCRED
typedef struct sockcred Cred;
+
#define cruid sc_uid
#endif
- Cred *cred;
+ Cred *cred;
/* Compute size without padding */
- char cmsgmem[ALIGN(sizeof(struct cmsghdr)) + ALIGN(sizeof(Cred))]; /*for NetBSD*/
+ char cmsgmem[ALIGN(sizeof(struct cmsghdr)) + ALIGN(sizeof(Cred))]; /* for NetBSD */
+
/* Point to start of first structure */
- struct cmsghdr *cmsg = (struct cmsghdr *)cmsgmem;
+ struct cmsghdr *cmsg = (struct cmsghdr *) cmsgmem;
struct iovec iov;
- char buf;
+ char buf;
struct passwd *pw;
memset(&msg, 0, sizeof(msg));
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
- msg.msg_control = (char *)cmsg;
+ msg.msg_control = (char *) cmsg;
msg.msg_controllen = sizeof(cmsgmem);
memset(cmsg, 0, sizeof(cmsgmem));
/*
- * The one character which is received here is not meaningful;
- * its purposes is only to make sure that recvmsg() blocks
- * long enough for the other side to send its credentials.
+ * The one character which is received here is not meaningful; its
+ * purposes is only to make sure that recvmsg() blocks long enough for
+ * the other side to send its credentials.
*/
iov.iov_base = &buf;
iov.iov_len = 1;
return false;
}
- cred = (Cred *)CMSG_DATA(cmsg);
+ cred = (Cred *) CMSG_DATA(cmsg);
pw = getpwuid(cred->cruid);
if (pw == NULL)
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "ident_unix: unknown local user with uid %d\n",
- cred->cruid);
+ "ident_unix: unknown local user with uid %d\n",
+ cred->cruid);
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
return false;
}
- StrNCpy(ident_user, pw->pw_name, IDENT_USERNAME_MAX+1);
+ StrNCpy(ident_user, pw->pw_name, IDENT_USERNAME_MAX + 1);
return true;
pqdebug("%s", PQerrormsg);
return false;
-
#endif
}
/*
- * Determine the username of the initiator of the connection described
- * by "port". Then look in the usermap file under the usermap
- * port->auth_arg and see if that user is equivalent to Postgres user
- * port->user.
+ * Determine the username of the initiator of the connection described
+ * by "port". Then look in the usermap file under the usermap
+ * port->auth_arg and see if that user is equivalent to Postgres user
+ * port->user.
*
- * Return STATUS_OK if yes, STATUS_ERROR if no match (or couldn't get info).
+ * Return STATUS_OK if yes, STATUS_ERROR if no match (or couldn't get info).
*/
int
authident(hbaPort *port)
/*
- * Determine what authentication method should be used when accessing database
- * "database" from frontend "raddr", user "user". Return the method and
- * an optional argument (stored in fields of *port), and STATUS_OK.
+ * Determine what authentication method should be used when accessing database
+ * "database" from frontend "raddr", user "user". Return the method and
+ * an optional argument (stored in fields of *port), and STATUS_OK.
*
- * Note that STATUS_ERROR indicates a problem with the hba config file.
- * If the file is OK but does not contain any entry matching the request,
- * we return STATUS_OK and method = uaReject.
+ * Note that STATUS_ERROR indicates a problem with the hba config file.
+ * If the file is OK but does not contain any entry matching the request,
+ * we return STATUS_OK and method = uaReject.
*/
int
hba_getauthmethod(hbaPort *port)
pfree((struct CharsetItem *) ChArray[i]);
}
}
-
-#endif /* CYR_RECODE */
+#endif /* CYR_RECODE */
/*
- * md5.c
+ * md5.c
*
- * Implements the MD5 Message-Digest Algorithm as specified in
- * RFC 1321. This implementation is a simple one, in that it
- * needs every input byte to be buffered before doing any
- * calculations. I do not expect this file to be used for
- * general purpose MD5'ing of large amounts of data, only for
- * generating hashed passwords from limited input.
+ * Implements the MD5 Message-Digest Algorithm as specified in
+ * RFC 1321. This implementation is a simple one, in that it
+ * needs every input byte to be buffered before doing any
+ * calculations. I do not expect this file to be used for
+ * general purpose MD5'ing of large amounts of data, only for
+ * generating hashed passwords from limited input.
*
- * Sverre H. Huseby
+ * Sverre H. Huseby
*
- * $Header: /cvsroot/pgsql/src/backend/libpq/md5.c,v 1.8 2001/09/29 19:49:50 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/md5.c,v 1.9 2001/10/25 05:49:30 momjian Exp $
*/
#include "postgres.h"
/*
* The returned array is allocated using malloc. the caller should free it
- * when it is no longer needed.
+ * when it is no longer needed.
*/
static uint8 *
createPaddedCopyWithLength(uint8 *b, uint32 *l)
{
- uint8 *ret;
- uint32 q;
- uint32 len, newLen448;
- uint32 len_high, len_low; /* 64-bit value split into 32-bit sections */
+ uint8 *ret;
+ uint32 q;
+ uint32 len,
+ newLen448;
+ uint32 len_high,
+ len_low; /* 64-bit value split into 32-bit sections */
len = ((b == NULL) ? 0 : *l);
newLen448 = len + 64 - (len % 64) - 8;
static void
doTheRounds(uint32 X[16], uint32 state[4])
{
- uint32 a, b, c, d;
+ uint32 a,
+ b,
+ c,
+ d;
a = state[0];
b = state[1];
d = state[3];
/* round 1 */
- a = b + ROT_LEFT((a + F(b, c, d) + X[ 0] + 0xd76aa478), 7); /* 1 */
- d = a + ROT_LEFT((d + F(a, b, c) + X[ 1] + 0xe8c7b756), 12); /* 2 */
- c = d + ROT_LEFT((c + F(d, a, b) + X[ 2] + 0x242070db), 17); /* 3 */
- b = c + ROT_LEFT((b + F(c, d, a) + X[ 3] + 0xc1bdceee), 22); /* 4 */
- a = b + ROT_LEFT((a + F(b, c, d) + X[ 4] + 0xf57c0faf), 7); /* 5 */
- d = a + ROT_LEFT((d + F(a, b, c) + X[ 5] + 0x4787c62a), 12); /* 6 */
- c = d + ROT_LEFT((c + F(d, a, b) + X[ 6] + 0xa8304613), 17); /* 7 */
- b = c + ROT_LEFT((b + F(c, d, a) + X[ 7] + 0xfd469501), 22); /* 8 */
- a = b + ROT_LEFT((a + F(b, c, d) + X[ 8] + 0x698098d8), 7); /* 9 */
- d = a + ROT_LEFT((d + F(a, b, c) + X[ 9] + 0x8b44f7af), 12); /* 10 */
- c = d + ROT_LEFT((c + F(d, a, b) + X[10] + 0xffff5bb1), 17); /* 11 */
- b = c + ROT_LEFT((b + F(c, d, a) + X[11] + 0x895cd7be), 22); /* 12 */
- a = b + ROT_LEFT((a + F(b, c, d) + X[12] + 0x6b901122), 7); /* 13 */
- d = a + ROT_LEFT((d + F(a, b, c) + X[13] + 0xfd987193), 12); /* 14 */
- c = d + ROT_LEFT((c + F(d, a, b) + X[14] + 0xa679438e), 17); /* 15 */
- b = c + ROT_LEFT((b + F(c, d, a) + X[15] + 0x49b40821), 22); /* 16 */
+ a = b + ROT_LEFT((a + F(b, c, d) + X[0] + 0xd76aa478), 7); /* 1 */
+ d = a + ROT_LEFT((d + F(a, b, c) + X[1] + 0xe8c7b756), 12); /* 2 */
+ c = d + ROT_LEFT((c + F(d, a, b) + X[2] + 0x242070db), 17); /* 3 */
+ b = c + ROT_LEFT((b + F(c, d, a) + X[3] + 0xc1bdceee), 22); /* 4 */
+ a = b + ROT_LEFT((a + F(b, c, d) + X[4] + 0xf57c0faf), 7); /* 5 */
+ d = a + ROT_LEFT((d + F(a, b, c) + X[5] + 0x4787c62a), 12); /* 6 */
+ c = d + ROT_LEFT((c + F(d, a, b) + X[6] + 0xa8304613), 17); /* 7 */
+ b = c + ROT_LEFT((b + F(c, d, a) + X[7] + 0xfd469501), 22); /* 8 */
+ a = b + ROT_LEFT((a + F(b, c, d) + X[8] + 0x698098d8), 7); /* 9 */
+ d = a + ROT_LEFT((d + F(a, b, c) + X[9] + 0x8b44f7af), 12); /* 10 */
+ c = d + ROT_LEFT((c + F(d, a, b) + X[10] + 0xffff5bb1), 17); /* 11 */
+ b = c + ROT_LEFT((b + F(c, d, a) + X[11] + 0x895cd7be), 22); /* 12 */
+ a = b + ROT_LEFT((a + F(b, c, d) + X[12] + 0x6b901122), 7); /* 13 */
+ d = a + ROT_LEFT((d + F(a, b, c) + X[13] + 0xfd987193), 12); /* 14 */
+ c = d + ROT_LEFT((c + F(d, a, b) + X[14] + 0xa679438e), 17); /* 15 */
+ b = c + ROT_LEFT((b + F(c, d, a) + X[15] + 0x49b40821), 22); /* 16 */
/* round 2 */
- a = b + ROT_LEFT((a + G(b, c, d) + X[ 1] + 0xf61e2562), 5); /* 17 */
- d = a + ROT_LEFT((d + G(a, b, c) + X[ 6] + 0xc040b340), 9); /* 18 */
- c = d + ROT_LEFT((c + G(d, a, b) + X[11] + 0x265e5a51), 14); /* 19 */
- b = c + ROT_LEFT((b + G(c, d, a) + X[ 0] + 0xe9b6c7aa), 20); /* 20 */
- a = b + ROT_LEFT((a + G(b, c, d) + X[ 5] + 0xd62f105d), 5); /* 21 */
- d = a + ROT_LEFT((d + G(a, b, c) + X[10] + 0x02441453), 9); /* 22 */
- c = d + ROT_LEFT((c + G(d, a, b) + X[15] + 0xd8a1e681), 14); /* 23 */
- b = c + ROT_LEFT((b + G(c, d, a) + X[ 4] + 0xe7d3fbc8), 20); /* 24 */
- a = b + ROT_LEFT((a + G(b, c, d) + X[ 9] + 0x21e1cde6), 5); /* 25 */
- d = a + ROT_LEFT((d + G(a, b, c) + X[14] + 0xc33707d6), 9); /* 26 */
- c = d + ROT_LEFT((c + G(d, a, b) + X[ 3] + 0xf4d50d87), 14); /* 27 */
- b = c + ROT_LEFT((b + G(c, d, a) + X[ 8] + 0x455a14ed), 20); /* 28 */
- a = b + ROT_LEFT((a + G(b, c, d) + X[13] + 0xa9e3e905), 5); /* 29 */
- d = a + ROT_LEFT((d + G(a, b, c) + X[ 2] + 0xfcefa3f8), 9); /* 30 */
- c = d + ROT_LEFT((c + G(d, a, b) + X[ 7] + 0x676f02d9), 14); /* 31 */
- b = c + ROT_LEFT((b + G(c, d, a) + X[12] + 0x8d2a4c8a), 20); /* 32 */
+ a = b + ROT_LEFT((a + G(b, c, d) + X[1] + 0xf61e2562), 5); /* 17 */
+ d = a + ROT_LEFT((d + G(a, b, c) + X[6] + 0xc040b340), 9); /* 18 */
+ c = d + ROT_LEFT((c + G(d, a, b) + X[11] + 0x265e5a51), 14); /* 19 */
+ b = c + ROT_LEFT((b + G(c, d, a) + X[0] + 0xe9b6c7aa), 20); /* 20 */
+ a = b + ROT_LEFT((a + G(b, c, d) + X[5] + 0xd62f105d), 5); /* 21 */
+ d = a + ROT_LEFT((d + G(a, b, c) + X[10] + 0x02441453), 9); /* 22 */
+ c = d + ROT_LEFT((c + G(d, a, b) + X[15] + 0xd8a1e681), 14); /* 23 */
+ b = c + ROT_LEFT((b + G(c, d, a) + X[4] + 0xe7d3fbc8), 20); /* 24 */
+ a = b + ROT_LEFT((a + G(b, c, d) + X[9] + 0x21e1cde6), 5); /* 25 */
+ d = a + ROT_LEFT((d + G(a, b, c) + X[14] + 0xc33707d6), 9); /* 26 */
+ c = d + ROT_LEFT((c + G(d, a, b) + X[3] + 0xf4d50d87), 14); /* 27 */
+ b = c + ROT_LEFT((b + G(c, d, a) + X[8] + 0x455a14ed), 20); /* 28 */
+ a = b + ROT_LEFT((a + G(b, c, d) + X[13] + 0xa9e3e905), 5); /* 29 */
+ d = a + ROT_LEFT((d + G(a, b, c) + X[2] + 0xfcefa3f8), 9); /* 30 */
+ c = d + ROT_LEFT((c + G(d, a, b) + X[7] + 0x676f02d9), 14); /* 31 */
+ b = c + ROT_LEFT((b + G(c, d, a) + X[12] + 0x8d2a4c8a), 20); /* 32 */
/* round 3 */
- a = b + ROT_LEFT((a + H(b, c, d) + X[ 5] + 0xfffa3942), 4); /* 33 */
- d = a + ROT_LEFT((d + H(a, b, c) + X[ 8] + 0x8771f681), 11); /* 34 */
- c = d + ROT_LEFT((c + H(d, a, b) + X[11] + 0x6d9d6122), 16); /* 35 */
- b = c + ROT_LEFT((b + H(c, d, a) + X[14] + 0xfde5380c), 23); /* 36 */
- a = b + ROT_LEFT((a + H(b, c, d) + X[ 1] + 0xa4beea44), 4); /* 37 */
- d = a + ROT_LEFT((d + H(a, b, c) + X[ 4] + 0x4bdecfa9), 11); /* 38 */
- c = d + ROT_LEFT((c + H(d, a, b) + X[ 7] + 0xf6bb4b60), 16); /* 39 */
- b = c + ROT_LEFT((b + H(c, d, a) + X[10] + 0xbebfbc70), 23); /* 40 */
- a = b + ROT_LEFT((a + H(b, c, d) + X[13] + 0x289b7ec6), 4); /* 41 */
- d = a + ROT_LEFT((d + H(a, b, c) + X[ 0] + 0xeaa127fa), 11); /* 42 */
- c = d + ROT_LEFT((c + H(d, a, b) + X[ 3] + 0xd4ef3085), 16); /* 43 */
- b = c + ROT_LEFT((b + H(c, d, a) + X[ 6] + 0x04881d05), 23); /* 44 */
- a = b + ROT_LEFT((a + H(b, c, d) + X[ 9] + 0xd9d4d039), 4); /* 45 */
- d = a + ROT_LEFT((d + H(a, b, c) + X[12] + 0xe6db99e5), 11); /* 46 */
- c = d + ROT_LEFT((c + H(d, a, b) + X[15] + 0x1fa27cf8), 16); /* 47 */
- b = c + ROT_LEFT((b + H(c, d, a) + X[ 2] + 0xc4ac5665), 23); /* 48 */
+ a = b + ROT_LEFT((a + H(b, c, d) + X[5] + 0xfffa3942), 4); /* 33 */
+ d = a + ROT_LEFT((d + H(a, b, c) + X[8] + 0x8771f681), 11); /* 34 */
+ c = d + ROT_LEFT((c + H(d, a, b) + X[11] + 0x6d9d6122), 16); /* 35 */
+ b = c + ROT_LEFT((b + H(c, d, a) + X[14] + 0xfde5380c), 23); /* 36 */
+ a = b + ROT_LEFT((a + H(b, c, d) + X[1] + 0xa4beea44), 4); /* 37 */
+ d = a + ROT_LEFT((d + H(a, b, c) + X[4] + 0x4bdecfa9), 11); /* 38 */
+ c = d + ROT_LEFT((c + H(d, a, b) + X[7] + 0xf6bb4b60), 16); /* 39 */
+ b = c + ROT_LEFT((b + H(c, d, a) + X[10] + 0xbebfbc70), 23); /* 40 */
+ a = b + ROT_LEFT((a + H(b, c, d) + X[13] + 0x289b7ec6), 4); /* 41 */
+ d = a + ROT_LEFT((d + H(a, b, c) + X[0] + 0xeaa127fa), 11); /* 42 */
+ c = d + ROT_LEFT((c + H(d, a, b) + X[3] + 0xd4ef3085), 16); /* 43 */
+ b = c + ROT_LEFT((b + H(c, d, a) + X[6] + 0x04881d05), 23); /* 44 */
+ a = b + ROT_LEFT((a + H(b, c, d) + X[9] + 0xd9d4d039), 4); /* 45 */
+ d = a + ROT_LEFT((d + H(a, b, c) + X[12] + 0xe6db99e5), 11); /* 46 */
+ c = d + ROT_LEFT((c + H(d, a, b) + X[15] + 0x1fa27cf8), 16); /* 47 */
+ b = c + ROT_LEFT((b + H(c, d, a) + X[2] + 0xc4ac5665), 23); /* 48 */
/* round 4 */
- a = b + ROT_LEFT((a + I(b, c, d) + X[ 0] + 0xf4292244), 6); /* 49 */
- d = a + ROT_LEFT((d + I(a, b, c) + X[ 7] + 0x432aff97), 10); /* 50 */
- c = d + ROT_LEFT((c + I(d, a, b) + X[14] + 0xab9423a7), 15); /* 51 */
- b = c + ROT_LEFT((b + I(c, d, a) + X[ 5] + 0xfc93a039), 21); /* 52 */
- a = b + ROT_LEFT((a + I(b, c, d) + X[12] + 0x655b59c3), 6); /* 53 */
- d = a + ROT_LEFT((d + I(a, b, c) + X[ 3] + 0x8f0ccc92), 10); /* 54 */
- c = d + ROT_LEFT((c + I(d, a, b) + X[10] + 0xffeff47d), 15); /* 55 */
- b = c + ROT_LEFT((b + I(c, d, a) + X[ 1] + 0x85845dd1), 21); /* 56 */
- a = b + ROT_LEFT((a + I(b, c, d) + X[ 8] + 0x6fa87e4f), 6); /* 57 */
- d = a + ROT_LEFT((d + I(a, b, c) + X[15] + 0xfe2ce6e0), 10); /* 58 */
- c = d + ROT_LEFT((c + I(d, a, b) + X[ 6] + 0xa3014314), 15); /* 59 */
- b = c + ROT_LEFT((b + I(c, d, a) + X[13] + 0x4e0811a1), 21); /* 60 */
- a = b + ROT_LEFT((a + I(b, c, d) + X[ 4] + 0xf7537e82), 6); /* 61 */
- d = a + ROT_LEFT((d + I(a, b, c) + X[11] + 0xbd3af235), 10); /* 62 */
- c = d + ROT_LEFT((c + I(d, a, b) + X[ 2] + 0x2ad7d2bb), 15); /* 63 */
- b = c + ROT_LEFT((b + I(c, d, a) + X[ 9] + 0xeb86d391), 21); /* 64 */
+ a = b + ROT_LEFT((a + I(b, c, d) + X[0] + 0xf4292244), 6); /* 49 */
+ d = a + ROT_LEFT((d + I(a, b, c) + X[7] + 0x432aff97), 10); /* 50 */
+ c = d + ROT_LEFT((c + I(d, a, b) + X[14] + 0xab9423a7), 15); /* 51 */
+ b = c + ROT_LEFT((b + I(c, d, a) + X[5] + 0xfc93a039), 21); /* 52 */
+ a = b + ROT_LEFT((a + I(b, c, d) + X[12] + 0x655b59c3), 6); /* 53 */
+ d = a + ROT_LEFT((d + I(a, b, c) + X[3] + 0x8f0ccc92), 10); /* 54 */
+ c = d + ROT_LEFT((c + I(d, a, b) + X[10] + 0xffeff47d), 15); /* 55 */
+ b = c + ROT_LEFT((b + I(c, d, a) + X[1] + 0x85845dd1), 21); /* 56 */
+ a = b + ROT_LEFT((a + I(b, c, d) + X[8] + 0x6fa87e4f), 6); /* 57 */
+ d = a + ROT_LEFT((d + I(a, b, c) + X[15] + 0xfe2ce6e0), 10); /* 58 */
+ c = d + ROT_LEFT((c + I(d, a, b) + X[6] + 0xa3014314), 15); /* 59 */
+ b = c + ROT_LEFT((b + I(c, d, a) + X[13] + 0x4e0811a1), 21); /* 60 */
+ a = b + ROT_LEFT((a + I(b, c, d) + X[4] + 0xf7537e82), 6); /* 61 */
+ d = a + ROT_LEFT((d + I(a, b, c) + X[11] + 0xbd3af235), 10); /* 62 */
+ c = d + ROT_LEFT((c + I(d, a, b) + X[2] + 0x2ad7d2bb), 15); /* 63 */
+ b = c + ROT_LEFT((b + I(c, d, a) + X[9] + 0xeb86d391), 21); /* 64 */
state[0] += a;
state[1] += b;
static int
calculateDigestFromBuffer(uint8 *b, uint32 len, uint8 sum[16])
{
- register uint32 i, j, k, newI;
- uint32 l;
- uint8 *input;
+ register uint32 i,
+ j,
+ k,
+ newI;
+ uint32 l;
+ uint8 *input;
register uint32 *wbp;
- uint32 workBuff[16], state[4];
+ uint32 workBuff[16],
+ state[4];
l = len;
if ((input = createPaddedCopyWithLength(b, &l)) == NULL)
return 0;
- for (i = 0;;) {
+ for (i = 0;;)
+ {
if ((newI = i + 16 * 4) > l)
break;
k = i + 3;
- for (j = 0; j < 16; j++) {
+ for (j = 0; j < 16; j++)
+ {
wbp = (workBuff + j);
*wbp = input[k--];
*wbp <<= 8;
free(input);
j = 0;
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < 4; i++)
+ {
k = state[i];
sum[j++] = (k & 0xff);
k >>= 8;
bytesToHex(uint8 b[16], char *s)
{
static char *hex = "0123456789abcdef";
- int q, w;
+ int q,
+ w;
- for (q = 0, w = 0; q < 16; q++) {
+ for (q = 0, w = 0; q < 16; q++)
+ {
s[w++] = hex[(b[q] >> 4) & 0x0F];
s[w++] = hex[b[q] & 0x0F];
}
}
/*
- * PUBLIC FUNCTIONS
+ * PUBLIC FUNCTIONS
*/
/*
- * md5_hash
+ * md5_hash
*
- * Calculates the MD5 sum of the bytes in a buffer.
+ * Calculates the MD5 sum of the bytes in a buffer.
*
- * SYNOPSIS #include "crypt.h"
- * int md5_hash(const void *buff, size_t len, char *hexsum)
+ * SYNOPSIS #include "crypt.h"
+ * int md5_hash(const void *buff, size_t len, char *hexsum)
*
- * INPUT buff the buffer containing the bytes that you want
- * the MD5 sum of.
- * len number of bytes in the buffer.
+ * INPUT buff the buffer containing the bytes that you want
+ * the MD5 sum of.
+ * len number of bytes in the buffer.
*
- * OUTPUT hexsum the MD5 sum as a '\0'-terminated string of
- * hexadecimal digits. an MD5 sum is 16 bytes long.
- * each byte is represented by two heaxadecimal
- * characters. you thus need to provide an array
- * of 33 characters, including the trailing '\0'.
+ * OUTPUT hexsum the MD5 sum as a '\0'-terminated string of
+ * hexadecimal digits. an MD5 sum is 16 bytes long.
+ * each byte is represented by two heaxadecimal
+ * characters. you thus need to provide an array
+ * of 33 characters, including the trailing '\0'.
*
- * RETURNS 0 on failure (out of memory for internal buffers) or
- * non-zero on success.
+ * RETURNS 0 on failure (out of memory for internal buffers) or
+ * non-zero on success.
*
- * STANDARDS MD5 is described in RFC 1321.
+ * STANDARDS MD5 is described in RFC 1321.
*
- * AUTHOR Sverre H. Huseby
+ * AUTHOR Sverre H. Huseby
*
*/
bool
md5_hash(const void *buff, size_t len, char *hexsum)
{
- uint8 sum[16];
+ uint8 sum[16];
if (!calculateDigestFromBuffer((uint8 *) buff, len, sum))
return false;
*
* Returns TRUE if okay, FALSE on error (out of memory).
*/
-bool EncryptMD5(const char *passwd, const char *salt, size_t salt_len,
- char *buf)
+bool
+EncryptMD5(const char *passwd, const char *salt, size_t salt_len,
+ char *buf)
{
- size_t passwd_len = strlen(passwd);
- char *crypt_buf = palloc(passwd_len + salt_len);
- bool ret;
-
+ size_t passwd_len = strlen(passwd);
+ char *crypt_buf = palloc(passwd_len + salt_len);
+ bool ret;
+
/*
- * Place salt at the end because it may be known by users
- * trying to crack the MD5 output.
- */
+ * Place salt at the end because it may be known by users trying to
+ * crack the MD5 output.
+ */
strcpy(crypt_buf, passwd);
- memcpy(crypt_buf+passwd_len, salt, salt_len);
+ memcpy(crypt_buf + passwd_len, salt, salt_len);
strcpy(buf, "md5");
ret = md5_hash(crypt_buf, passwd_len + salt_len, buf + 3);
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: password.c,v 1.39 2001/08/17 15:44:17 momjian Exp $
+ * $Id: password.c,v 1.40 2001/10/25 05:49:30 momjian Exp $
*
*/
/*
* If the password is empty or "+" then we use the regular
* pg_shadow passwords. If we use crypt then we have to use
- * pg_shadow passwords no matter what. This is because
- * the current code needs non-encrypted passwords to
- * encrypt with a random salt.
+ * pg_shadow passwords no matter what. This is because the
+ * current code needs non-encrypted passwords to encrypt with
+ * a random salt.
*/
if (port->auth_method == uaMD5 ||
port->auth_method == uaCrypt ||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqcomm.c,v 1.121 2001/08/07 15:55:16 tgl Exp $
+ * $Id: pqcomm.c,v 1.122 2001/10/25 05:49:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#endif /* HAVE_UNIX_SOCKETS */
/*
- * Select appropriate accept-queue length limit. PG_SOMAXCONN is
- * only intended to provide a clamp on the request on platforms where
- * an overly large request provokes a kernel error (are there any?).
+ * Select appropriate accept-queue length limit. PG_SOMAXCONN is only
+ * intended to provide a clamp on the request on platforms where an
+ * overly large request provokes a kernel error (are there any?).
*/
maxconn = MaxBackends * 2;
if (maxconn > PG_SOMAXCONN)
}
#ifdef SCO_ACCEPT_BUG
+
/*
* UnixWare 7+ and OpenServer 5.0.4 are known to have this bug, but it
* shouldn't hurt to catch it for all versions of those platforms.
int
pq_eof(void)
{
- char x;
- int res;
+ char x;
+ int res;
res = recv(MyProcPort->sock, &x, 1, MSG_PEEK);
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqformat.c,v 1.17 2001/04/16 01:46:57 tgl Exp $
+ * $Id: pqformat.c,v 1.18 2001/10/25 05:49:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#else
#error BYTE_ORDER not defined as anything understood
-
#endif
#endif
#endif
#ifdef MULTIBYTE
char *p;
-
#endif
result = pq_getstring(s);
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/util.c,v 1.17 2001/01/24 19:42:56 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/util.c,v 1.18 2001/10/25 05:49:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (PQtracep)
{
-
/*
* if nothing else was suggested default to stderr
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.47 2001/10/22 19:41:38 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.48 2001/10/25 05:49:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#if defined(__alpha)
#ifdef NOFIXADE
int buffer[] = {SSIN_UACPROC, UAC_SIGBUS};
-
#endif /* NOFIXADE */
#ifdef NOPRINTADE
int buffer[] = {SSIN_UACPROC, UAC_NOPRINT};
-
#endif /* NOPRINTADE */
#endif /* __alpha */
(unsigned long) NULL) < 0)
fprintf(stderr, gettext("%s: setsysinfo failed: %s\n"), argv[0], strerror(errno));
#endif
-
#endif /* NOFIXADE || NOPRINTADE */
#ifdef __BEOS__
* affected if init_ps_display overwrites the original argv[].
*
* (NB: do NOT think to remove the copying of argv[], even though
- * postmaster.c finishes looking at argv[] long before we ever consider
- * changing the ps display. On some platforms, getopt() keeps pointers
- * into the argv array, and will get horribly confused when it is
- * re-called to analyze a subprocess' argument string if the argv storage
- * has been clobbered meanwhile.)
+ * postmaster.c finishes looking at argv[] long before we ever
+ * consider changing the ps display. On some platforms, getopt()
+ * keeps pointers into the argv array, and will get horribly confused
+ * when it is re-called to analyze a subprocess' argument string if
+ * the argv storage has been clobbered meanwhile.)
*
* On some platforms, save_ps_display_args moves the environment strings
- * to make extra room. Therefore this should be done as early as
- * possible during startup, to avoid entanglements with code that might
- * save a getenv() result pointer.
+ * to make extra room. Therefore this should be done as early as
+ * possible during startup, to avoid entanglements with code that
+ * might save a getenv() result pointer.
*/
save_ps_display_args(argc, argv);
#endif
/*
- * Skip permission checks if we're just trying to do --help or --version;
- * otherwise root will get unhelpful failure messages from initdb.
+ * Skip permission checks if we're just trying to do --help or
+ * --version; otherwise root will get unhelpful failure messages from
+ * initdb.
*/
if (!(argc > 1
&& (strcmp(argv[1], "--help") == 0 ||
if (geteuid() == 0)
{
fprintf(stderr, gettext(
- "\"root\" execution of the PostgreSQL server is not permitted.\n\n"
- "The server must be started under an unprivileged user id to prevent\n"
- "a possible system security compromise. See the documentation for\n"
- "more information on how to properly start the server.\n\n"
- ));
+ "\"root\" execution of the PostgreSQL server is not permitted.\n\n"
+ "The server must be started under an unprivileged user id to prevent\n"
+ "a possible system security compromise. See the documentation for\n"
+ "more information on how to properly start the server.\n\n"
+ ));
exit(1);
}
#endif /* __BEOS__ */
/*
* Also make sure that real and effective uids are the same.
* Executing Postgres as a setuid program from a root shell is a
- * security hole, since on many platforms a nefarious subroutine could
- * setuid back to root if real uid is root. (Since nobody actually
- * uses Postgres as a setuid program, trying to actively fix this
- * situation seems more trouble than it's worth; we'll just expend the
- * effort to check for it.)
+ * security hole, since on many platforms a nefarious subroutine
+ * could setuid back to root if real uid is root. (Since nobody
+ * actually uses Postgres as a setuid program, trying to actively
+ * fix this situation seems more trouble than it's worth; we'll
+ * just expend the effort to check for it.)
*/
if (getuid() != geteuid())
{
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.158 2001/10/18 17:30:14 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.159 2001/10/25 05:49:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (from->constbyval || from->constisnull)
{
-
/*
* passed by value so just copy the datum. Also, don't try to copy
* struct when value is null!
}
else
{
-
/*
* not passed by value. datum contains a pointer.
*/
static NullTest *
_copyNullTest(NullTest *from)
{
- NullTest *newnode = makeNode(NullTest);
+ NullTest *newnode = makeNode(NullTest);
/*
* copy remainder of node
static void
CopyPathFields(Path *from, Path *newnode)
{
-
/*
* Modify the next line, since it causes the copying to cycle (i.e.
* the parent points right back here! -- JMH, 7/7/92. Old version:
/*
* We do not copy the planner internal fields: base_rel_list,
- * other_rel_list, join_rel_list, equi_key_list, query_pathkeys.
- * Not entirely clear if this is right?
+ * other_rel_list, join_rel_list, equi_key_list, query_pathkeys. Not
+ * entirely clear if this is right?
*/
return newnode;
static GrantStmt *
_copyGrantStmt(GrantStmt *from)
{
- GrantStmt *newnode = makeNode(GrantStmt);
+ GrantStmt *newnode = makeNode(GrantStmt);
newnode->is_grant = from->is_grant;
Node_Copy(from, newnode, relnames);
LockStmt *newnode = makeNode(LockStmt);
Node_Copy(from, newnode, rellist);
-
+
newnode->mode = from->mode;
return newnode;
switch (nodeTag(from))
{
-
/*
* PLAN NODES
*/
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.106 2001/10/18 17:30:14 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.107 2001/10/25 05:49:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static bool
_equalExpr(Expr *a, Expr *b)
{
-
/*
* We do not examine typeOid, since the optimizer often doesn't bother
* to set it in created nodes, and it is logically a derivative of the
static bool
_equalRelOptInfo(RelOptInfo *a, RelOptInfo *b)
{
-
/*
* We treat RelOptInfos as equal if they refer to the same base rels
* joined in the same order. Is this appropriate/sufficient?
static bool
_equalIndexOptInfo(IndexOptInfo *a, IndexOptInfo *b)
{
-
/*
* We treat IndexOptInfos as equal if they refer to the same index. Is
* this sufficient?
return false;
if (a->ispusheddown != b->ispusheddown)
return false;
+
/*
* We ignore eval_cost, this_selec, left/right_pathkey, and
* left/right_bucketsize, since they may not be set yet, and should be
- * derivable from the clause anyway. Probably it's not really necessary
- * to compare any of these remaining fields ...
+ * derivable from the clause anyway. Probably it's not really
+ * necessary to compare any of these remaining fields ...
*/
if (!equal(a->subclauseindices, b->subclauseindices))
return false;
/*
* We do not check the internal-to-the-planner fields: base_rel_list,
- * other_rel_list, join_rel_list, equi_key_list, query_pathkeys.
- * They might not be set yet, and in any case they should be derivable
- * from the other fields.
+ * other_rel_list, join_rel_list, equi_key_list, query_pathkeys. They
+ * might not be set yet, and in any case they should be derivable from
+ * the other fields.
*/
return true;
}
{
return equalstr(a->username, b->username)
&& equalstr(a->groupname, b->groupname);
-}
+}
static bool
_equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/nodeFuncs.c,v 1.14 2001/03/22 03:59:32 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/nodeFuncs.c,v 1.15 2001/10/25 05:49:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
var_is_rel(Var *var)
{
return (bool)
- !(var_is_inner(var) || var_is_outer(var));
+ !(var_is_inner(var) || var_is_outer(var));
}
/*****************************************************************************
else
return false;
}
-
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.145 2001/08/21 16:36:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.146 2001/10/25 05:49:31 momjian Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
if (node->utilityStmt)
{
-
/*
* Hack to make up for lack of outfuncs for utility-stmt nodes
*/
{
switch (value->type)
{
- case T_Integer:
+ case T_Integer:
appendStringInfo(str, " %ld ", value->val.ival);
break;
case T_Float:
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.48 2001/10/18 16:11:41 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.49 2001/10/25 05:49:31 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
outputstr = DatumGetCString(OidFunctionCall3(typoutput,
c->constvalue,
- ObjectIdGetDatum(typelem),
+ ObjectIdGetDatum(typelem),
Int32GetDatum(-1)));
printf("%s", outputstr);
pfree(outputstr);
{
switch (nodeTag(p))
{
- case T_Plan:
+ case T_Plan:
return "PLAN";
case T_Result:
return "RESULT";
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.30 2001/03/22 17:41:47 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.31 2001/10/25 05:49:31 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
* us. We know the token will end at a character that strtol will
* stop at, so we do not need to modify the string.
*/
- long val;
- char *endptr;
+ long val;
+ char *endptr;
errno = 0;
val = strtol(token, &endptr, 10);
if (endptr != token + length || errno == ERANGE
#ifdef HAVE_LONG_INT_64
- /* if long > 32 bits, check for overflow of int4 */
+ /* if long > 32 bits, check for overflow of int4 */
|| val != (long) ((int32) val)
#endif
- )
+ )
return T_Float;
return T_Integer;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.112 2001/07/03 16:52:48 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.113 2001/10/25 05:49:31 momjian Exp $
*
* NOTES
* Most of the read functions for plan nodes are tested. (In fact, they
local_node->utilityStmt = NULL;
else
{
-
/*
* Hack to make up for lack of readfuncs for utility-stmt nodes
*
static NullTest *
_readNullTest(void)
{
- NullTest *local_node;
- char *token;
+ NullTest *local_node;
+ char *token;
int length;
local_node = makeNode(NullTest);
static BooleanTest *
_readBooleanTest(void)
{
- BooleanTest *local_node;
- char *token;
+ BooleanTest *local_node;
+ char *token;
int length;
local_node = makeNode(BooleanTest);
* geqo_erx.c
* edge recombination crossover [ER]
*
-* $Id: geqo_erx.c,v 1.15 1999/07/16 04:59:08 momjian Exp $
+* $Id: geqo_erx.c,v 1.16 2001/10/25 05:49:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
for (index1 = 0; index1 < num_gene; index1++)
{
-
/*
* presume the tour is circular, i.e. 1->2, 2->3, 3->1 this
* operaton maps n back to 1
for (i = 1; i < num_gene; i++)
{
-
/*
* as each point is entered into the tour, remove it from the edge
* table
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_main.c,v 1.28 2001/06/03 14:53:56 petere Exp $
+ * $Id: geqo_main.c,v 1.29 2001/10/25 05:49:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Edge *edge_table; /* list of edges */
int edge_failures = 0;
float difference;
-
#endif
#if defined(CX) || defined(PX) || defined(OX1) || defined(OX2)
City *city_table; /* list of cities */
-
#endif
#if defined(CX)
int cycle_diffs = 0;
int mutations = 0;
-
#endif
/* set GA parameters */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/predmig.c,v 1.10 2001/03/22 06:16:14 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/predmig.c,v 1.11 2001/10/25 05:49:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (is_clause(tmpstream)
&& get_pathptr(pathstream) != get_pathptr(tmpstream))
{
-
/*
* * If restriction moved above a Join after sort, we pull it *
* up in the join plan. * If restriction moved down, we
get_groupup((Stream) get_downstream(temp))) &&
get_grouprank(parent) < get_grouprank(temp))
{
- progress = true;/* we formed a new group */
+ progress = true; /* we formed a new group */
set_groupup(temp, true);
set_groupcost(temp,
get_groupcost(temp) +
}
-/* ------------------- UTILITY FUNCTIONS ------------------------- */
+/* ------------------- UTILITY FUNCTIONS ------------------------- */
/*
** xfunc_free_stream
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.16 2001/03/22 06:16:14 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.17 2001/10/25 05:49:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
else if (maxrank != -(MAXFLOAT))
{
-
/*
* * we've left an expensive restriction below a join. Since *
* we may pullup this restriction in predmig.c, we'd best *
}
else if (IsA(clause, Iter))
{
-
/*
* * An Iter returns a setof things, so return the width of a
* single * thing. * Note: THIS MAY NOT WORK RIGHT WHEN AGGS GET
}
else if (fast_is_clause(clause))
{
-
/*
* * get function associated with this Oper, and treat this as * a
* Func
if (get_func_tlist(func) != LispNil)
{
-
/*
* this function has a projection on it. Get the length of
* the projected attribute
tle = tlistentry_member((Var) clause, get_targetlist(rel));
if (tle == LispNil)
{
-
/*
* * The attribute we need is not in the target list, * so we
* have to add it. *
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.79 2001/10/18 16:11:41 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.80 2001/10/25 05:49:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static void set_plain_rel_pathlist(Query *root, RelOptInfo *rel,
RangeTblEntry *rte);
static void set_inherited_rel_pathlist(Query *root, RelOptInfo *rel,
- Index rti, RangeTblEntry *rte,
- List *inheritlist);
+ Index rti, RangeTblEntry *rte,
+ List *inheritlist);
static void set_subquery_pathlist(Query *root, RelOptInfo *rel,
- Index rti, RangeTblEntry *rte);
+ Index rti, RangeTblEntry *rte);
static RelOptInfo *make_one_rel_by_joins(Query *root, int levels_needed,
List *initial_rels);
* Build access paths for a inheritance tree rooted at rel
*
* inheritlist is a list of RT indexes of all tables in the inheritance tree,
- * including a duplicate of the parent itself. Note we will not come here
+ * including a duplicate of the parent itself. Note we will not come here
* unless there's at least one child in addition to the parent.
*
* NOTE: the passed-in rel and RTE will henceforth represent the appended
elog(ERROR, "SELECT FOR UPDATE is not supported for inherit queries");
/*
- * The executor will check the parent table's access permissions when it
- * examines the parent's inheritlist entry. There's no need to check
- * twice, so turn off access check bits in the original RTE.
+ * The executor will check the parent table's access permissions when
+ * it examines the parent's inheritlist entry. There's no need to
+ * check twice, so turn off access check bits in the original RTE.
*/
rte->checkForRead = false;
rte->checkForWrite = false;
/*
* Copy the parent's targetlist and restriction quals to the
* child, with attribute-number adjustment as needed. We don't
- * bother to copy the join quals, since we can't do any joining
- * of the individual tables.
+ * bother to copy the join quals, since we can't do any joining of
+ * the individual tables.
*/
childrel->targetlist = (List *)
adjust_inherited_attrs((Node *) rel->targetlist,
/*
* If there are any restriction clauses that have been attached to the
- * subquery relation, consider pushing them down to become HAVING quals
- * of the subquery itself. (Not WHERE clauses, since they may refer to
- * subquery outputs that are aggregate results. But planner.c will
- * transfer them into the subquery's WHERE if they do not.) This
- * transformation is useful because it may allow us to generate a better
- * plan for the subquery than evaluating all the subquery output rows
- * and then filtering them.
+ * subquery relation, consider pushing them down to become HAVING
+ * quals of the subquery itself. (Not WHERE clauses, since they may
+ * refer to subquery outputs that are aggregate results. But
+ * planner.c will transfer them into the subquery's WHERE if they do
+ * not.) This transformation is useful because it may allow us to
+ * generate a better plan for the subquery than evaluating all the
+ * subquery output rows and then filtering them.
*
* There are several cases where we cannot push down clauses:
*
* 1. If the subquery contains set ops (UNION/INTERSECT/EXCEPT) we do not
- * push down any qual clauses, since the planner doesn't support quals at
- * the top level of a setop. (With suitable analysis we could try to push
- * the quals down into the component queries of the setop, but getting it
- * right seems nontrivial. Work on this later.)
+ * push down any qual clauses, since the planner doesn't support quals
+ * at the top level of a setop. (With suitable analysis we could try
+ * to push the quals down into the component queries of the setop, but
+ * getting it right seems nontrivial. Work on this later.)
*
* 2. If the subquery has a LIMIT clause or a DISTINCT ON clause, we must
* not push down any quals, since that could change the set of rows
* returned. (Actually, we could push down quals into a DISTINCT ON
- * subquery if they refer only to DISTINCT-ed output columns, but checking
- * that seems more work than it's worth. In any case, a plain DISTINCT is
- * safe to push down past.)
+ * subquery if they refer only to DISTINCT-ed output columns, but
+ * checking that seems more work than it's worth. In any case, a
+ * plain DISTINCT is safe to push down past.)
*
* 3. We do not push down clauses that contain subselects, mainly because
- * I'm not sure it will work correctly (the subplan hasn't yet transformed
- * sublinks to subselects).
+ * I'm not sure it will work correctly (the subplan hasn't yet
+ * transformed sublinks to subselects).
*
* Non-pushed-down clauses will get evaluated as qpquals of the
* SubqueryScan node.
else
{
/*
- * We need to replace Vars in the clause (which must refer to
- * outputs of the subquery) with copies of the subquery's
- * targetlist expressions. Note that at this point, any
- * uplevel Vars in the clause should have been replaced with
- * Params, so they need no work.
+ * We need to replace Vars in the clause (which must refer
+ * to outputs of the subquery) with copies of the
+ * subquery's targetlist expressions. Note that at this
+ * point, any uplevel Vars in the clause should have been
+ * replaced with Params, so they need no work.
*/
clause = ResolveNew(clause, rti, 0,
subquery->targetList,
CMD_SELECT, 0);
subquery->havingQual = make_and_qual(subquery->havingQual,
clause);
+
/*
* We need not change the subquery's hasAggs or
- * hasSublinks flags, since we can't be pushing
- * down any aggregates that weren't there before,
- * and we don't push down subselects at all.
+ * hasSublinks flags, since we can't be pushing down any
+ * aggregates that weren't there before, and we don't push
+ * down subselects at all.
*/
}
}
if (levels_needed == 1)
{
-
/*
* Single jointree node, so we're done.
*/
}
else
{
-
/*
* Consider the different orders in which we could join the rels,
* using either GEQO or regular optimizer.
static void
print_path(Query *root, Path *path, int indent)
{
- const char *ptype;
+ const char *ptype;
bool join;
int i;
foreach(l, rel->joininfo)
{
- JoinInfo *j = (JoinInfo *) lfirst(l);
+ JoinInfo *j = (JoinInfo *) lfirst(l);
printf("\tjoininfo (");
print_relids(j->unjoined_relids);
printf("\n");
fflush(stdout);
}
-
#endif /* OPTIMIZER_DEBUG */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.46 2001/06/25 21:11:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.47 2001/10/25 05:49:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
} RangeQueryClause;
static void addRangeClause(RangeQueryClause **rqlist, Node *clause,
- bool varonleft, bool isLTsel, Selectivity s2);
+ bool varonleft, bool isLTsel, Selectivity s2);
/****************************************************************************
{
if (s2 < -0.01)
{
-
/*
* No data available --- use a default estimate that
* is small, but not real small.
}
else
{
-
/*
* It's just roundoff error; use a small positive
* value
for (rqelem = *rqlist; rqelem; rqelem = rqelem->next)
{
-
/*
* We use full equal() here because the "var" might be a function
* of one or more attributes of the same relation...
if (rte->subquery)
{
-
/*
* XXX not smart about subquery references... any way to
* do better?
}
else
{
-
/*
* A Var at the top of a clause must be a bool Var. This
* is equivalent to the clause reln.attribute = 't', so we
BooleanEqualOperator,
makeList2(var,
MAKEBOOLCONST(true,
- false)),
+ false)),
varRelid);
}
}
}
else if (or_clause(clause))
{
-
/*
* Selectivities for an 'or' clause are computed as s1+s2 - s1*s2
* to account for the probable overlap of selected tuple sets. XXX
if (varRelid != 0)
{
-
/*
* If we are considering a nestloop join then all clauses are
* restriction clauses, since we are only interested in the
}
else
{
-
/*
* Otherwise, it's a join if there's more than one relation
* used.
if (is_join_clause)
{
/* Estimate selectivity for a join clause. */
- s1 = join_selectivity(root, opno,
+ s1 = join_selectivity(root, opno,
((Expr *) clause)->args);
}
else
{
/* Estimate selectivity for a restriction clause. */
- s1 = restriction_selectivity(root, opno,
- ((Expr *) clause)->args, varRelid);
+ s1 = restriction_selectivity(root, opno,
+ ((Expr *) clause)->args, varRelid);
}
}
else if (is_funcclause(clause))
{
-
/*
* This is not an operator, so we guess at the selectivity. THIS
* IS A HACK TO GET V4 OUT THE DOOR. FUNCS SHOULD BE ABLE TO HAVE
}
else if (is_subplan(clause))
{
-
/*
* Just for the moment! FIX ME! - vadim 02/04/98
*/
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.78 2001/08/21 16:36:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.79 2001/10/25 05:49:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*
* When the index ordering is exactly correlated with the table ordering
* (just after a CLUSTER, for example), the number of pages fetched should
- * be just sT. What's more, these will be sequential fetches, not the
- * random fetches that occur in the uncorrelated case. So, depending on
+ * be just sT. What's more, these will be sequential fetches, not the
+ * random fetches that occur in the uncorrelated case. So, depending on
* the extent of correlation, we should estimate the actual I/O cost
- * somewhere between s * T * 1.0 and PF * random_cost. We currently
+ * somewhere between s * T * 1.0 and PF * random_cost. We currently
* interpolate linearly between these two endpoints based on the
* correlation squared (XXX is that appropriate?).
*
}
else
{
- double lim;
+ double lim;
lim = (2.0 * T * b) / (2.0 * T - b);
if (tuples_fetched <= lim)
}
/*
- * min_IO_cost corresponds to the perfectly correlated case (csquared=1),
- * max_IO_cost to the perfectly uncorrelated case (csquared=0). Note
- * that we just charge random_page_cost per page in the uncorrelated
- * case, rather than using cost_nonsequential_access, since we've already
- * accounted for caching effects by using the Mackert model.
+ * min_IO_cost corresponds to the perfectly correlated case
+ * (csquared=1), max_IO_cost to the perfectly uncorrelated case
+ * (csquared=0). Note that we just charge random_page_cost per page
+ * in the uncorrelated case, rather than using
+ * cost_nonsequential_access, since we've already accounted for
+ * caching effects by using the Mackert model.
*/
min_IO_cost = ceil(indexSelectivity * T);
max_IO_cost = pages_fetched * random_page_cost;
/*
- * Now interpolate based on estimated index order correlation
- * to get total disk I/O cost for main table accesses.
+ * Now interpolate based on estimated index order correlation to get
+ * total disk I/O cost for main table accesses.
*/
csquared = indexCorrelation * indexCorrelation;
/*
* Estimate CPU costs per tuple.
*
- * Normally the indexquals will be removed from the list of
- * restriction clauses that we have to evaluate as qpquals, so we
- * should subtract their costs from baserestrictcost. XXX For a lossy
- * index, not all the quals will be removed and so we really shouldn't
- * subtract their costs; but detecting that seems more expensive than
- * it's worth. Also, if we are doing a join then some of the indexquals
- * are join clauses and shouldn't be subtracted. Rather than work out
- * exactly how much to subtract, we don't subtract anything.
+ * Normally the indexquals will be removed from the list of restriction
+ * clauses that we have to evaluate as qpquals, so we should subtract
+ * their costs from baserestrictcost. XXX For a lossy index, not all
+ * the quals will be removed and so we really shouldn't subtract their
+ * costs; but detecting that seems more expensive than it's worth.
+ * Also, if we are doing a join then some of the indexquals are join
+ * clauses and shouldn't be subtracted. Rather than work out exactly
+ * how much to subtract, we don't subtract anything.
*/
cpu_per_tuple = cpu_tuple_cost + baserel->baserestrictcost;
/*
* NOTE: clearly, we must pay both outer and inner paths' startup_cost
- * before we can start returning tuples, so the join's startup cost
- * is their sum. What's not so clear is whether the inner path's
+ * before we can start returning tuples, so the join's startup cost is
+ * their sum. What's not so clear is whether the inner path's
* startup_cost must be paid again on each rescan of the inner path.
- * This is not true if the inner path is materialized, but probably
- * is true otherwise. Since we don't yet have clean handling of the
+ * This is not true if the inner path is materialized, but probably is
+ * true otherwise. Since we don't yet have clean handling of the
* decision whether to materialize a path, we can't tell here which
* will happen. As a compromise, charge 50% of the inner startup cost
* for each restart.
/*
* The number of tuple comparisons needed depends drastically on the
* number of equal keys in the two source relations, which we have no
- * good way of estimating. Somewhat arbitrarily, we charge one
- * tuple comparison (one cpu_operator_cost) for each tuple in the
- * two source relations. This is probably a lower bound.
+ * good way of estimating. Somewhat arbitrarily, we charge one tuple
+ * comparison (one cpu_operator_cost) for each tuple in the two source
+ * relations. This is probably a lower bound.
*/
run_cost += cpu_operator_cost *
(outer_path->parent->rows + inner_path->parent->rows);
/*
* For each tuple that gets through the mergejoin proper, we charge
* cpu_tuple_cost plus the cost of evaluating additional restriction
- * clauses that are to be applied at the join. It's OK to use an
+ * clauses that are to be applied at the join. It's OK to use an
* approximate selectivity here, since in most cases this is a minor
* component of the cost.
*/
run_cost += cpu_operator_cost * outer_path->parent->rows;
/*
- * Determine bucketsize fraction for inner relation. First we have
- * to figure out which side of the hashjoin clause is the inner side.
+ * Determine bucketsize fraction for inner relation. First we have to
+ * figure out which side of the hashjoin clause is the inner side.
*/
Assert(length(hashclauses) == 1);
Assert(IsA(lfirst(hashclauses), RestrictInfo));
right = get_rightop(restrictinfo->clause);
/*
- * Since we tend to visit the same clauses over and over when
- * planning a large query, we cache the bucketsize estimate in
- * the RestrictInfo node to avoid repeated lookups of statistics.
+ * Since we tend to visit the same clauses over and over when planning
+ * a large query, we cache the bucketsize estimate in the RestrictInfo
+ * node to avoid repeated lookups of statistics.
*/
if (intMember(right->varno, inner_path->parent->relids))
{
/*
* The number of tuple comparisons needed is the number of outer
- * tuples times the typical number of tuples in a hash bucket,
- * which is the inner relation size times its bucketsize fraction.
- * We charge one cpu_operator_cost per tuple comparison.
+ * tuples times the typical number of tuples in a hash bucket, which
+ * is the inner relation size times its bucketsize fraction. We charge
+ * one cpu_operator_cost per tuple comparison.
*/
run_cost += cpu_operator_cost * outer_path->parent->rows *
ceil(inner_path->parent->rows * innerbucketsize);
/*
* For each tuple that gets through the hashjoin proper, we charge
* cpu_tuple_cost plus the cost of evaluating additional restriction
- * clauses that are to be applied at the join. It's OK to use an
+ * clauses that are to be applied at the join. It's OK to use an
* approximate selectivity here, since in most cases this is a minor
* component of the cost.
*/
* distribution, so this will have to do for now.
*
* We can get the number of buckets the executor will use for the given
- * input relation. If the data were perfectly distributed, with the same
+ * input relation. If the data were perfectly distributed, with the same
* number of tuples going into each available bucket, then the bucketsize
* fraction would be 1/nbuckets. But this happy state of affairs will occur
* only if (a) there are at least nbuckets distinct data values, and (b)
- * we have a not-too-skewed data distribution. Otherwise the buckets will
+ * we have a not-too-skewed data distribution. Otherwise the buckets will
* be nonuniformly occupied. If the other relation in the join has a key
* distribution similar to this one's, then the most-loaded buckets are
* exactly those that will be probed most often. Therefore, the "average"
int nnumbers;
/*
- * Lookup info about var's relation and attribute;
- * if none available, return default estimate.
+ * Lookup info about var's relation and attribute; if none available,
+ * return default estimate.
*/
if (!IsA(var, Var))
return 0.1;
avgfreq = (1.0 - stats->stanullfrac) / ndistinct;
/*
- * Adjust ndistinct to account for restriction clauses. Observe we are
- * assuming that the data distribution is affected uniformly by the
- * restriction clauses!
+ * Adjust ndistinct to account for restriction clauses. Observe we
+ * are assuming that the data distribution is affected uniformly by
+ * the restriction clauses!
*
* XXX Possibly better way, but much more expensive: multiply by
- * selectivity of rel's restriction clauses that mention the target Var.
+ * selectivity of rel's restriction clauses that mention the target
+ * Var.
*/
ndistinct *= rel->rows / rel->tuples;
}
/*
- * Adjust estimated bucketsize upward to account for skewed distribution.
+ * Adjust estimated bucketsize upward to account for skewed
+ * distribution.
*/
if (avgfreq > 0.0 && mcvfreq > avgfreq)
estfract *= mcvfreq / avgfreq;
static Selectivity
approx_selectivity(Query *root, List *quals)
{
- Selectivity total = 1.0;
+ Selectivity total = 1.0;
List *l;
foreach(l, quals)
{
Node *qual = (Node *) lfirst(l);
- Selectivity selec;
+ Selectivity selec;
/*
* RestrictInfo nodes contain a this_selec field reserved for this
* routine's use, so that it's not necessary to evaluate the qual
- * clause's selectivity more than once. If the clause's selectivity
- * hasn't been computed yet, the field will contain -1.
+ * clause's selectivity more than once. If the clause's
+ * selectivity hasn't been computed yet, the field will contain
+ * -1.
*/
if (qual && IsA(qual, RestrictInfo))
{
* NB: this works best on base relations because it prefers to look at
* real Vars. It will fail to make use of pg_statistic info when applied
* to a subquery relation, even if the subquery outputs are simple vars
- * that we could have gotten info for. Is it worth trying to be smarter
+ * that we could have gotten info for. Is it worth trying to be smarter
* about subqueries?
*/
static void
foreach(tllist, rel->targetlist)
{
TargetEntry *tle = (TargetEntry *) lfirst(tllist);
- int32 item_width;
+ int32 item_width;
/*
* If it's a Var, try to get statistical info from pg_statistic.
*/
if (tle->expr && IsA(tle->expr, Var))
{
- Var *var = (Var *) tle->expr;
- Oid relid;
+ Var *var = (Var *) tle->expr;
+ Oid relid;
relid = getrelid(var->varno, root->rtable);
if (relid != InvalidOid)
}
}
}
+
/*
* Not a Var, or can't find statistics for it. Estimate using
* just the type info.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.111 2001/08/21 16:36:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.112 2001/10/25 05:49:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (restriction_is_or_clause(restrictinfo))
{
-
/*
* Add this index to the subclause index list for each
* subclause that it matches.
Oid *classes = index->classlist;
/*
- * Extract relevant indexclauses in indexkey order. This is essentially
- * just like group_clauses_by_indexkey() except that the input and
- * output are lists of bare clauses, not of RestrictInfo nodes.
+ * Extract relevant indexclauses in indexkey order. This is
+ * essentially just like group_clauses_by_indexkey() except that the
+ * input and output are lists of bare clauses, not of RestrictInfo
+ * nodes.
*/
do
{
{
foreach(item, orsubclause->args)
{
- Expr *subsubclause = (Expr *) lfirst(item);
+ Expr *subsubclause = (Expr *) lfirst(item);
if (match_clause_to_indexkey(rel, index,
curIndxKey, curClass,
else if (match_clause_to_indexkey(rel, index,
curIndxKey, curClass,
orsubclause, false))
- {
clausegroup = makeList1(orsubclause);
- }
/*
* If we found no clauses for this indexkey in the OR subclause
}
/*
- * If still no clauses match this key, we're done; we don't want to
- * look at keys to its right.
+ * If still no clauses match this key, we're done; we don't want
+ * to look at keys to its right.
*/
if (clausegroup == NIL)
break;
if (!join)
{
-
/*
* Not considering joins, so check for clauses of the form:
* (indexkey operator constant) or (constant operator indexkey).
}
else
{
-
/*
* Check for an indexqual that could be handled by a nestloop
* join. We need the index key to be compared against an
{
if (new_op != expr_op)
{
-
/*
* OK, we found a binary-compatible operator of the same name;
* now does it match the index?
* and a "simple clause" restriction.
*
* We have two strategies for determining whether one simple clause
- * implies another. A simple and general way is to see if they are
+ * implies another. A simple and general way is to see if they are
* equal(); this works for any kind of expression. (Actually, there
* is an implied assumption that the functions in the expression are
* cachable, ie dependent only on their input arguments --- but this
return true;
/*
- * Can't do anything more unless they are both binary opclauses with
- * a Var on the left and a Const on the right.
+ * Can't do anything more unless they are both binary opclauses with a
+ * Var on the left and a Const on the right.
*/
if (!is_opclause((Node *) predicate))
return false;
/*
* 1. Find a "btree" strategy number for the pred_op
*
- * The following assumes that any given operator will only be in a
- * single btree operator class. This is true at least for all the
+ * The following assumes that any given operator will only be in a single
+ * btree operator class. This is true at least for all the
* pre-defined operator classes. If it isn't true, then whichever
* operator class happens to be returned first for the given operator
* will be used to find the associated strategy numbers for the test.
relation = heap_openr(AccessMethodOperatorRelationName, AccessShareLock);
scan = heap_beginscan(relation, false, SnapshotNow, 1, entry);
-
+
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
{
aform = (Form_pg_amop) GETSTRUCT(tuple);
/* Get the predicate operator's btree strategy number (1 to 5) */
pred_strategy = (StrategyNumber) aform->amopstrategy;
Assert(pred_strategy >= 1 && pred_strategy <= 5);
- /* Remember which operator class this strategy number came from */
+
+ /*
+ * Remember which operator class this strategy number came
+ * from
+ */
opclass_id = aform->amopclaid;
break;
}
/*
* Note that we are making a pathnode for a single-scan indexscan;
- * therefore, both indexinfo and indexqual should be single-element
- * lists.
+ * therefore, both indexinfo and indexqual should be
+ * single-element lists.
*/
pathnode->indexinfo = makeList1(index);
pathnode->indexqual = makeList1(indexquals);
RelOptInfo *rel,
IndexOptInfo *index)
{
-
/*
* Ignore any RelabelType node above the indexkey. This is needed to
* be able to apply indexscanning in binary-compatible-operator cases.
if (index->indproc == InvalidOid)
{
-
/*
* Simple index.
*/
switch (expr_op)
{
-
/*
* LIKE and regex operators are not members of any index
* opclass, so if we find one in an indexqual list we can
/*
* Given a leftop and a rightop, and a inet-class sup/sub operator,
* generate suitable indexqual condition(s). expr_op is the original
- * operator.
+ * operator.
*/
static List *
network_prefix_quals(Var *leftop, Oid expr_op, Datum rightop)
{
- bool is_eq;
- char *opr1name;
- Datum opr1right;
- Datum opr2right;
- Oid opr1oid;
- Oid opr2oid;
+ bool is_eq;
+ char *opr1name;
+ Datum opr1right;
+ Datum opr2right;
+ Oid opr1oid;
+ Oid opr2oid;
List *result;
Oid datatype;
Oper *op;
switch (expr_op)
{
case OID_INET_SUB_OP:
- datatype = INETOID;
- is_eq = false;
+ datatype = INETOID;
+ is_eq = false;
break;
case OID_INET_SUBEQ_OP:
- datatype = INETOID;
- is_eq = true;
+ datatype = INETOID;
+ is_eq = true;
break;
case OID_CIDR_SUB_OP:
- datatype = CIDROID;
- is_eq = false;
+ datatype = CIDROID;
+ is_eq = false;
break;
case OID_CIDR_SUBEQ_OP:
- datatype = CIDROID;
- is_eq = true;
+ datatype = CIDROID;
+ is_eq = true;
break;
default:
elog(ERROR, "network_prefix_quals: unexpected operator %u",
expr_op);
return NIL;
- }
+ }
/*
- * create clause "key >= network_scan_first( rightop )", or ">"
- * if the operator disallows equality.
+ * create clause "key >= network_scan_first( rightop )", or ">" if the
+ * operator disallows equality.
*/
opr1name = is_eq ? ">=" : ">";
elog(ERROR, "network_prefix_quals: no %s operator for type %u",
opr1name, datatype);
- opr1right = network_scan_first( rightop );
+ opr1right = network_scan_first(rightop);
op = makeOper(opr1oid, InvalidOid, BOOLOID);
- expr = make_opclause(op, leftop,
- (Var *) makeConst(datatype, -1, opr1right,
+ expr = make_opclause(op, leftop,
+ (Var *) makeConst(datatype, -1, opr1right,
false, false, false, false));
result = makeList1(expr);
elog(ERROR, "network_prefix_quals: no <= operator for type %u",
datatype);
- opr2right = network_scan_last( rightop );
+ opr2right = network_scan_last(rightop);
op = makeOper(opr2oid, InvalidOid, BOOLOID);
- expr = make_opclause(op, leftop,
- (Var *) makeConst(datatype, -1, opr2right,
+ expr = make_opclause(op, leftop,
+ (Var *) makeConst(datatype, -1, opr2right,
false, false, false, false));
result = lappend(result, expr);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.65 2001/06/05 05:26:04 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.66 2001/10/25 05:49:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
RelOptInfo *outerrel, RelOptInfo *innerrel,
List *restrictlist, List *mergeclause_list,
JoinType jointype);
-
#endif
static void hash_inner_and_outer(Query *root, RelOptInfo *joinrel,
RelOptInfo *outerrel, RelOptInfo *innerrel,
/*
* Nestloop only supports inner and left joins. Also, if we are doing
* a right or full join, we must use *all* the mergeclauses as join
- * clauses, else we will not have a valid plan. (Although these two flags
- * are currently inverses, keep them separate for clarity and possible
- * future changes.)
+ * clauses, else we will not have a valid plan. (Although these two
+ * flags are currently inverses, keep them separate for clarity and
+ * possible future changes.)
*/
switch (jointype)
{
default:
elog(ERROR, "match_unsorted_outer: unexpected join type %d",
(int) jointype);
- nestjoinOK = false; /* keep compiler quiet */
+ nestjoinOK = false; /* keep compiler quiet */
useallclauses = false;
break;
}
if (nestjoinOK)
{
-
/*
* Always consider a nestloop join with this outer and
* cheapest-total-cost inner. Consider nestloops using the
- * cheapest-startup-cost inner as well, and the best
- * innerjoin indexpath.
+ * cheapest-startup-cost inner as well, and the best innerjoin
+ * indexpath.
*/
add_path(joinrel, (Path *)
create_nestloop_path(root,
/* Found a cheap (or even-cheaper) sorted path */
if (innerpath != cheapest_total_inner)
{
-
/*
* Avoid rebuilding clause list if we already made
* one; saves memory in big join trees...
}
cheapest_startup_inner = innerpath;
}
+
/*
* Don't consider truncated sortkeys if we need all clauses.
*/
default:
elog(ERROR, "match_unsorted_inner: unexpected join type %d",
(int) jointype);
- useallclauses = false; /* keep compiler quiet */
+ useallclauses = false; /* keep compiler quiet */
break;
}
}
}
}
-
#endif
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.54 2001/10/18 16:11:41 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.55 2001/10/25 05:49:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (old_rel->joininfo != NIL)
{
-
/*
* Note that if all available join clauses for this rel
* require more than one other rel, we will fail to make any
}
else
{
-
/*
* Oops, we have a relation that is not joined to any other
* relation. Cartesian product time.
*/
if (result_rels == NIL)
{
-
/*
* This loop is just like the first one, except we always call
* make_rels_by_clauseless_joins().
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.44 2001/06/05 17:13:52 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.45 2001/10/25 05:49:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
pathnode->indexinfo = lappend(pathnode->indexinfo, best_indexinfo);
pathnode->indexqual = lappend(pathnode->indexqual, best_indexqual);
- if (slist == subclauses) /* first scan? */
+ if (slist == subclauses)/* first scan? */
pathnode->path.startup_cost = best_startup_cost;
pathnode->path.total_cost += best_total_cost;
RelOptInfo *rel,
Expr *subclause,
List *indices,
- IndexOptInfo **retIndexInfo, /* return value */
+ IndexOptInfo **retIndexInfo, /* return value */
List **retIndexQual, /* return value */
Cost *retStartupCost, /* return value */
Cost *retTotalCost) /* return value */
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.33 2001/10/18 16:11:41 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.34 2001/10/25 05:49:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (item1here || item2here)
{
-
/*
* If find both in same equivalence set, no need to do any
* more
if (key1 == NIL && key2 == NIL)
return PATHKEYS_EQUAL;
if (key1 != NIL)
- return PATHKEYS_BETTER1;/* key1 is longer */
+ return PATHKEYS_BETTER1; /* key1 is longer */
return PATHKEYS_BETTER2; /* key2 is longer */
}
if (key1 == NIL && key2 == NIL)
return PATHKEYS_EQUAL;
if (key1 != NIL)
- return PATHKEYS_BETTER1;/* key1 is longer */
+ return PATHKEYS_BETTER1; /* key1 is longer */
return PATHKEYS_BETTER2; /* key2 is longer */
}
{
switch (compare_pathkeys(keys1, keys2))
{
- case PATHKEYS_EQUAL:
- case PATHKEYS_BETTER2:
+ case PATHKEYS_EQUAL:
+ case PATHKEYS_BETTER2:
return true;
default:
break;
{
switch (compare_noncanonical_pathkeys(keys1, keys2))
{
- case PATHKEYS_EQUAL:
- case PATHKEYS_BETTER2:
+ case PATHKEYS_EQUAL:
+ case PATHKEYS_BETTER2:
return true;
default:
break;
RelOptInfo *joinrel,
List *outer_pathkeys)
{
-
/*
* This used to be quite a complex bit of code, but now that all
* pathkey sublists start out life canonicalized, we don't have to do
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.109 2001/09/21 04:06:04 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.110 2001/10/25 05:49:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Plan *outer_plan, List *outer_tlist,
Plan *inner_plan, List *inner_tlist);
static void fix_indxqual_references(List *indexquals, IndexPath *index_path,
- List **fixed_indexquals,
- List **recheck_indexquals);
+ List **fixed_indexquals,
+ List **recheck_indexquals);
static void fix_indxqual_sublist(List *indexqual, int baserelid,
- IndexOptInfo *index,
- List **fixed_quals, List **recheck_quals);
+ IndexOptInfo *index,
+ List **fixed_quals, List **recheck_quals);
static Node *fix_indxqual_operand(Node *node, int baserelid,
- IndexOptInfo *index,
- Oid *opclass);
+ IndexOptInfo *index,
+ Oid *opclass);
static List *switch_outer(List *clauses);
static void copy_path_costsize(Plan *dest, Path *src);
static void copy_plan_costsize(Plan *dest, Plan *src);
/*
* The qpqual list must contain all restrictions not automatically
- * handled by the index. Normally the predicates in the indxqual
- * are checked fully by the index, but if the index is "lossy" for
- * a particular operator (as signaled by the amopreqcheck flag in
+ * handled by the index. Normally the predicates in the indxqual are
+ * checked fully by the index, but if the index is "lossy" for a
+ * particular operator (as signaled by the amopreqcheck flag in
* pg_amop), then we need to double-check that predicate in qpqual,
* because the index may return more tuples than match the predicate.
*
/*
* The executor needs a copy with the indexkey on the left of each
- * clause and with index attr numbers substituted for table ones.
- * This pass also looks for "lossy" operators.
+ * clause and with index attr numbers substituted for table ones. This
+ * pass also looks for "lossy" operators.
*/
fix_indxqual_references(indxqual, best_path,
&fixed_indxqual, &recheck_indxqual);
/*
- * If there were any "lossy" operators, need to add back the appropriate
- * qual clauses to the qpqual. When there is just one indexscan being
- * performed (ie, we have simple AND semantics), we can just add the
- * lossy clauses themselves to qpqual. If we have OR-of-ANDs, we'd
- * better add the entire original indexqual to make sure that the
- * semantics are correct.
+ * If there were any "lossy" operators, need to add back the
+ * appropriate qual clauses to the qpqual. When there is just one
+ * indexscan being performed (ie, we have simple AND semantics), we
+ * can just add the lossy clauses themselves to qpqual. If we have
+ * OR-of-ANDs, we'd better add the entire original indexqual to make
+ * sure that the semantics are correct.
*/
if (recheck_indxqual != NIL)
{
if (IsA(inner_plan, IndexScan))
{
-
/*
* An index is being used to reduce the number of tuples scanned
* in the inner relation. If there are join clauses being used
}
else if (IsA_Join(inner_plan))
{
-
/*
* Materialize the inner join for speed reasons.
*
* left. (Someday the executor might not need this, but for now it does.)
* * If the indexable operator is marked 'amopreqcheck' in pg_amop, then
* the index is "lossy" for this operator: it may return more tuples than
- * actually satisfy the operator condition. For each such operator, we
+ * actually satisfy the operator condition. For each such operator, we
* must add (the original form of) the indexqual clause to the "qpquals"
* of the indexscan node, where the operator will be re-evaluated to
* ensure it passes.
*/
static void
fix_indxqual_references(List *indexquals, IndexPath *index_path,
- List **fixed_indexquals, List **recheck_indexquals)
+ List **fixed_indexquals, List **recheck_indexquals)
{
List *fixed_quals = NIL;
List *recheck_quals = NIL;
/*
* Check to see if the indexkey is on the right; if so, commute
- * the clause. The indexkey should be the side that refers to
+ * the clause. The indexkey should be the side that refers to
* (only) the base relation.
*/
leftvarnos = pull_varnos((Node *) lfirst(newclause->args));
fixed_qual = lappend(fixed_qual, newclause);
/*
- * Finally, check to see if index is lossy for this operator.
- * If so, add (a copy of) original form of clause to recheck list.
+ * Finally, check to see if index is lossy for this operator. If
+ * so, add (a copy of) original form of clause to recheck list.
*/
if (op_requires_recheck(newopno, opclass))
recheck_qual = lappend(recheck_qual,
fix_indxqual_operand(Node *node, int baserelid, IndexOptInfo *index,
Oid *opclass)
{
-
/*
* Remove any binary-compatible relabeling of the indexkey
*/
* the returned varattno must be 1.
*/
Assert(index->indproc != InvalidOid);
- Assert(is_funcclause(node)); /* not a very thorough check, but easy */
+ Assert(is_funcclause(node)); /* not a very thorough check, but easy */
/* classlist[0] is the only class of a functional index */
*opclass = index->classlist[0];
Assert(op && IsA(op, Var));
if (var_is_outer(op))
{
-
/*
* Duplicate just enough of the structure to allow commuting
* the clause without changing the original list. Could use
return newTlist;
return tlist; /* do nothing for now - ay 10/94 */
}
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.64 2001/10/18 16:11:41 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.65 2001/10/25 05:49:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Relids join_relids);
static void add_vars_to_targetlist(Query *root, List *vars);
static bool qual_is_redundant(Query *root, RestrictInfo *restrictinfo,
- List *restrictlist);
+ List *restrictlist);
static void check_mergejoinable(RestrictInfo *restrictinfo);
static void check_hashjoinable(RestrictInfo *restrictinfo);
/*
* Presently the executor cannot support FOR UPDATE marking of
- * rels appearing on the nullable side of an outer join.
- * (It's somewhat unclear what that would mean, anyway: what should
- * we mark when a result row is generated from no element of the
- * nullable relation?) So, complain if target rel is FOR UPDATE.
+ * rels appearing on the nullable side of an outer join. (It's
+ * somewhat unclear what that would mean, anyway: what should we
+ * mark when a result row is generated from no element of the
+ * nullable relation?) So, complain if target rel is FOR UPDATE.
* It's sufficient to make this check once per rel, so do it only
* if rel wasn't already known nullable.
*/
* outerjoinset list of each baserel will show exactly those outer
* joins that are below the qual in the join tree.
*
- * If the qual came from implied-equality deduction, we can evaluate
- * the qual at its natural semantic level.
- *
+ * If the qual came from implied-equality deduction, we can evaluate the
+ * qual at its natural semantic level.
+ *
*/
if (isdeduced)
{
/*
* If the clause was deduced from implied equality, check to see
- * whether it is redundant with restriction clauses we already have
- * for this rel. Note we cannot apply this check to user-written
- * clauses, since we haven't found the canonical pathkey sets yet
- * while processing user clauses. (NB: no comparable check is done
- * in the join-clause case; redundancy will be detected when the
- * join clause is moved into a join rel's restriction list.)
+ * whether it is redundant with restriction clauses we already
+ * have for this rel. Note we cannot apply this check to
+ * user-written clauses, since we haven't found the canonical
+ * pathkey sets yet while processing user clauses. (NB: no
+ * comparable check is done in the join-clause case; redundancy
+ * will be detected when the join clause is moved into a join
+ * rel's restriction list.)
*/
if (!isdeduced ||
!qual_is_redundant(root, restrictinfo, rel->baserestrictinfo))
}
else
{
-
/*
* 'clause' references no rels, and therefore we have no place to
* attach it. Shouldn't get here if callers are working properly.
* the two sides represent equivalent PathKeyItems for path keys: any
* path that is sorted by one side will also be sorted by the other
* (as soon as the two rels are joined, that is). Record the key
- * equivalence for future use. (We can skip this for a deduced clause,
- * since the keys are already known equivalent in that case.)
+ * equivalence for future use. (We can skip this for a deduced
+ * clause, since the keys are already known equivalent in that case.)
*/
if (can_be_equijoin && restrictinfo->mergejoinoperator != InvalidOid &&
!isdeduced)
eq_operator = compatible_oper("=", ltype, rtype, true);
if (!HeapTupleIsValid(eq_operator))
{
-
/*
* Would it be safe to just not add the equality to the query if
* we have no suitable equality operator for the combination of
RestrictInfo *restrictinfo,
List *restrictlist)
{
- List *oldquals;
- List *olditem;
- Node *newleft;
- Node *newright;
- List *equalvars;
- bool someadded;
+ List *oldquals;
+ List *olditem;
+ Node *newleft;
+ Node *newright;
+ List *equalvars;
+ bool someadded;
/*
* Set cached pathkeys. NB: it is okay to do this now because this
/* If different, say "not redundant" (should never happen) */
if (restrictinfo->left_pathkey != restrictinfo->right_pathkey)
return false;
+
/*
* Scan existing quals to find those referencing same pathkeys.
* Usually there will be few, if any, so build a list of just the
}
if (oldquals == NIL)
return false;
+
/*
* Now, we want to develop a list of Vars that are known equal to the
- * left side of the new qual. We traverse the old-quals list repeatedly
- * to transitively expand the Vars list. If at any point we find we
- * can reach the right-side Var of the new qual, we are done. We give
- * up when we can't expand the equalvars list any more.
+ * left side of the new qual. We traverse the old-quals list
+ * repeatedly to transitively expand the Vars list. If at any point
+ * we find we can reach the right-side Var of the new qual, we are
+ * done. We give up when we can't expand the equalvars list any more.
*/
newleft = (Node *) get_leftop(restrictinfo->clause);
newright = (Node *) get_rightop(restrictinfo->clause);
equalvars = makeList1(newleft);
- do {
+ do
+ {
someadded = false;
foreach(olditem, oldquals)
{
RestrictInfo *oldrinfo = (RestrictInfo *) lfirst(olditem);
- Node *oldleft = (Node *) get_leftop(oldrinfo->clause);
- Node *oldright = (Node *) get_rightop(oldrinfo->clause);
- Node *newguy = NULL;
+ Node *oldleft = (Node *) get_leftop(oldrinfo->clause);
+ Node *oldright = (Node *) get_rightop(oldrinfo->clause);
+ Node *newguy = NULL;
if (member(oldleft, equalvars))
newguy = oldright;
return true; /* we proved new clause is redundant */
equalvars = lcons(newguy, equalvars);
someadded = true;
+
/*
* Remove this qual from list, since we don't need it anymore.
* Note this doesn't break the foreach() loop, since lremove
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.66 2001/06/05 05:26:04 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.67 2001/10/25 05:49:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
if (constant_quals || IsA(subplan, Append))
{
-
/*
* The result node will also be responsible for evaluating the
* originally requested tlist.
}
else
{
-
/*
* Replace the toplevel plan node's flattened target list with the
* targetlist given by my caller, so that expressions are
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.109 2001/10/18 16:11:41 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.110 2001/10/25 05:49:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* grouping_planner.
*/
if (parse->resultRelation &&
- (lst = expand_inherted_rtentry(parse, parse->resultRelation, false))
+ (lst = expand_inherted_rtentry(parse, parse->resultRelation, false))
!= NIL)
plan = inheritance_planner(parse, lst);
else
* Is this a subquery RTE, and if so, is the subquery simple
* enough to pull up? (If not, do nothing at this node.)
*
- * Note: even if the subquery itself is simple enough, we can't
- * pull it up if there is a reference to its whole tuple result.
+ * Note: even if the subquery itself is simple enough, we can't pull
+ * it up if there is a reference to its whole tuple result.
*/
if (subquery && is_simple_subquery(subquery) &&
!contain_whole_tuple_var((Node *) parse, varno, 0))
/*
* At the moment, we can't pull up subqueries that are inside the
- * nullable side of an outer join, because substituting their target
- * list entries for upper Var references wouldn't do the right thing
- * (the entries wouldn't go to NULL when they're supposed to).
- * Suppressing the pullup is an ugly, performance-losing hack, but
- * I see no alternative for now. Find a better way to handle this
- * when we redesign query trees --- tgl 4/30/01.
+ * nullable side of an outer join, because substituting their
+ * target list entries for upper Var references wouldn't do the
+ * right thing (the entries wouldn't go to NULL when they're
+ * supposed to). Suppressing the pullup is an ugly,
+ * performance-losing hack, but I see no alternative for now.
+ * Find a better way to handle this when we redesign query trees
+ * --- tgl 4/30/01.
*/
switch (j->jointype)
{
j->rarg = pull_up_subqueries(parse, j->rarg);
break;
case JOIN_UNION:
+
/*
* This is where we fail if upper levels of planner
* haven't rewritten UNION JOIN as an Append ...
static bool
is_simple_subquery(Query *subquery)
{
-
/*
* Let's just make sure it's a valid subselect ...
*/
/* Now, is it a FromExpr? */
if (child && IsA(child, FromExpr))
{
-
/*
* Yes, so do we want to merge it into parent? Always do
* so if child has just one element (since that doesn't
static Node *
preprocess_expression(Query *parse, Node *expr, int kind)
{
-
/*
* Simplify constant expressions.
*
if (kind != EXPRKIND_WHERE &&
(parse->groupClause != NIL || parse->hasAggs))
{
-
/*
* Check for ungrouped variables passed to subplans. Note we
* do NOT do this for subplans in WHERE (or JOIN/ON); it's
if (parse->setOperations)
{
-
/*
* Construct the plan for set operations. The result will not
* need any work except perhaps a top-level sort and/or LIMIT.
if (parse->limitCount != NULL)
{
/*
- * A LIMIT clause limits the absolute number of tuples returned.
- * However, if it's not a constant LIMIT then we have to punt;
- * for lack of a better idea, assume 10% of the plan's result
- * is wanted.
+ * A LIMIT clause limits the absolute number of tuples
+ * returned. However, if it's not a constant LIMIT then we
+ * have to punt; for lack of a better idea, assume 10% of the
+ * plan's result is wanted.
*/
- double limit_fraction = 0.0;
+ double limit_fraction = 0.0;
if (IsA(parse->limitCount, Const))
{
int32 count = DatumGetInt32(limitc->constvalue);
/*
- * A NULL-constant LIMIT represents "LIMIT ALL", which
- * we treat the same as no limit (ie, expect to
- * retrieve all the tuples).
+ * A NULL-constant LIMIT represents "LIMIT ALL", which we
+ * treat the same as no limit (ie, expect to retrieve all
+ * the tuples).
*/
if (!limitc->constisnull && count > 0)
{
{
/*
* If we have absolute limits from both caller and LIMIT,
- * use the smaller value; if one is fractional and the other
- * absolute, treat the fraction as a fraction of the absolute
- * value; else we can multiply the two fractions together.
+ * use the smaller value; if one is fractional and the
+ * other absolute, treat the fraction as a fraction of the
+ * absolute value; else we can multiply the two fractions
+ * together.
*/
if (tuple_fraction >= 1.0)
{
if (parse->groupClause)
{
-
/*
* In GROUP BY mode, we have the little problem that we don't
* really know how many input tuples will be needed to make a
}
else if (parse->hasAggs)
{
-
/*
* Ungrouped aggregate will certainly want all the input
* tuples.
}
else if (parse->distinctClause)
{
-
/*
* SELECT DISTINCT, like GROUP, will absorb an unpredictable
* number of input tuples per output tuple. Handle the same
}
else
{
-
/*
* We will need to do an explicit sort by the GROUP BY clause.
* make_groupplan will do the work, but set current_pathkeys
if (!is_presorted)
{
-
/*
* The Sort node always just takes a copy of the subplan's tlist
* plus ordering information. (This might seem inefficient if the
secondExpr = lsecond(expr->args);
return (firstExpr && secondExpr && nodeTag(firstExpr) == T_Var && nodeTag(secondExpr) == T_Const);
}
-
#endif /* ENABLE_KEY_SET_QUERY */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepqual.c,v 1.29 2001/03/22 03:59:38 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepqual.c,v 1.30 2001/10/25 05:49:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
if (cnfok)
{
-
/*
* Normalize into conjunctive normal form, and clean up the
* result.
}
else if (dnfok)
{
-
/*
* Normalize into disjunctive normal form, and clean up the
* result.
return newqual;
}
-
#endif
/*--------------------
}
else if (not_clause((Node *) qual))
{
-
/*
* Another 'not' cancels this 'not', so eliminate the 'not' and
* stop negating this branch. But search the subexpression for
}
else
{
-
/*
* We don't know how to negate anything else, place a 'not' at
* this level.
}
else if (contain_subplans((Node *) qual))
{
-
/*
* charge extra for subexpressions containing sub-SELECTs, to
* discourage us from rearranging them in a way that might
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.43 2001/09/06 02:07:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.44 2001/10/25 05:49:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Index result_relation,
List *range_table)
{
-
/*
* Sanity check: if there is a result relation, it'd better be a real
* relation not a subquery. Else parser or rewriter messed up.
if (new_tle == NULL)
{
-
/*
* Didn't find a matching tlist entry, so make one.
*
/*
* Set attributes are represented as OIDs no
* matter what the set element type is, and
- * the element type's default is irrelevant too.
+ * the element type's default is irrelevant
+ * too.
*/
hasdefault = false;
typedefault = (Datum) 0;
if (prior_tle == NULL)
{
-
/*
* Normal case where this is the first assignment to the
* attribute.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.66 2001/08/14 17:12:57 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.67 2001/10/25 05:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*
* The tlist for an Append plan isn't important as far as the Append is
* concerned, but we must make it look real anyway for the benefit of
- * the next plan level up. In fact, it has to be real enough that the
+ * the next plan level up. In fact, it has to be real enough that the
* flag column is shown as a variable not a constant, else setrefs.c
* will get confused.
*/
*
* colTypes: column datatypes for non-junk columns
* flag: -1 if no flag column needed, 0 or 1 to create a const flag column,
- * 2 to create a variable flag column
+ * 2 to create a variable flag column
* hack_constants: true to copy up constants (see comments in code)
* input_tlist: targetlist of this node's input node
* refnames_tlist: targetlist to take column names from
* If not, return NIL.
*
* When dup_parent is false, the initially given RT index is part of the
- * returned list (if any). When dup_parent is true, the given RT index
+ * returned list (if any). When dup_parent is true, the given RT index
* is *not* in the returned list; a duplicate RTE will be made for the
* parent table.
*
return NIL;
/* Scan for all members of inheritance set */
inhOIDs = find_all_inheritors(parentOID);
+
/*
* Check that there's at least one descendant, else treat as no-child
* case. This could happen despite above has_subclass() check, if
if (dup_parent)
inhRTIs = NIL;
else
- inhRTIs = makeListi1(rti); /* include original RTE in result */
+ inhRTIs = makeListi1(rti); /* include original RTE in result */
foreach(l, inhOIDs)
{
/*
* BUT: although we don't need to recurse into subplans, we do need to
* make sure that they are copied, not just referenced as
- * expression_tree_mutator will do by default. Otherwise we'll have the
- * same subplan node referenced from each arm of the inheritance APPEND
- * plan, which will cause trouble in the executor. This is a kluge
- * that should go away when we redesign querytrees.
+ * expression_tree_mutator will do by default. Otherwise we'll have
+ * the same subplan node referenced from each arm of the inheritance
+ * APPEND plan, which will cause trouble in the executor. This is a
+ * kluge that should go away when we redesign querytrees.
*/
if (is_subplan(node))
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.88 2001/07/31 20:16:33 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.89 2001/10/25 05:49:34 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
List *
make_ands_implicit(Expr *clause)
{
-
/*
* NB: because the parser sets the qual field to NULL in a query that
* has no WHERE clause, we must consider a NULL input clause as TRUE,
check_subplans_for_ungrouped_vars(Node *clause,
Query *query)
{
-
/*
* No special setup needed; context for walker is just the Query
* pointer
*/
if (is_subplan(node))
{
-
/*
* The args list of the subplan node represents attributes from
* outside passed into the sublink.
bool
is_pseudo_constant_clause(Node *clause)
{
-
/*
* We could implement this check in one recursive scan. But since the
* check for noncachable functions is both moderately expensive and
static bool
sortgroupref_is_present(Index sortgroupref, List *clauselist)
{
- List *clause;
+ List *clause;
foreach(clause, clauselist)
{
bool
has_distinct_on_clause(Query *query)
{
- List *targetList;
+ List *targetList;
/* Is there a DISTINCT clause at all? */
if (query->distinctClause == NIL)
return false;
+
/*
- * If the DISTINCT list contains all the nonjunk targetlist items,
- * and nothing else (ie, no junk tlist items), then it's a simple
+ * If the DISTINCT list contains all the nonjunk targetlist items, and
+ * nothing else (ie, no junk tlist items), then it's a simple
* DISTINCT, else it's DISTINCT ON. We do not require the lists to be
* in the same order (since the parser may have adjusted the DISTINCT
- * clause ordering to agree with ORDER BY). Furthermore, a non-DISTINCT
- * junk tlist item that is in the sortClause is also evidence of
- * DISTINCT ON, since we don't allow ORDER BY on junk tlist items when
- * plain DISTINCT is used.
+ * clause ordering to agree with ORDER BY). Furthermore, a
+ * non-DISTINCT junk tlist item that is in the sortClause is also
+ * evidence of DISTINCT ON, since we don't allow ORDER BY on junk
+ * tlist items when plain DISTINCT is used.
*
* This code assumes that the DISTINCT list is valid, ie, all its entries
* match some entry of the tlist.
}
if (IsA(node, RelabelType))
{
-
/*
* If we can simplify the input to a constant, then we don't need
* the RelabelType node anymore: just change the type field of the
}
if (IsA(node, Iter))
{
-
/*
* The argument of an Iter is normally a function call. We must
* not try to eliminate the function, but we can try to simplify
*/
if (proisstrict && has_null_input)
{
-
/*
* It's strict and has NULL input, so must produce NULL output.
* Return a NULL constant of the right type.
Node *(*mutator) (),
void *context)
{
-
/*
* The mutator has already decided not to modify the current node, but
* we must call the mutator for any sub-nodes.
}
else
{
-
/*
* for other Expr node types, just transform args
* list, linking to original oper node (OK?)
break;
case T_NullTest:
{
- NullTest *ntest = (NullTest *) node;
- NullTest *newnode;
+ NullTest *ntest = (NullTest *) node;
+ NullTest *newnode;
FLATCOPY(newnode, ntest, NullTest);
MUTATE(newnode->arg, ntest->arg, Node *);
break;
case T_SubLink:
{
-
/*
* A "bare" SubLink (note we will not come here if we
* found a SUBPLAN_EXPR node above it). Transform the
break;
case T_List:
{
-
/*
* We assume the mutator isn't interested in the list
* nodes per se, so just invoke it on each list element.
break;
case T_TargetEntry:
{
-
/*
* We mutate the expression, but not the resdom, by
* default.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.29 2001/03/22 03:59:39 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.30 2001/10/25 05:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* Returns a joininfo node.
*
*/
-JoinInfo *
+JoinInfo *
find_joininfo_node(RelOptInfo *this_rel, Relids join_relids)
{
JoinInfo *joininfo = joininfo_member(join_relids,
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.75 2001/07/16 05:06:58 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.76 2001/10/25 05:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*
* Returns the new path node.
*/
-IndexPath *
+IndexPath *
create_index_path(Query *root,
RelOptInfo *rel,
IndexOptInfo *index,
pathnode->rows = rel->rows;
/*
- * Not sure if this is necessary, but it should help if the
- * statistics are too far off
+ * Not sure if this is necessary, but it should help if the statistics
+ * are too far off
*/
if (index->indpred && index->tuples < pathnode->rows)
pathnode->rows = index->tuples;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.68 2001/08/21 16:36:03 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.69 2001/10/25 05:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
info = makeNode(IndexOptInfo);
/*
- * Need to make these arrays large enough to be sure there is
- * room for a terminating 0 at the end of each one.
+ * Need to make these arrays large enough to be sure there is room
+ * for a terminating 0 at the end of each one.
*/
info->classlist = (Oid *) palloc(sizeof(Oid) * (INDEX_MAX_KEYS + 1));
info->indexkeys = (int *) palloc(sizeof(int) * (INDEX_MAX_KEYS + 1));
/* Extract info from the pg_index tuple */
info->indexoid = index->indexrelid;
info->indproc = index->indproc; /* functional index ?? */
- if (VARSIZE(&index->indpred) > VARHDRSZ) /* partial index ?? */
+ if (VARSIZE(&index->indpred) > VARHDRSZ) /* partial index ?? */
{
char *predString;
* This code executes registered procedures stored in the
* operator relation, by calling the function manager.
*
- * varRelid is either 0 or a rangetable index. See clause_selectivity()
+ * varRelid is either 0 or a rangetable index. See clause_selectivity()
* for details about its meaning.
*/
Selectivity
float8 result;
/*
- * if the oprrest procedure is missing for whatever reason,
- * use a selectivity of 0.5
+ * if the oprrest procedure is missing for whatever reason, use a
+ * selectivity of 0.5
*/
if (!oprrest)
return (Selectivity) 0.5;
float8 result;
/*
- * if the oprjoin procedure is missing for whatever reason,
- * use a selectivity of 0.5
+ * if the oprjoin procedure is missing for whatever reason, use a
+ * selectivity of 0.5
*/
if (!oprjoin)
return (Selectivity) 0.5;
IndexOptInfo *index = (IndexOptInfo *) lfirst(ilist);
/*
- * Note: ignore functional and partial indexes, since they
- * don't allow us to conclude that all attr values are distinct.
- * Also, a multicolumn unique index doesn't allow us to conclude
- * that just the specified attr is unique.
+ * Note: ignore functional and partial indexes, since they don't
+ * allow us to conclude that all attr values are distinct. Also, a
+ * multicolumn unique index doesn't allow us to conclude that just
+ * the specified attr is unique.
*/
if (index->unique &&
index->nkeys == 1 &&
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.34 2001/10/18 16:11:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.35 2001/10/25 05:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static RelOptInfo *make_base_rel(Query *root, int relid);
static List *new_join_tlist(List *tlist, int first_resdomno);
static List *build_joinrel_restrictlist(Query *root,
- RelOptInfo *joinrel,
- RelOptInfo *outer_rel,
- RelOptInfo *inner_rel);
+ RelOptInfo *joinrel,
+ RelOptInfo *outer_rel,
+ RelOptInfo *inner_rel);
static void build_joinrel_joinlist(RelOptInfo *joinrel,
RelOptInfo *outer_rel,
RelOptInfo *inner_rel);
if (relationObjectId != InvalidOid)
{
/* Plain relation --- retrieve statistics from the system catalogs */
- bool indexed;
+ bool indexed;
get_relation_info(relationObjectId,
&indexed, &rel->pages, &rel->tuples);
if (joinrel)
{
-
/*
* Yes, so we only need to figure the restrictlist for this
* particular pair of component relations.
RelOptInfo *outer_rel,
RelOptInfo *inner_rel)
{
- List *result = NIL;
- List *rlist;
- List *item;
+ List *result = NIL;
+ List *rlist;
+ List *item;
/*
* Collect all the clauses that syntactically belong at this level.
* Eliminate duplicate and redundant clauses.
*
* We must eliminate duplicates, since we will see many of the same
- * clauses arriving from both input relations. Also, if a clause is
- * a mergejoinable clause, it's possible that it is redundant with
- * previous clauses (see optimizer/README for discussion). We detect
+ * clauses arriving from both input relations. Also, if a clause is a
+ * mergejoinable clause, it's possible that it is redundant with
+ * previous clauses (see optimizer/README for discussion). We detect
* that case and omit the redundant clause from the result list.
*
* We can detect redundant mergejoinable clauses very cheaply by using
* equijoined variables in question. All the members of a pathkey set
* that are in the left relation have already been forced to be equal;
* likewise for those in the right relation. So, we need to have only
- * one clause that checks equality between any set member on the left and
- * any member on the right; by transitivity, all the rest are then equal.
+ * one clause that checks equality between any set member on the left
+ * and any member on the right; by transitivity, all the rest are then
+ * equal.
*/
foreach(item, rlist)
{
/* check for redundant merge clauses */
if (rinfo->mergejoinoperator != InvalidOid)
{
- bool redundant = false;
- List *olditem;
+ bool redundant = false;
+ List *olditem;
cache_mergeclause_pathkeys(root, rinfo);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.50 2001/03/22 03:59:40 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.51 2001/10/25 05:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
return (Node *) NULL;
}
-
#endif
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.32 2001/05/09 23:13:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.33 2001/10/25 05:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static bool pull_varnos_walker(Node *node,
pull_varnos_context *context);
static bool contain_var_reference_walker(Node *node,
- contain_var_reference_context *context);
+ contain_var_reference_context *context);
static bool contain_var_clause_walker(Node *node, void *context);
static bool pull_var_clause_walker(Node *node,
pull_var_clause_context *context);
*
* NOTE: this is used on not-yet-planned expressions. It may therefore find
* bare SubLinks, and if so it needs to recurse into them to look for uplevel
- * references to the desired rtable level! But when we find a completed
+ * references to the desired rtable level! But when we find a completed
* SubPlan, we only need to look at the parameters passed to the subplan.
*/
List *
}
if (is_subplan(node))
{
-
/*
* Already-planned subquery. Examine the args list (parameters to
* be passed to subquery), as well as the "oper" list which is
*
* NOTE: this is used on not-yet-planned expressions. It may therefore find
* bare SubLinks, and if so it needs to recurse into them to look for uplevel
- * references to the desired rtable entry! But when we find a completed
+ * references to the desired rtable entry! But when we find a completed
* SubPlan, we only need to look at the parameters passed to the subplan.
*/
bool
}
if (is_subplan(node))
{
-
/*
* Already-planned subquery. Examine the args list (parameters to
* be passed to subquery), as well as the "oper" list which is
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.203 2001/10/23 17:39:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.204 2001/10/25 05:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static Query *transformCreateStmt(ParseState *pstate, CreateStmt *stmt);
static Query *transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt);
static void transformColumnDefinition(ParseState *pstate,
- CreateStmtContext *cxt,
- ColumnDef *column);
+ CreateStmtContext *cxt,
+ ColumnDef *column);
static void transformTableConstraint(ParseState *pstate,
- CreateStmtContext *cxt,
- Constraint *constraint);
+ CreateStmtContext *cxt,
+ Constraint *constraint);
static void transformIndexConstraints(ParseState *pstate,
- CreateStmtContext *cxt);
+ CreateStmtContext *cxt);
static void transformFKConstraints(ParseState *pstate,
- CreateStmtContext *cxt);
+ CreateStmtContext *cxt);
static Node *transformTypeRefs(ParseState *pstate, Node *stmt);
static void transformTypeRefsList(ParseState *pstate, List *l);
static void transformFkeyCheckAttrs(FkConstraint *fkconstraint, Oid *pktypoid);
static void transformFkeyGetPrimaryKey(FkConstraint *fkconstraint, Oid *pktypoid);
static bool relationHasPrimaryKey(char *relname);
-static Oid transformFkeyGetColType(CreateStmtContext *cxt, char *colname);
+static Oid transformFkeyGetColType(CreateStmtContext *cxt, char *colname);
static void release_pstate_resources(ParseState *pstate);
static FromExpr *makeFromExpr(List *fromlist, Node *quals);
switch (nodeTag(parseTree))
{
-
/*
* Non-optimizable statements
*/
* insert these into the actual query tree. - thomas
* 2000-03-08
*
- * Outer loop is over targetlist to make it easier to
- * skip junk targetlist entries.
+ * Outer loop is over targetlist to make it easier to skip
+ * junk targetlist entries.
*/
if (n->aliases != NIL)
{
Assert(IsA(te, TargetEntry));
rd = te->resdom;
Assert(IsA(rd, Resdom));
- if (rd->resjunk) /* junk columns don't get aliases */
+ if (rd->resjunk) /* junk columns don't get
+ * aliases */
continue;
id = (Ident *) lfirst(aliaslist);
Assert(IsA(id, Ident));
rd->resname = pstrdup(id->name);
aliaslist = lnext(aliaslist);
if (aliaslist == NIL)
- break; /* done assigning aliases */
+ break; /* done assigning aliases */
}
if (aliaslist != NIL)
}
else
{
-
/*
* For INSERT ... VALUES, transform the given list of values to
* form a targetlist for the INSERT.
te = makeTargetEntry(makeResdom(attrno,
thisatt->atttypid,
thisatt->atttypmod,
- pstrdup(NameStr(thisatt->attname)),
+ pstrdup(NameStr(thisatt->attname)),
false),
stringToNode(defval[ndef].adbin));
qry->targetList = lappend(qry->targetList, te);
CreateSeqStmt *sequence;
/*
- * Create appropriate constraints for SERIAL. We do
- * this in full, rather than shortcutting, so that we
- * will detect any conflicting constraints the user
- * wrote (like a different DEFAULT).
+ * Create appropriate constraints for SERIAL. We do this in full,
+ * rather than shortcutting, so that we will detect any
+ * conflicting constraints the user wrote (like a different
+ * DEFAULT).
*/
sname = makeObjectName(cxt->relname, column->colname, "seq");
/*
- * Create an expression tree representing the function
- * call nextval('"sequencename"')
+ * Create an expression tree representing the function call
+ * nextval('"sequencename"')
*/
qstring = palloc(strlen(sname) + 2 + 1);
sprintf(qstring, "\"%s\"", sname);
constraint = makeNode(Constraint);
constraint->contype = CONSTR_UNIQUE;
- constraint->name = NULL; /* assign later */
+ constraint->name = NULL; /* assign later */
column->constraints = lappend(column->constraints, constraint);
constraint = makeNode(Constraint);
column->constraints = lappend(column->constraints, constraint);
/*
- * Build a CREATE SEQUENCE command to create the
- * sequence object, and add it to the list of things
- * to be done before this CREATE/ALTER TABLE.
+ * Build a CREATE SEQUENCE command to create the sequence object,
+ * and add it to the list of things to be done before this
+ * CREATE/ALTER TABLE.
*/
sequence = makeNode(CreateSeqStmt);
sequence->seqname = pstrdup(sname);
sequence->options = NIL;
elog(NOTICE, "%s will create implicit sequence '%s' for SERIAL column '%s.%s'",
- cxt->stmtType, sequence->seqname, cxt->relname, column->colname);
+ cxt->stmtType, sequence->seqname, cxt->relname, column->colname);
cxt->blist = lappend(cxt->blist, sequence);
}
constraint = lfirst(clist);
/*
- * If this column constraint is a FOREIGN KEY
- * constraint, then we fill in the current attributes
- * name and throw it into the list of FK constraints
- * to be processed later.
+ * If this column constraint is a FOREIGN KEY constraint, then we
+ * fill in the current attributes name and throw it into the list
+ * of FK constraints to be processed later.
*/
if (IsA(constraint, FkConstraint))
{
List *indexlist = NIL;
/*
- * Run through the constraints that need to generate an index.
- * For PRIMARY KEY, mark each column as NOT NULL and create an index.
- * For UNIQUE, create an index as for PRIMARY KEY, but do not insist on
+ * Run through the constraints that need to generate an index. For
+ * PRIMARY KEY, mark each column as NOT NULL and create an index. For
+ * UNIQUE, create an index as for PRIMARY KEY, but do not insist on
* NOT NULL.
*/
foreach(listptr, cxt->ixconstraints)
index->whereClause = NULL;
/*
- * Make sure referenced keys exist. If we are making a
- * PRIMARY KEY index, also make sure they are NOT NULL.
+ * Make sure referenced keys exist. If we are making a PRIMARY
+ * KEY index, also make sure they are NOT NULL.
*/
foreach(keys, constraint->keys)
{
else if (SystemAttributeByName(key->name, cxt->hasoids) != NULL)
{
/*
- * column will be a system column in the new table,
- * so accept it. System columns can't ever be null,
- * so no need to worry about PRIMARY/NOT NULL constraint.
+ * column will be a system column in the new table, so
+ * accept it. System columns can't ever be null, so no
+ * need to worry about PRIMARY/NOT NULL constraint.
*/
found = true;
}
if (HeapTupleIsValid(atttuple))
{
found = true;
+
/*
* We require pre-existing column to be already marked
* NOT NULL.
* Finally, select unique names for all not-previously-named indices,
* and display notice messages.
*
- * XXX in ALTER TABLE case, we fail to consider name collisions
- * against pre-existing indexes.
+ * XXX in ALTER TABLE case, we fail to consider name collisions against
+ * pre-existing indexes.
*/
foreach(indexlist, cxt->alist)
{
List *fk_attr;
List *pk_attr;
Ident *id;
- Oid pktypoid[INDEX_MAX_KEYS];
- Oid fktypoid[INDEX_MAX_KEYS];
- int i;
+ Oid pktypoid[INDEX_MAX_KEYS];
+ Oid fktypoid[INDEX_MAX_KEYS];
+ int i;
if (cxt->fkconstraints == NIL)
return;
foreach(fkclist, cxt->fkconstraints)
{
FkConstraint *fkconstraint = (FkConstraint *) lfirst(fkclist);
- int attnum;
+ int attnum;
List *fkattrs;
/*
if (fkconstraint->constr_name == NULL)
fkconstraint->constr_name = "";
- for (attnum=0; attnum<INDEX_MAX_KEYS; attnum++)
+ for (attnum = 0; attnum < INDEX_MAX_KEYS; attnum++)
pktypoid[attnum] = fktypoid[attnum] = InvalidOid;
/*
- * Look up the referencing attributes to make sure they exist
- * (or will exist) in this table, and remember their type OIDs.
+ * Look up the referencing attributes to make sure they exist (or
+ * will exist) in this table, and remember their type OIDs.
*/
attnum = 0;
foreach(fkattrs, fkconstraint->fk_attrs)
/* Use the to-be-created primary key */
List *attr;
- attnum=0;
+ attnum = 0;
foreach(attr, cxt->pkey->indexParams)
{
IndexElem *ielem = lfirst(attr);
elog(ERROR, "Can only have %d keys in a foreign key",
INDEX_MAX_KEYS);
pktypoid[attnum++] = transformFkeyGetColType(cxt,
- ielem->name);
+ ielem->name);
}
}
else
if (length(ind->indexParams) !=
length(fkconstraint->pk_attrs))
continue;
- attnum=0;
+ attnum = 0;
foreach(pkattrs, fkconstraint->pk_attrs)
{
Ident *pkattr = lfirst(pkattrs);
elog(ERROR, "Can only have %d keys in a foreign key",
INDEX_MAX_KEYS);
pktypoid[attnum++] = transformFkeyGetColType(cxt,
- pkattr->name);
+ pkattr->name);
}
if (found)
break;
}
if (!found)
{
- /* In ALTER TABLE case, such an index may already exist */
+ /*
+ * In ALTER TABLE case, such an index may already
+ * exist
+ */
if (OidIsValid(cxt->relOid))
transformFkeyCheckAttrs(fkconstraint, pktypoid);
else
for (i = 0; i < INDEX_MAX_KEYS && fktypoid[i] != 0; i++)
{
/*
- * fktypoid[i] is the foreign key table's i'th element's type oid
- * pktypoid[i] is the primary key table's i'th element's type oid
- * We let oper() do our work for us, including elog(ERROR) if the
- * types don't compare with =
+ * fktypoid[i] is the foreign key table's i'th element's type
+ * oid pktypoid[i] is the primary key table's i'th element's
+ * type oid We let oper() do our work for us, including
+ * elog(ERROR) if the types don't compare with =
*/
- Operator o=oper("=", fktypoid[i], pktypoid[i], false);
+ Operator o = oper("=", fktypoid[i], pktypoid[i], false);
+
ReleaseSysCache(o);
}
fk_trigger->args = lappend(fk_trigger->args,
makeString(cxt->relname));
fk_trigger->args = lappend(fk_trigger->args,
- makeString(fkconstraint->pktable_name));
+ makeString(fkconstraint->pktable_name));
fk_trigger->args = lappend(fk_trigger->args,
makeString(fkconstraint->match_type));
fk_attr = fkconstraint->fk_attrs;
fkactions = lappend(fkactions, (Node *) fk_trigger);
/*
- * Build a CREATE CONSTRAINT TRIGGER statement for the ON
- * DELETE action fired on the PK table !!!
+ * Build a CREATE CONSTRAINT TRIGGER statement for the ON DELETE
+ * action fired on the PK table !!!
*/
fk_trigger = (CreateTrigStmt *) makeNode(CreateTrigStmt);
fk_trigger->trigname = fkconstraint->constr_name;
fk_trigger->args = lappend(fk_trigger->args,
makeString(cxt->relname));
fk_trigger->args = lappend(fk_trigger->args,
- makeString(fkconstraint->pktable_name));
+ makeString(fkconstraint->pktable_name));
fk_trigger->args = lappend(fk_trigger->args,
makeString(fkconstraint->match_type));
fk_attr = fkconstraint->fk_attrs;
fkactions = lappend(fkactions, (Node *) fk_trigger);
/*
- * Build a CREATE CONSTRAINT TRIGGER statement for the ON
- * UPDATE action fired on the PK table !!!
+ * Build a CREATE CONSTRAINT TRIGGER statement for the ON UPDATE
+ * action fired on the PK table !!!
*/
fk_trigger = (CreateTrigStmt *) makeNode(CreateTrigStmt);
fk_trigger->trigname = fkconstraint->constr_name;
fk_trigger->args = lappend(fk_trigger->args,
makeString(cxt->relname));
fk_trigger->args = lappend(fk_trigger->args,
- makeString(fkconstraint->pktable_name));
+ makeString(fkconstraint->pktable_name));
fk_trigger->args = lappend(fk_trigger->args,
makeString(fkconstraint->match_type));
fk_attr = fkconstraint->fk_attrs;
}
/*
- * Attach completed list of extra actions to cxt->alist. We cannot
- * do this earlier, because we assume above that cxt->alist still
- * holds only IndexStmts.
+ * Attach completed list of extra actions to cxt->alist. We cannot do
+ * this earlier, because we assume above that cxt->alist still holds
+ * only IndexStmts.
*/
cxt->alist = nconc(cxt->alist, fkactions);
}
if (stmt->whereClause)
{
/*
- * Put the parent table into the rtable so that the WHERE clause can
- * refer to its fields without qualification. Note that this only
- * works if the parent table already exists --- so we can't easily
- * support predicates on indexes created implicitly by CREATE TABLE.
- * Fortunately, that's not necessary.
+ * Put the parent table into the rtable so that the WHERE clause
+ * can refer to its fields without qualification. Note that this
+ * only works if the parent table already exists --- so we can't
+ * easily support predicates on indexes created implicitly by
+ * CREATE TABLE. Fortunately, that's not necessary.
*/
rte = addRangeTableEntry(pstate, stmt->relname, NULL, false, true);
/*
* We cannot support utility-statement actions (eg NOTIFY)
- * with nonempty rule WHERE conditions, because there's no
- * way to make the utility action execute conditionally.
+ * with nonempty rule WHERE conditions, because there's no way
+ * to make the utility action execute conditionally.
*/
if (top_subqry->commandType == CMD_UTILITY &&
stmt->whereClause != NULL)
* The tree of set operations is converted into the setOperations field of
* the top-level Query.
*/
-static Query *transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
+static Query *
+transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
{
Query *qry = makeNode(Query);
SelectStmt *leftmostSelect;
if (resnode->resjunk)
{
-
/*
* Resjunk nodes need no additional processing, but be sure
* they have names and resnos that do not match any target
/*
* The only subtypes that currently require parse transformation
- * handling are 'A'dd column and Add 'C'onstraint. These largely
+ * handling are 'A'dd column and Add 'C'onstraint. These largely
* re-use code from CREATE TABLE.
*/
switch (stmt->subtype)
PointerGetDatum(stmt->relname),
0, 0, 0);
cxt.hasoids = SearchSysCacheExists(ATTNUM,
- ObjectIdGetDatum(cxt.relOid),
- Int16GetDatum(ObjectIdAttributeNumber),
+ ObjectIdGetDatum(cxt.relOid),
+ Int16GetDatum(ObjectIdAttributeNumber),
0, 0);
cxt.columns = NIL;
cxt.ckconstraints = NIL;
PointerGetDatum(stmt->relname),
0, 0, 0);
cxt.hasoids = SearchSysCacheExists(ATTNUM,
- ObjectIdGetDatum(cxt.relOid),
- Int16GetDatum(ObjectIdAttributeNumber),
+ ObjectIdGetDatum(cxt.relOid),
+ Int16GetDatum(ObjectIdAttributeNumber),
0, 0);
cxt.columns = NIL;
cxt.ckconstraints = NIL;
switch (nodeTag(stmt))
{
case T_ProcedureStmt:
- {
- ProcedureStmt *ps = (ProcedureStmt *) stmt;
+ {
+ ProcedureStmt *ps = (ProcedureStmt *) stmt;
- transformTypeRefsList(pstate, ps->argTypes);
- transformTypeRef(pstate, (TypeName *) ps->returnType);
- transformTypeRefsList(pstate, ps->withClause);
- }
- break;
+ transformTypeRefsList(pstate, ps->argTypes);
+ transformTypeRef(pstate, (TypeName *) ps->returnType);
+ transformTypeRefsList(pstate, ps->withClause);
+ }
+ break;
case T_CommentStmt:
- {
- CommentStmt *cs = (CommentStmt *) stmt;
+ {
+ CommentStmt *cs = (CommentStmt *) stmt;
- transformTypeRefsList(pstate, cs->objlist);
- }
- break;
+ transformTypeRefsList(pstate, cs->objlist);
+ }
+ break;
case T_RemoveFuncStmt:
- {
- RemoveFuncStmt *rs = (RemoveFuncStmt *) stmt;
+ {
+ RemoveFuncStmt *rs = (RemoveFuncStmt *) stmt;
- transformTypeRefsList(pstate, rs->args);
- }
- break;
+ transformTypeRefsList(pstate, rs->args);
+ }
+ break;
case T_DefineStmt:
- {
- DefineStmt *ds = (DefineStmt *) stmt;
- List *ele;
-
- foreach(ele, ds->definition)
{
- DefElem *de = (DefElem *) lfirst(ele);
+ DefineStmt *ds = (DefineStmt *) stmt;
+ List *ele;
- if (de->arg != NULL
- && IsA(de->arg, TypeName))
+ foreach(ele, ds->definition)
{
- transformTypeRef(pstate, (TypeName *) de->arg);
+ DefElem *de = (DefElem *) lfirst(ele);
+
+ if (de->arg != NULL
+ && IsA(de->arg, TypeName))
+ transformTypeRef(pstate, (TypeName *) de->arg);
}
}
- }
- break;
+ break;
default:
elog(ERROR, "Unsupported type %d in transformTypeRefs",
foreach(ele, l)
{
- Node *elem = lfirst(ele);
+ Node *elem = lfirst(ele);
if (elem && IsA(elem, TypeName))
transformTypeRef(pstate, (TypeName *) elem);
static void
transformTypeRef(ParseState *pstate, TypeName *tn)
{
- Attr *att;
- Node *n;
- Var *v;
- char *tyn;
+ Attr *att;
+ Node *n;
+ Var *v;
+ char *tyn;
if (tn->attrname == NULL)
return;
att = makeAttr(tn->name, tn->attrname);
n = transformExpr(pstate, (Node *) att, EXPR_COLUMN_FIRST);
- if (! IsA(n, Var))
+ if (!IsA(n, Var))
elog(ERROR, "unsupported expression in %%TYPE");
v = (Var *) n;
tyn = typeidTypeName(v->vartype);
{
/* go through the fkconstraint->pk_attrs list */
List *attrl;
- int attnum = 0;
+ int attnum = 0;
foreach(attrl, fkconstraint->pk_attrs)
{
HeapTuple indexTuple = NULL;
Form_pg_index indexStruct = NULL;
int i;
- int attnum=0;
+ int attnum = 0;
/*
* Open the referenced table
if (strcmp(col->colname, colname) == 0)
{
- char *buff = TypeNameToInternalName(col->typename);
+ char *buff = TypeNameToInternalName(col->typename);
result = typenameTypeId(buff);
if (!OidIsValid(result))
*/
if (typeTypeRelid(ctype) != InvalidOid)
{
-
/*
* (Eventually add in here that the set can only contain one
* element.)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.45 2001/08/09 18:28:17 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.46 2001/10/25 05:49:36 momjian Exp $
*
*-------------------------------------------------------------------------
*/
void
agg_error(char *caller, char *aggname, Oid basetypeID)
{
-
/*
* basetypeID that is Invalid (zero) means aggregate over all types.
* (count)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.82 2001/08/09 18:28:17 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.83 2001/10/25 05:49:37 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
switch (inhOpt)
{
- case INH_NO:
+ case INH_NO:
return false;
case INH_YES:
return true;
result = transformExpr(pstate, result, EXPR_COLUMN_FIRST);
/*
- * We expect the result to yield bool directly, otherwise complain.
- * We could try coerce_to_boolean() here, but it seems likely that an
- * "=" operator that doesn't return bool is wrong anyway.
+ * We expect the result to yield bool directly, otherwise complain. We
+ * could try coerce_to_boolean() here, but it seems likely that an "="
+ * operator that doesn't return bool is wrong anyway.
*/
if (exprType(result) != BOOLOID)
elog(ERROR, "JOIN/USING clause must return type boolean, not type %s",
/* This part is just like transformWhereClause() */
result = transformExpr(pstate, j->quals, EXPR_COLUMN_FIRST);
- if (! coerce_to_boolean(pstate, &result))
+ if (!coerce_to_boolean(pstate, &result))
elog(ERROR, "JOIN/ON clause must return type boolean, not type %s",
format_type_be(exprType(result)));
if (j->using)
{
-
/*
* JOIN/USING (or NATURAL JOIN, as transformed above).
* Transform the list into an explicit ON-condition, and
*/
if (j->alias)
{
-
/*
* If a column alias list is specified, substitute the alias
* names into my output-column list
qual = transformExpr(pstate, clause, EXPR_COLUMN_FIRST);
- if (! coerce_to_boolean(pstate, &qual))
+ if (!coerce_to_boolean(pstate, &qual))
elog(ERROR, "WHERE clause must return type boolean, not type %s",
format_type_be(exprType(qual)));
* an expression.
*----------
*/
- if (IsA(node, Ident) && ((Ident *) node)->indirection == NIL)
+ if (IsA(node, Ident) &&((Ident *) node)->indirection == NIL)
{
char *name = ((Ident *) node)->name;
if (clause == GROUP_CLAUSE)
{
-
/*
* In GROUP BY, we must prefer a match against a FROM-clause
* column to one against the targetlist. Look to see if there
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.63 2001/10/04 17:52:24 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.64 2001/10/25 05:49:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
else if (inputTypeId == UNKNOWNOID && IsA(node, Const))
{
-
/*
* Input is a string constant with previously undetermined type.
* Apply the target type's typinput function to it to produce a
}
else if (IS_BINARY_COMPATIBLE(inputTypeId, targetTypeId))
{
-
/*
* We don't really need to do a conversion, but we do need to
* attach a RelabelType node so that the expression will be seen
}
else
{
-
/*
* Otherwise, find the appropriate type conversion function
* (caller should have determined that there is one), and generate
oid_array[0] = inputTypeId;
ftup = SearchSysCache(PROCNAME,
- PointerGetDatum(typeidTypeName(targetTypeId)),
+ PointerGetDatum(typeidTypeName(targetTypeId)),
Int32GetDatum(1),
PointerGetDatum(oid_array),
0);
* (AND, OR, NOT, etc).
*
* If successful, update *pnode to be the transformed argument (if any
- * transformation is needed), and return TRUE. If fail, return FALSE.
+ * transformation is needed), and return TRUE. If fail, return FALSE.
* (The caller must check for FALSE and emit a suitable error message.)
*/
bool
if (inputTypeId == BOOLOID)
return true; /* no work */
targetTypeId = BOOLOID;
- if (! can_coerce_type(1, &inputTypeId, &targetTypeId))
+ if (!can_coerce_type(1, &inputTypeId, &targetTypeId))
return false; /* fail, but let caller choose error msg */
*pnode = coerce_type(pstate, *pnode, inputTypeId, targetTypeId, -1);
return true;
}
else if (TypeCategory(ntype) != pcategory)
{
-
/*
* both types in different categories? then not much
* hope...
&& !IsPreferredType(pcategory, ptype)
&& can_coerce_type(1, &ptype, &ntype))
{
-
/*
* new one is preferred and can convert? then take it...
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.103 2001/10/08 21:46:59 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.104 2001/10/25 05:49:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static Node *parser_typecast_constant(Value *expr, TypeName *typename);
static Node *parser_typecast_expression(ParseState *pstate,
- Node *expr, TypeName *typename);
+ Node *expr, TypeName *typename);
static Node *transformAttr(ParseState *pstate, Attr *att, int precedence);
static Node *transformIdent(ParseState *pstate, Ident *ident, int precedence);
static Node *transformIndirection(ParseState *pstate, Node *basenode,
- List *indirection);
+ List *indirection);
/*
case OP:
{
/*
- * Special-case "foo = NULL" and "NULL = foo" for
- * compatibility with standards-broken products
- * (like Microsoft's). Turn these into IS NULL exprs.
+ * Special-case "foo = NULL" and "NULL = foo"
+ * for compatibility with standards-broken
+ * products (like Microsoft's). Turn these
+ * into IS NULL exprs.
*/
if (Transform_null_equals &&
strcmp(a->opname, "=") == 0 &&
(exprIsNullConstant(a->lexpr) ||
exprIsNullConstant(a->rexpr)))
{
- NullTest *n = makeNode(NullTest);
+ NullTest *n = makeNode(NullTest);
+
n->nulltesttype = IS_NULL;
if (exprIsNullConstant(a->lexpr))
else
{
Node *lexpr = transformExpr(pstate,
- a->lexpr,
- precedence);
+ a->lexpr,
+ precedence);
Node *rexpr = transformExpr(pstate,
- a->rexpr,
- precedence);
+ a->rexpr,
+ precedence);
result = (Node *) make_op(a->opname,
lexpr,
precedence);
Expr *expr = makeNode(Expr);
- if (! coerce_to_boolean(pstate, &lexpr))
+ if (!coerce_to_boolean(pstate, &lexpr))
elog(ERROR, "left-hand side of AND is type '%s', not '%s'",
format_type_be(exprType(lexpr)),
format_type_be(BOOLOID));
- if (! coerce_to_boolean(pstate, &rexpr))
+ if (!coerce_to_boolean(pstate, &rexpr))
elog(ERROR, "right-hand side of AND is type '%s', not '%s'",
format_type_be(exprType(rexpr)),
format_type_be(BOOLOID));
precedence);
Expr *expr = makeNode(Expr);
- if (! coerce_to_boolean(pstate, &lexpr))
+ if (!coerce_to_boolean(pstate, &lexpr))
elog(ERROR, "left-hand side of OR is type '%s', not '%s'",
format_type_be(exprType(lexpr)),
format_type_be(BOOLOID));
- if (! coerce_to_boolean(pstate, &rexpr))
+ if (!coerce_to_boolean(pstate, &rexpr))
elog(ERROR, "right-hand side of OR is type '%s', not '%s'",
format_type_be(exprType(rexpr)),
format_type_be(BOOLOID));
precedence);
Expr *expr = makeNode(Expr);
- if (! coerce_to_boolean(pstate, &rexpr))
+ if (!coerce_to_boolean(pstate, &rexpr))
elog(ERROR, "argument to NOT is type '%s', not '%s'",
format_type_be(exprType(rexpr)),
format_type_be(BOOLOID));
if (sublink->subLinkType == EXISTS_SUBLINK)
{
-
/*
* EXISTS needs no lefthand or combining operator.
* These fields should be NIL already, but make sure.
}
neww->expr = transformExpr(pstate, warg, precedence);
- if (! coerce_to_boolean(pstate, &neww->expr))
+ if (!coerce_to_boolean(pstate, &neww->expr))
elog(ERROR, "WHEN clause must have a boolean result");
/*
case T_BooleanTest:
{
- BooleanTest *b = (BooleanTest *) expr;
+ BooleanTest *b = (BooleanTest *) expr;
b->arg = transformExpr(pstate, b->arg, precedence);
- if (! coerce_to_boolean(pstate, &b->arg))
+ if (!coerce_to_boolean(pstate, &b->arg))
{
const char *clausename;
default:
elog(ERROR, "transformExpr: unexpected booltesttype %d",
(int) b->booltesttype);
- clausename = NULL; /* keep compiler quiet */
+ clausename = NULL; /* keep compiler quiet */
}
elog(ERROR, "Argument of %s must be boolean",
* appear
*/
if (ident->indirection == NIL &&
- refnameRangeOrJoinEntry(pstate, ident->name, &sublevels_up) != NULL)
+ refnameRangeOrJoinEntry(pstate, ident->name, &sublevels_up) != NULL)
{
ident->isRel = TRUE;
result = (Node *) ident;
Assert(typename->attrname == NULL);
if (typename->arrayBounds != NIL)
{
-
/*
* By convention, the name of an array type is the name of its
* element type with "_" prepended.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.111 2001/10/04 22:06:46 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.112 2001/10/25 05:49:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
/*
- * parse function
+ * parse function
*
- * This code is confusing because the database can accept
- * relation.column, column.function, or relation.column.function.
+ * This code is confusing because the database can accept
+ * relation.column, column.function, or relation.column.function.
* In these cases, funcname is the last parameter, and fargs are
- * the rest.
+ * the rest.
*
- * It can also be called as func(col) or func(col,col).
- * In this case, Funcname is the part before parens, and fargs
- * are the part in parens.
+ * It can also be called as func(col) or func(col,col).
+ * In this case, Funcname is the part before parens, and fargs
+ * are the part in parens.
*
* FYI, projection is choosing column from a table.
*
Expr *expr;
/*
- * Most of the rest of the parser just assumes that functions do
- * not have more than FUNC_MAX_ARGS parameters. We have to test
- * here to protect against array overruns, etc. Of course, this
- * may not be a function, but the test doesn't hurt.
+ * Most of the rest of the parser just assumes that functions do not
+ * have more than FUNC_MAX_ARGS parameters. We have to test here to
+ * protect against array overruns, etc. Of course, this may not be a
+ * function, but the test doesn't hurt.
*/
if (nargs > FUNC_MAX_ARGS)
elog(ERROR, "Cannot pass more than %d arguments to a function",
/*
* test for relation.column
*
- * check for projection methods: if function takes one argument, and
- * that argument is a relation, param, or PQ function returning a
- * complex * type, then the function could be a projection.
+ * check for projection methods: if function takes one argument, and that
+ * argument is a relation, param, or PQ function returning a complex *
+ * type, then the function could be a projection.
*/
/* We only have one parameter, and it's not got aggregate decoration */
if (nargs == 1 && !must_be_agg)
{
/* Is it a plain Relation name from the parser? */
- if (IsA(first_arg, Ident) && ((Ident *) first_arg)->isRel)
+ if (IsA(first_arg, Ident) &&((Ident *) first_arg)->isRel)
{
Ident *ident = (Ident *) first_arg;
}
else if (ISCOMPLEX(exprType(first_arg)))
{
-
/*
* Attempt to handle projection of a complex argument. If
* ParseComplexProjection can't handle the projection, we have
if (nargs != 1)
elog(ERROR, "Aggregate functions may only have one parameter");
/* Agg's argument can't be a relation name, either */
- if (IsA(first_arg, Ident) && ((Ident *) first_arg)->isRel)
+ if (IsA(first_arg, Ident) &&((Ident *) first_arg)->isRel)
elog(ERROR, "Aggregate functions cannot be applied to relation names");
could_be_agg = true;
}
{
/* Try to parse as an aggregate if above-mentioned checks are OK */
could_be_agg = (nargs == 1) &&
- !(IsA(first_arg, Ident) && ((Ident *) first_arg)->isRel);
+ !(IsA(first_arg, Ident) &&((Ident *) first_arg)->isRel);
}
if (could_be_agg)
if (must_be_agg)
{
-
/*
* No matching agg, but we had '*' or DISTINCT, so a plain
* function could not have been meant.
{
Node *arg = lfirst(i);
- if (IsA(arg, Ident) && ((Ident *) arg)->isRel)
+ if (IsA(arg, Ident) &&((Ident *) arg)->isRel)
{
RangeTblEntry *rte;
int vnum;
rte = (RangeTblEntry *) rteorjoin;
else if (IsA(rteorjoin, JoinExpr))
{
-
/*
- * The relation name refers to a join. We can't support
+ * The relation name refers to a join. We can't support
* functions on join tuples (since we don't have a named
* type for the join tuples), so error out.
*/
else
{
/*
- * There are multiple arguments, so it must be a function
- * call.
+ * There are multiple arguments, so it must be a
+ * function call.
*/
elog(ERROR, "Cannot pass result of join %s to a function",
refname);
vnum = RTERangeTablePosn(pstate, rte, &sublevels_up);
/*
- * The parameter to be passed to the function is the whole tuple
- * from the relation. We build a special VarNode to reflect
- * this -- it has varno set to the correct range table entry,
- * but has varattno == 0 to signal that the whole tuple is the
- * argument. Also, it has typmod set to sizeof(Pointer) to
- * signal that the runtime representation will be a pointer
- * not an Oid.
+ * The parameter to be passed to the function is the whole
+ * tuple from the relation. We build a special VarNode to
+ * reflect this -- it has varno set to the correct range table
+ * entry, but has varattno == 0 to signal that the whole tuple
+ * is the argument. Also, it has typmod set to
+ * sizeof(Pointer) to signal that the runtime representation
+ * will be a pointer not an Oid.
*/
if (rte->relname == NULL)
{
/*
- * RTE is a subselect; must fail for lack of a specific type
+ * RTE is a subselect; must fail for lack of a specific
+ * type
*/
if (nargs == 1)
{
/*
- * Here, we probably have an unrecognized attribute of a
- * sub-select; again can't tell if it was x.f or f(x)
+ * Here, we probably have an unrecognized attribute of
+ * a sub-select; again can't tell if it was x.f or
+ * f(x)
*/
elog(ERROR, "No such attribute or function %s.%s",
refname, funcname);
}
else
{
- FuncDetailCode fdresult;
+ FuncDetailCode fdresult;
/*
* func_get_detail looks up the function in the catalogs, does
- * disambiguation for polymorphic functions, handles inheritance, and
- * returns the funcid and type and set or singleton status of the
- * function's return value. it also returns the true argument types
- * to the function.
+ * disambiguation for polymorphic functions, handles inheritance,
+ * and returns the funcid and type and set or singleton status of
+ * the function's return value. it also returns the true argument
+ * types to the function.
*/
fdresult = func_get_detail(funcname, fargs, nargs, oid_array,
&funcid, &rettype, &retset,
if (fdresult == FUNCDETAIL_COERCION)
{
/*
- * We can do it as a trivial coercion.
- * coerce_type can handle these cases, so why duplicate code...
+ * We can do it as a trivial coercion. coerce_type can handle
+ * these cases, so why duplicate code...
*/
return coerce_type(pstate, lfirst(fargs),
oid_array[0], rettype, -1);
}
else
{
-
/*
* Remember conflict, but keep going (might find
* STRING)
* (exact match) is as quick as possible.
*
* If an exact match isn't found:
- * 1) check for possible interpretation as a trivial type coercion
+ * 1) check for possible interpretation as a trivial type coercion
* 2) get a vector of all possible input arg type arrays constructed
* from the superclasses of the original input arg types
* 3) get a list of all possible argument type arrays to the function
* that this is really a type-coercion request: a single-argument
* function call where the function name is a type name. If so,
* and if we can do the coercion trivially (no run-time function
- * call needed), then go ahead and treat the "function call" as
- * a coercion. This interpretation needs to be given higher
- * priority than interpretations involving a type coercion followed
- * by a function call, otherwise we can produce surprising results.
- * For example, we want "text(varchar)" to be interpreted as a
- * trivial coercion, not as "text(name(varchar))" which the code
- * below this point is entirely capable of selecting.
+ * call needed), then go ahead and treat the "function call" as a
+ * coercion. This interpretation needs to be given higher
+ * priority than interpretations involving a type coercion
+ * followed by a function call, otherwise we can produce
+ * surprising results. For example, we want "text(varchar)" to be
+ * interpreted as a trivial coercion, not as "text(name(varchar))"
+ * which the code below this point is entirely capable of
+ * selecting.
*
- * "Trivial" coercions are ones that involve binary-compatible
- * types and ones that are coercing a previously-unknown-type
- * literal constant to a specific type.
+ * "Trivial" coercions are ones that involve binary-compatible types
+ * and ones that are coercing a previously-unknown-type literal
+ * constant to a specific type.
*
* NB: it's important that this code stays in sync with what
* coerce_type can do, because the caller will try to apply
* coerce_type if we return FUNCDETAIL_COERCION. If we return
- * that result for something coerce_type can't handle, we'll
- * cause infinite recursion between this module and coerce_type!
+ * that result for something coerce_type can't handle, we'll cause
+ * infinite recursion between this module and coerce_type!
*/
if (nargs == 1)
{
}
case T_Var:
{
-
/*
* The argument is a set, so this is either a projection
* or a function call on this set.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.55 2001/08/09 18:28:18 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.56 2001/10/25 05:49:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* forceSlice If true, treat subscript as array slice in all cases
* assignFrom NULL for array fetch, else transformed expression for source.
*/
-ArrayRef *
+ArrayRef *
transformArraySubscripts(ParseState *pstate,
Node *arrayBase,
Oid arrayType,
case T_String:
val = DirectFunctionCall1(textin, CStringGetDatum(strVal(value)));
- typeid = UNKNOWNOID;/* will be coerced later */
+ typeid = UNKNOWNOID; /* will be coerced later */
typelen = -1; /* variable len */
typebyval = false;
break;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.50 2001/08/09 18:28:18 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.51 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
else
{
-
/*
* Remember conflict, but keep going (might find
* STRING)
unary_op_error(op, arg, FALSE);
else
{
-
/*
* We must run oper_select_candidate even if only one
* candidate, otherwise we may falsely return a
unary_op_error(op, arg, TRUE);
else
{
-
/*
* We must run oper_select_candidate even if only one
* candidate, otherwise we may falsely return a
{
if (is_left_op)
elog(ERROR, "Unable to identify a prefix operator '%s' for type '%s'"
- "\n\tYou may need to add parentheses or an explicit cast",
+ "\n\tYou may need to add parentheses or an explicit cast",
op, format_type_be(arg));
else
elog(ERROR, "Unable to identify a postfix operator '%s' for type '%s'"
- "\n\tYou may need to add parentheses or an explicit cast",
+ "\n\tYou may need to add parentheses or an explicit cast",
op, format_type_be(arg));
}
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.58 2001/10/23 17:39:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.59 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
Form_pg_attribute sysatt;
- sysatt = SystemAttributeByName(a, true /* "oid" will be accepted */);
+ sysatt = SystemAttributeByName(a, true /* "oid" will be accepted */ );
if (sysatt != NULL)
return sysatt->attnum;
return InvalidAttrNumber;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.74 2001/10/08 21:48:51 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.75 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static List *ExpandAllTables(ParseState *pstate);
static char *FigureColname(Node *node);
-static int FigureColnameInternal(Node *node, char **name);
+static int FigureColnameInternal(Node *node, char **name);
/*
if (expr == NULL)
expr = transformExpr(pstate, node, EXPR_COLUMN_FIRST);
- if (IsA(expr, Ident) && ((Ident *)expr)->isRel)
- elog(ERROR,"You can't use relation names alone in the target list, try relation.*.");
+ if (IsA(expr, Ident) &&((Ident *) expr)->isRel)
+ elog(ERROR, "You can't use relation names alone in the target list, try relation.*.");
type_id = exprType(expr);
type_mod = exprTypmod(expr);
if (att->relname != NULL && strcmp(att->relname, "*") == 0)
{
-
/*
* Target item is a single '*', expand all tables (eg.
* SELECT * FROM emp)
else if (att->attrs != NIL &&
strcmp(strVal(lfirst(att->attrs)), "*") == 0)
{
-
/*
* Target item is relation.*, expand that table (eg.
* SELECT emp.*, dname FROM emp, dept)
if (pstate->p_is_insert)
{
-
/*
* The command is INSERT INTO table (arraycol[subscripts]) ...
* so there is not really a source array value to work with.
}
else
{
-
/*
* Build a Var for the array to be updated.
*/
}
else
{
-
/*
* For normal non-subscripted target column, do type checking and
* coercion. But accept InvalidOid, which indicates the source is
if (cols == NIL)
{
-
/*
* Generate default column list for INSERT.
*/
}
else
{
-
/*
* Do initial validation of user-supplied INSERT column list.
*/
static char *
FigureColname(Node *node)
{
- char *name = NULL;
+ char *name = NULL;
FigureColnameInternal(node, &name);
if (name != NULL)
static int
FigureColnameInternal(Node *node, char **name)
{
- int strength = 0;
+ int strength = 0;
if (node == NULL)
return strength;
return 1;
}
break;
- case T_TypeCast:
+ case T_TypeCast:
strength = FigureColnameInternal(((TypeCast *) node)->arg,
name);
if (strength <= 1)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.36 2001/10/09 04:15:38 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.37 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
return typtup->typelem;
}
-
#endif
#ifdef NOT_USED
return typtup->typinput;
}
-
#endif
#ifdef NOT_USED
return typtup->typoutput;
}
-
#endif
/* Given a type structure and a string, returns the internal form of
ReleaseSysCache(typeTuple);
return outfunc;
}
-
#endif
/* return a type name, given a typeid */
void
parseTypeString(const char *str, Oid *type_id, int32 *typmod)
{
- char *buf;
- List *raw_parsetree_list;
+ char *buf;
+ List *raw_parsetree_list;
SelectStmt *stmt;
- ResTarget *restarget;
- A_Const *aconst;
- TypeName *typename;
+ ResTarget *restarget;
+ A_Const *aconst;
+ TypeName *typename;
buf = (char *) palloc(strlen(str) + 16);
sprintf(buf, "SELECT (NULL::%s)", str);
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.49 2001/03/22 03:59:42 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.50 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#if defined(FLEX_SCANNER)
extern void DeleteBuffer(void);
-
#endif /* FLEX_SCANNER */
char *parseString; /* the char* which holds the string to be
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.20 2001/01/24 19:43:03 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.21 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
if (s[i] == '\'')
{
-
/*
* Note: if scanner is working right, unescaped quotes can
* only appear in pairs, so there should be another character.
TRACEDBGP("->semctl nmbre %d", Address[0]);
for (i = 0; i < Address[0]; i++)
{
-
/*
* Make sure to have ownership of the semaphore (if created by
* another team)
/* For each sem in the pool, check the operation to perform */
if (sops[i].sem_op < 0)
{
-
/*
* Try acuiring the semaphore till we are not inteerupted by a
* signal
if (ainfo.team == teinfo.team)
{
-
/*
* the area is already in our address space, just return the
* address
}
else
{
-
/*
* the area is not in our address space, clone it before and
* return the address
}
void
-beos_dl_sym(image_id im,char* symname,void** fptr)
+beos_dl_sym(image_id im, char *symname, void **fptr)
{
/* Send command '3' (get symbol) to the support server */
write_port(beos_dl_port_in, 3, symname, strlen(symname) + 1);
- write_port(beos_dl_port_in, im, NULL,0);
+ write_port(beos_dl_port_in, im, NULL, 0);
/* Read sym address */
- read_port(beos_dl_port_out, (int32*)(fptr), NULL, 0);
+ read_port(beos_dl_port_out, (int32 *) (fptr), NULL, 0);
- if (fptr==NULL)
- {
+ if (fptr == NULL)
elog(NOTICE, "loading symbol '%s' failed ", symname);
- }
}
status_t
{
if (strlen(argv[0]) >= 10 && !strcmp(argv[0] + strlen(argv[0]) - 10, "postmaster"))
{
-
/*
* We are in the postmaster, create the protection semaphore for
* shared mem remapping
* server
*/
read_port(port_in, &opcode, datas, 4000);
-
+
switch (opcode)
{
image_id addon;
image_info info_im;
area_info info_ar;
- void * fpt;
+ void *fpt;
/* Load Add-On */
case 1:
break;
/* Cleanup and exit */
case 3:
-
+
/* read image Id on the input port */
- read_port(port_in, &addon,NULL,0);
+ read_port(port_in, &addon, NULL, 0);
/* Loading symbol */
- fpt=NULL;
-
-
- if (get_image_symbol(addon, datas, B_SYMBOL_TYPE_TEXT, &fpt) == B_OK);
- {
+ fpt = NULL;
+
+ if (get_image_symbol(addon, datas, B_SYMBOL_TYPE_TEXT, &fpt) == B_OK);
+ {
/*
- * Sometime the loader return B_OK for an inexistant function
- * with an invalid address !!! Check that the return address
- * is in the image range
- */
+ * Sometime the loader return B_OK for an
+ * inexistant function with an invalid address !!!
+ * Check that the return address is in the image
+ * range
+ */
get_image_info(addon, &info_im);
if ((fpt < info_im.text) ||(fpt >= (info_im.text +info_im.text_size)))
- fpt=NULL;
+ fpt = NULL;
}
/* Send back fptr of data segment */
- write_port(port_out, (int32)(fpt),NULL,0);
+ write_port(port_out, (int32) (fpt), NULL, 0);
break;
-
+
default:
/* Free system resources */
delete_port(port_in);
* - this required changing sem_info from containig an array of sem_t to an array of sem_t*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/darwin/Attic/sem.c,v 1.4 2001/09/07 00:27:29 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/darwin/Attic/sem.c,v 1.5 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
key_t key;
int nsems;
sem_t *sem[SEMMAX]; /* array of POSIX semaphores */
- struct sem semV[SEMMAX]; /* array of System V semaphore
- * structures */
- struct pending_ops pendingOps[SEMMAX]; /* array of pending
- * operations */
+ struct sem semV[SEMMAX]; /* array of System V semaphore structures */
+ struct pending_ops pendingOps[SEMMAX]; /* array of pending
+ * operations */
};
struct sem_info
sem_t *sem;
int nsets;
/* there are actually nsets of these: */
- struct sem_set_info set[1]; /* VARIABLE LENGTH ARRAY */
+ struct sem_set_info set[1]; /* VARIABLE LENGTH ARRAY */
};
static struct sem_info *SemInfo = (struct sem_info *) - 1;
shm_unlink(SHM_INFO_NAME);
/* The size may only be set once. Ignore errors. */
nsets = PROC_SEM_MAP_ENTRIES(MaxBackends);
- sem_info_size = sizeof(struct sem_info) + (nsets-1) * sizeof(struct sem_set_info);
+ sem_info_size = sizeof(struct sem_info) + (nsets - 1) * sizeof(struct sem_set_info);
ftruncate(fd, sem_info_size);
SemInfo = mmap(NULL, sem_info_size,
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
/* Currently sem_init always returns -1. */
#ifdef NOT_USED
- if( sem_init( &SemInfo->set[semid].sem[semnum], 1, 0 ) == -1 ) {
- int semnum1;
+ if (sem_init(&SemInfo->set[semid].sem[semnum], 1, 0) == -1)
+ {
+ int semnum1;
- for( semnum1 = 0; semnum1 < semnum; semnum1++ ) {
- sem_close( SemInfo->set[semid].sem[semnum1] );
- }
- sem_post( SemInfo->sem );
+ for (semnum1 = 0; semnum1 < semnum; semnum1++)
+ sem_close(SemInfo->set[semid].sem[semnum1]);
+ sem_post(SemInfo->sem);
return -1;
}
#endif
symname = ls->l_offset + lhp->l_stoff + ldbuf;
else
{
-
/*
* The l_name member is not zero terminated, we must copy the
* first SYMNMLEN chars and make sure we have a zero byte at
free(buf);
return ret;
}
-
#endif /* HAVE_DLOPEN */
/*
- * $Id: aix.h,v 1.6 2001/05/14 21:45:53 petere Exp $
+ * $Id: aix.h,v 1.7 2001/10/25 05:49:40 momjian Exp $
*
* @(#)dlfcn.h 1.4 revision of 95/04/25 09:36:52
* This is an unpublished work copyright (c) 1992 HELIOS Software GmbH
#ifdef __cplusplus
}
-
#endif
-
#endif /* HAVE_DLOPEN */
#include "utils/dynamic_loader.h"
#define pg_dlsym dlsym
#define pg_dlclose dlclose
#define pg_dlerror dlerror
-
#endif /* PORT_PROTOS_H */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.8 2001/08/07 16:56:17 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.9 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* Checking that "Handle" is valid */
if ((handle) && ((*(int *) (handle)) >= 0))
{
- beos_dl_sym(*((int *) (handle)),funcname,(void **) &fpt);
+ beos_dl_sym(*((int *) (handle)), funcname, (void **) &fpt);
return fpt;
}
elog(NOTICE, "add-on not loaded correctly");
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: beos.h,v 1.4 2001/01/24 19:43:04 momjian Exp $
+ * $Id: beos.h,v 1.5 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PORT_PROTOS_H
#define PORT_PROTOS_H
-
#endif /* PORT_PROTOS_H */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/dynloader/bsdi.c,v 1.15 2001/05/30 18:32:29 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/dynloader/bsdi.c,v 1.16 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
return dld_strerror(dld_errno);
}
-
-#endif /* not HAVE_DLOPEN */
+#endif /* not HAVE_DLOPEN */
#define pg_dlclose dlclose
#define pg_dlerror dlerror
-#else /* not HAVE_DLOPEN */
+#else /* not HAVE_DLOPEN */
#define pg_dlsym(handle, funcname) ((PGFunction) dld_get_func((funcname)))
#define pg_dlclose(handle) \
dld_unlink_by_file(handle, 1); \
free(handle); \
} while (0)
-
-#endif /* not HAVE_DLOPEN */
-
+#endif /* not HAVE_DLOPEN */
#endif /* PORT_PROTOS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: dgux.h,v 1.10 2001/05/14 21:45:53 petere Exp $
+ * $Id: dgux.h,v 1.11 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define pg_dlsym dlsym
#define pg_dlclose dlclose
#define pg_dlerror dlerror
-
#endif /* PORT_PROTOS_H */
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91";
-
#endif /* LIBC_SCCS and not lint */
#include
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: freebsd.h,v 1.10 2001/05/15 16:55:27 petere Exp $
+ * $Id: freebsd.h,v 1.11 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
void *BSD44_derived_dlopen(const char *filename, int num);
void *BSD44_derived_dlsym(void *handle, const char *name);
void BSD44_derived_dlclose(void *handle);
-
#endif /* PORT_PROTOS_H */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/dynloader/hpux.c,v 1.18 2001/03/22 03:59:43 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/dynloader/hpux.c,v 1.19 2001/10/25 05:49:40 momjian Exp $
*
* NOTES
* all functions are defined here -- it's impossible to trace the
void *
pg_dlopen(char *filename)
{
-
/*
* Use BIND_IMMEDIATE so that undefined symbols cause a failure return
* from shl_load(), rather than an abort() later on when we attempt to
#define pg_dlsym dlsym
#define pg_dlclose dlclose
#define pg_dlerror dlerror
-
#endif /* PORT_PROTOS_H */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/dynloader/linux.c,v 1.18 2001/01/24 19:43:04 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/dynloader/linux.c,v 1.19 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
return dld_strerror(dld_errno);
#endif
}
-
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: linux.h,v 1.13 2001/10/25 01:29:37 momjian Exp $
+ * $Id: linux.h,v 1.14 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
dld_unlink_by_file(handle, 1); \
free(handle); \
} while (0)
-
#endif
-#else /* HAVE_DLOPEN */
+#else /* HAVE_DLOPEN */
#define pg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
#define pg_dlsym dlsym
#define pg_dlclose dlclose
#define pg_dlerror dlerror
-
-#endif /* HAVE_DLOPEN */
-
+#endif /* HAVE_DLOPEN */
#endif /* PORT_PROTOS_H */
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91";
-
#endif /* LIBC_SCCS and not lint */
#include
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: netbsd.h,v 1.5 2001/05/15 16:55:27 petere Exp $
+ * $Id: netbsd.h,v 1.6 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
void *BSD44_derived_dlopen(const char *filename, int num);
void *BSD44_derived_dlsym(void *handle, const char *name);
void BSD44_derived_dlclose(void *handle);
-
#endif /* PORT_PROTOS_H */
#define pg_dlerror next_dlerror
/* port.c */
-
#endif /* PORT_PROTOS_H */
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91";
-
#endif /* LIBC_SCCS and not lint */
#include
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: openbsd.h,v 1.6 2001/06/20 18:33:31 petere Exp $
+ * $Id: openbsd.h,v 1.7 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
void *BSD44_derived_dlopen(const char *filename, int num);
void *BSD44_derived_dlsym(void *handle, const char *name);
void BSD44_derived_dlclose(void *handle);
-
#endif /* PORT_PROTOS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: osf.h,v 1.3 2001/05/14 21:45:53 petere Exp $
+ * $Id: osf.h,v 1.4 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define pg_dlsym(h, f) ((PGFunction) dlsym(h, f))
#define pg_dlclose(h) dlclose(h)
#define pg_dlerror() dlerror()
-
#endif /* PORT_PROTOS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: sco.h,v 1.8 2001/05/14 21:45:53 petere Exp $
+ * $Id: sco.h,v 1.9 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define pg_dlerror dlerror
/* port.c */
-
#endif /* PORT_PROTOS_H */
-/* $Header: /cvsroot/pgsql/src/backend/port/dynloader/solaris.h,v 1.4 2001/05/14 21:45:53 petere Exp $ */
+/* $Header: /cvsroot/pgsql/src/backend/port/dynloader/solaris.h,v 1.5 2001/10/25 05:49:40 momjian Exp $ */
#ifndef DYNLOADER_SOLARIS_H
#define DYNLOADER_SOLARIS_H
#define pg_dlsym dlsym
#define pg_dlclose dlclose
#define pg_dlerror dlerror
-
#endif /* DYNLOADER_SOLARIS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: sunos4.h,v 1.8 2001/05/14 21:45:53 petere Exp $
+ * $Id: sunos4.h,v 1.9 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define pg_dlsym dlsym
#define pg_dlclose dlclose
#define pg_dlerror dlerror
-
#endif /* PORT_PROTOS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: svr4.h,v 1.8 2001/05/14 21:45:53 petere Exp $
+ * $Id: svr4.h,v 1.9 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define pg_dlsym dlsym
#define pg_dlclose dlclose
#define pg_dlerror dlerror
-
#endif /* DYNLOADER_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: ultrix4.h,v 1.7 2001/01/24 19:43:04 momjian Exp $
+ * $Id: ultrix4.h,v 1.8 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef enum
{
- DL_NEEDRELOC, /* still need relocation */
- DL_RELOCATED, /* no relocation necessary */
- DL_INPROG /* relocation in progress */
+ DL_NEEDRELOC, /* still need relocation */
+ DL_RELOCATED, /* no relocation necessary */
+ DL_INPROG /* relocation in progress */
} dlRStatus;
typedef struct JmpTbl
extern char **dl_undefinedSymbols( /* int *count */ );
extern void dl_printAllSymbols( /* void *handle */ );
extern void dl_setLibraries( /* char *libs */ );
-
#endif /* _DL_HEADER_ */
#define pg_dlsym dlsym
#define pg_dlclose dlclose
#define pg_dlerror dlerror
-
#endif /* PORT_PROTOS_H */
#define pg_dlsym dlsym
#define pg_dlclose dlclose
#define pg_dlerror dlerror
-
#endif /* PORT_PROTOS_H */
#define pg_dlsym dlsym
#define pg_dlclose dlclose
#define pg_dlerror dlerror
-
#endif /* PORT_PROTOS_H */
-/* $Id: inet_aton.c,v 1.19 2001/08/24 14:07:49 petere Exp $
+/* $Id: inet_aton.c,v 1.20 2001/10/25 05:49:40 momjian Exp $
*
* This inet_aton() function was taken from the GNU C library and
* incorporated into Postgres for those systems which do not have this
for (;;)
{
-
/*
* Collect number up to ``.''. Values are specified as for C:
* 0x=hex, 0=octal, other=decimal.
}
if (*cp == '.')
{
-
/*
* Internet format: a.b.c.d a.b.c (with c treated as
* 16-bits) a.b (with b treated as 24 bits)
-/* $Id: isinf.c,v 1.16 2001/08/24 14:07:49 petere Exp $ */
+/* $Id: isinf.c,v 1.17 2001/10/25 05:49:40 momjian Exp $ */
#include "c.h"
#else
int fpclass = fp_class_d(x);
-
#endif
if (fpclass == FP_POS_INF)
return -1;
return 0;
}
-
#endif
#endif
return -1;
return 0;
}
-
#endif
{
return getwd(buf);
}
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/ipc.h,v 1.3 2001/03/18 18:32:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/ipc.h,v 1.4 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* Control Commands. */
#define IPC_RMID 0 /* remove identifier */
#define IPC_STAT 1 /* get shm status */
-
#endif /* _SYS_IPC_H */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.c,v 1.7 2001/09/07 00:27:29 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.c,v 1.8 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
key_t key;
int nsems;
sem_t sem[SEMMAX]; /* array of POSIX semaphores */
- struct sem semV[SEMMAX]; /* array of System V semaphore
- * structures */
- struct pending_ops pendingOps[SEMMAX]; /* array of pending
- * operations */
+ struct sem semV[SEMMAX]; /* array of System V semaphore structures */
+ struct pending_ops pendingOps[SEMMAX]; /* array of pending
+ * operations */
};
struct sem_info
sem_t sem;
int nsets;
/* there are actually nsets of these: */
- struct sem_set_info set[1]; /* VARIABLE LENGTH ARRAY */
+ struct sem_set_info set[1]; /* VARIABLE LENGTH ARRAY */
};
static struct sem_info *SemInfo = (struct sem_info *) - 1;
/* ----------------------------------------------------------------
* semclean - remove the shared memory file on exit
- * only called by the process which created the shm file
+ * only called by the process which created the shm file
* ----------------------------------------------------------------
*/
static void
-semclean( void )
+semclean(void)
{
- remove( "/dev/shmem/" SHM_INFO_NAME );
+ remove("/dev/shmem/" SHM_INFO_NAME);
}
int
return fd;
/* The size may only be set once. Ignore errors. */
nsets = PROC_SEM_MAP_ENTRIES(MaxBackends);
- sem_info_size = sizeof(struct sem_info) + (nsets-1) * sizeof(struct sem_set_info);
+ sem_info_size = sizeof(struct sem_info) + (nsets - 1) * sizeof(struct sem_set_info);
ltrunc(fd, sem_info_size, SEEK_SET);
- if ( fstat( fd, &statbuf ) ) /* would be strange : the only doc'ed */
- { /* error is EBADF */
- close( fd );
+ if (fstat(fd, &statbuf))/* would be strange : the only doc'ed */
+ { /* error is EBADF */
+ close(fd);
+ return -1;
+ }
+
+ /*
+ * size is rounded by proc to the next __PAGESIZE
+ */
+ if (statbuf.st_size !=
+ (((sem_info_size / __PAGESIZE) + 1) * __PAGESIZE))
+ {
+ fprintf(stderr,
+ "Found a pre-existing shared memory block for the semaphore memory\n"
+ "of a different size (%ld instead %ld). Make sure that all executables\n"
+ "are from the same release or remove the file \"/dev/shmem/%s\"\n"
+ "left by a previous version.\n",
+ (long) statbuf.st_size,
+ (long) sem_info_size,
+ SHM_INFO_NAME);
+ errno = EACCES;
return -1;
}
- /*
- * size is rounded by proc to the next __PAGESIZE
- */
- if ( statbuf.st_size !=
- (((sem_info_size/__PAGESIZE)+1) * __PAGESIZE) )
- {
- fprintf( stderr,
- "Found a pre-existing shared memory block for the semaphore memory\n"
- "of a different size (%ld instead %ld). Make sure that all executables\n"
- "are from the same release or remove the file \"/dev/shmem/%s\"\n"
- "left by a previous version.\n",
- (long) statbuf.st_size,
- (long) sem_info_size,
- SHM_INFO_NAME);
- errno = EACCES;
- return -1;
- }
SemInfo = mmap(NULL, sem_info_size,
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (SemInfo == MAP_FAILED)
SemInfo->set[semid].key = -1;
/* create semaphore for locking */
sem_init(&SemInfo->sem, 1, 1);
- on_proc_exit( semclean, 0 );
+ on_proc_exit(semclean, 0);
}
}
sem_init(&SemInfo->set[semid].sem[semnum], 1, 0);
/* Currently sem_init always returns -1. */
#ifdef NOT_USED
- if( sem_init( &SemInfo->set[semid].sem[semnum], 1, 0 ) == -1 ) {
- int semnum1;
+ if (sem_init(&SemInfo->set[semid].sem[semnum], 1, 0) == -1)
+ {
+ int semnum1;
- for( semnum1 = 0; semnum1 < semnum; semnum1++ ) {
- sem_destroy( &SemInfo->set[semid].sem[semnum1] );
- }
- sem_post( &SemInfo->sem );
+ for (semnum1 = 0; semnum1 < semnum; semnum1++)
+ sem_destroy(&SemInfo->set[semid].sem[semnum1]);
+ sem_post(&SemInfo->sem);
return -1;
}
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.h,v 1.3 2000/04/12 17:15:30 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.h,v 1.4 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifdef __cplusplus
}
-
#endif
-
#endif /* _SYS_SEM_H */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.c,v 1.6 2001/08/24 14:07:49 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.c,v 1.7 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static char *
keytoname(key_t key, char *name)
{
- sprintf( name,"PgShm%x", key );
- return name;
+ sprintf(name, "PgShm%x", key);
+ return name;
}
static int
{
struct shm_info info;
char name[NAME_MAX + 1];
- int result;
- int fd;
- struct stat statbuf;
+ int result;
+ int fd;
+ struct stat statbuf;
-
- switch( cmd )
- {
- case IPC_RMID :
- if (shm_getinfo(shmid, &info) == -1)
- {
- errno = EACCES;
- return -1;
- }
- close( info.shmid );
- keytoname(info.key, name);
- return shm_unlink( name );
-
- case IPC_STAT :
- /*
- * we have to open it first. stat() does no prefix tracking
- * -> the call would go to fsys instead of proc
- */
- keytoname(shmid, name);
- fd = shm_open( name, 0, MODE );
- if ( fd >= 0 )
- {
- result = fstat( fd, &statbuf );
- /*
- * if the file exists, subtract 2 from linkcount :
- * one for our own open and one for the dir entry
- */
- if ( ! result )
- buf->shm_nattch = statbuf.st_nlink-2;
- close( fd );
- return result;
- }
- else
+
+ switch (cmd)
{
- /*
- * if there's no entry for this key it doesn't matter
- * the next shmget() would get a different shm anyway
- */
- buf->shm_nattch = 0;
- return 0;
- }
+ case IPC_RMID:
+ if (shm_getinfo(shmid, &info) == -1)
+ {
+ errno = EACCES;
+ return -1;
+ }
+ close(info.shmid);
+ keytoname(info.key, name);
+ return shm_unlink(name);
+
+ case IPC_STAT:
+
+ /*
+ * we have to open it first. stat() does no prefix tracking ->
+ * the call would go to fsys instead of proc
+ */
+ keytoname(shmid, name);
+ fd = shm_open(name, 0, MODE);
+ if (fd >= 0)
+ {
+ result = fstat(fd, &statbuf);
+
+ /*
+ * if the file exists, subtract 2 from linkcount : one for
+ * our own open and one for the dir entry
+ */
+ if (!result)
+ buf->shm_nattch = statbuf.st_nlink - 2;
+ close(fd);
+ return result;
+ }
+ else
+ {
+ /*
+ * if there's no entry for this key it doesn't matter the
+ * next shmget() would get a different shm anyway
+ */
+ buf->shm_nattch = 0;
+ return 0;
+ }
}
errno = EINVAL;
return -1;
info.key = key;
info.size = size;
info.addr = NULL;
- if (shm_putinfo(&info) == -1) {
- close( info.shmid );
- if ( (oflag & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL) ) {
- shm_unlink( name );
- }
+ if (shm_putinfo(&info) == -1)
+ {
+ close(info.shmid);
+ if ((oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
+ shm_unlink(name);
return -1;
- }
+ }
}
/* The size may only be set once. Ignore errors. */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.h,v 1.3 2001/03/18 18:32:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.h,v 1.4 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifdef __cplusplus
}
-
#endif
-
#endif /* _SYS_SHM_H */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstsem.c,v 1.5 2001/08/24 14:07:49 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstsem.c,v 1.6 2001/10/25 05:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
printf("semval = %d\n", i);
}
-void on_proc_exit( void (*function)(), Datum arg )
+void on_proc_exit(void (*function) (), Datum arg)
{
- atexit( function );
+ atexit(function);
}
int
main(int argc, char **argv)
#else
typedef long long_long;
typedef unsigned long ulong_long;
-
#endif
/*
* causing nast effects.
**************************************************************/
-/*static char _id[] = "$Id: snprintf.c,v 1.30 2001/02/10 02:31:26 tgl Exp $";*/
+/*static char _id[] = "$Id: snprintf.c,v 1.31 2001/10/25 05:49:40 momjian Exp $";*/
static char *end;
static int SnprfOverflow;
-/* $Id: strcasecmp.c,v 1.7 2001/01/24 19:43:03 momjian Exp $ */
+/* $Id: strcasecmp.c,v 1.8 2001/10/25 05:49:40 momjian Exp $ */
/*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
-
#endif /* LIBC_SCCS and not lint */
#include
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91";
-
#endif /* LIBC_SCCS and not lint */
#include
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93";
-
#endif /* LIBC_SCCS and not lint */
#include
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: float.h,v 1.6 2001/01/24 19:43:04 momjian Exp $
+ * $Id: float.h,v 1.7 2001/10/25 05:49:40 momjian Exp $
*
* NOTES
* These come straight out of ANSI X3.159-1989 (p.18) and
#define DBL_DIG 15
#define DBL_MIN 2.2250738585072014e-308
#define DBL_MAX 1.7976931348623157e+308
-
#endif /* FLOAT_H */
*
* Copyright (c) 2001, PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.13 2001/10/22 19:41:38 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.14 2001/10/25 05:49:40 momjian Exp $
* ----------
*/
#include "postgres.h"
* GUC parameters
* ----------
*/
-bool pgstat_collect_startcollector = true;
-bool pgstat_collect_resetonpmstart = true;
-bool pgstat_collect_querystring = false;
-bool pgstat_collect_tuplelevel = false;
-bool pgstat_collect_blocklevel = false;
+bool pgstat_collect_startcollector = true;
+bool pgstat_collect_resetonpmstart = true;
+bool pgstat_collect_querystring = false;
+bool pgstat_collect_tuplelevel = false;
+bool pgstat_collect_blocklevel = false;
/* ----------
* Local data
* ----------
*/
-static int pgStatSock = -1;
-static int pgStatPipe[2];
-static struct sockaddr_in pgStatAddr;
-static int pgStatPmPipe[2] = { -1, -1 };
+static int pgStatSock = -1;
+static int pgStatPipe[2];
+static struct sockaddr_in pgStatAddr;
+static int pgStatPmPipe[2] = {-1, -1};
-static int pgStatRunning = 0;
-static int pgStatPid;
+static int pgStatRunning = 0;
+static int pgStatPid;
-static long pgStatNumMessages = 0;
+static long pgStatNumMessages = 0;
-static bool pgStatRunningInCollector = FALSE;
-static int pgStatTabstatAlloc = 0;
-static int pgStatTabstatUsed = 0;
-static PgStat_MsgTabstat **pgStatTabstatMessages = NULL;
-static int pgStatXactCommit = 0;
-static int pgStatXactRollback = 0;
+static bool pgStatRunningInCollector = FALSE;
+static int pgStatTabstatAlloc = 0;
+static int pgStatTabstatUsed = 0;
+static PgStat_MsgTabstat **pgStatTabstatMessages = NULL;
+static int pgStatXactCommit = 0;
+static int pgStatXactRollback = 0;
-static TransactionId pgStatDBHashXact = InvalidTransactionId;
-static HTAB *pgStatDBHash = NULL;
-static HTAB *pgStatBeDead = NULL;
-static PgStat_StatBeEntry *pgStatBeTable = NULL;
-static int pgStatNumBackends = 0;
+static TransactionId pgStatDBHashXact = InvalidTransactionId;
+static HTAB *pgStatDBHash = NULL;
+static HTAB *pgStatBeDead = NULL;
+static PgStat_StatBeEntry *pgStatBeTable = NULL;
+static int pgStatNumBackends = 0;
-static char pgStat_tmpfname[MAXPGPATH];
-static char pgStat_fname[MAXPGPATH];
+static char pgStat_tmpfname[MAXPGPATH];
+static char pgStat_fname[MAXPGPATH];
/* ----------
* Local function forward declarations
* ----------
*/
-static void pgstat_main(void);
-static void pgstat_recvbuffer(void);
-static void pgstat_die(SIGNAL_ARGS);
-
-static int pgstat_add_backend(PgStat_MsgHdr *msg);
-static void pgstat_sub_backend(int procpid);
-static void pgstat_drop_database(Oid databaseid);
-static void pgstat_write_statsfile(void);
-static void pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
- PgStat_StatBeEntry **betab,
- int *numbackends);
-
-static void pgstat_setheader(PgStat_MsgHdr *hdr, int mtype);
-static void pgstat_send(void *msg, int len);
-
-static void pgstat_recv_bestart(PgStat_MsgBestart *msg, int len);
-static void pgstat_recv_beterm(PgStat_MsgBeterm *msg, int len);
-static void pgstat_recv_activity(PgStat_MsgActivity *msg, int len);
-static void pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len);
-static void pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len);
-static void pgstat_recv_dropdb(PgStat_MsgDropdb *msg, int len);
-static void pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len);
+static void pgstat_main(void);
+static void pgstat_recvbuffer(void);
+static void pgstat_die(SIGNAL_ARGS);
+
+static int pgstat_add_backend(PgStat_MsgHdr *msg);
+static void pgstat_sub_backend(int procpid);
+static void pgstat_drop_database(Oid databaseid);
+static void pgstat_write_statsfile(void);
+static void pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
+ PgStat_StatBeEntry **betab,
+ int *numbackends);
+
+static void pgstat_setheader(PgStat_MsgHdr *hdr, int mtype);
+static void pgstat_send(void *msg, int len);
+
+static void pgstat_recv_bestart(PgStat_MsgBestart *msg, int len);
+static void pgstat_recv_beterm(PgStat_MsgBeterm *msg, int len);
+static void pgstat_recv_activity(PgStat_MsgActivity *msg, int len);
+static void pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len);
+static void pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len);
+static void pgstat_recv_dropdb(PgStat_MsgDropdb *msg, int len);
+static void pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len);
/* ------------------------------------------------------------
* Force start of collector daemon if something to collect
*/
if (pgstat_collect_querystring || pgstat_collect_tuplelevel ||
- pgstat_collect_blocklevel)
+ pgstat_collect_blocklevel)
pgstat_collect_startcollector = true;
/*
* Initialize the filenames for the status reports.
*/
- snprintf(pgStat_tmpfname, MAXPGPATH,
- PGSTAT_STAT_TMPFILE, DataDir, getpid());
- snprintf(pgStat_fname, MAXPGPATH,
- PGSTAT_STAT_FILENAME, DataDir);
+ snprintf(pgStat_tmpfname, MAXPGPATH,
+ PGSTAT_STAT_TMPFILE, DataDir, getpid());
+ snprintf(pgStat_fname, MAXPGPATH,
+ PGSTAT_STAT_FILENAME, DataDir);
/*
- * If we don't have to start a collector or should reset the
- * collected statistics on postmaster start, simply remove the
- * file.
+ * If we don't have to start a collector or should reset the collected
+ * statistics on postmaster start, simply remove the file.
*/
if (!pgstat_collect_startcollector || pgstat_collect_resetonpmstart)
unlink(pgStat_fname);
}
/*
- * Bind it to a kernel assigned port on localhost and
- * get the assigned port via getsockname().
+ * Bind it to a kernel assigned port on localhost and get the assigned
+ * port via getsockname().
*/
- pgStatAddr.sin_family = AF_INET;
- pgStatAddr.sin_port = htons(0);
+ pgStatAddr.sin_family = AF_INET;
+ pgStatAddr.sin_port = htons(0);
inet_aton("127.0.0.1", &(pgStatAddr.sin_addr));
alen = sizeof(pgStatAddr);
- if (bind(pgStatSock, (struct sockaddr *)&pgStatAddr, alen) < 0)
+ if (bind(pgStatSock, (struct sockaddr *) & pgStatAddr, alen) < 0)
{
perror("PGSTAT: bind(2)");
close(pgStatSock);
pgStatSock = -1;
return -1;
}
- if (getsockname(pgStatSock, (struct sockaddr *)&pgStatAddr, &alen) < 0)
+ if (getsockname(pgStatSock, (struct sockaddr *) & pgStatAddr, &alen) < 0)
{
perror("PGSTAT: getsockname(2)");
close(pgStatSock);
}
/*
- * Connect the socket to its own address. This saves a few cycles
- * by not having to respecify the target address on every send.
- * This also provides a kernel-level check that only packets from
- * this same address will be received.
+ * Connect the socket to its own address. This saves a few cycles by
+ * not having to respecify the target address on every send. This also
+ * provides a kernel-level check that only packets from this same
+ * address will be received.
*/
- if (connect(pgStatSock, (struct sockaddr *)&pgStatAddr, alen) < 0)
+ if (connect(pgStatSock, (struct sockaddr *) & pgStatAddr, alen) < 0)
{
perror("PGSTAT: connect(2)");
close(pgStatSock);
*/
if (pgStatSock < 0)
{
- fprintf(stderr,
- "PGSTAT: suppress collector startup due to missing socket\n");
+ fprintf(stderr,
+ "PGSTAT: suppress collector startup due to missing socket\n");
return 0;
}
beos_before_backend_startup();
#endif
- switch ((pgStatPid = (int)fork()))
+ switch ((pgStatPid = (int) fork()))
{
case -1:
#ifdef __BEOS__
void
pgstat_beterm(int pid)
{
- PgStat_MsgBeterm msg;
+ PgStat_MsgBeterm msg;
if (!pgstat_collect_startcollector || pgStatSock < 0)
return;
- msg.m_hdr.m_type = PGSTAT_MTYPE_BETERM;
- msg.m_hdr.m_backendid = 0;
- msg.m_hdr.m_procpid = pid;
- msg.m_hdr.m_databaseid = 0;
+ msg.m_hdr.m_type = PGSTAT_MTYPE_BETERM;
+ msg.m_hdr.m_backendid = 0;
+ msg.m_hdr.m_procpid = pid;
+ msg.m_hdr.m_databaseid = 0;
pgstat_send(&msg, sizeof(msg));
}
/* ------------------------------------------------------------
* Public functions used by backends follow
- *------------------------------------------------------------
+ *------------------------------------------------------------
*/
void
pgstat_bestart(void)
{
- PgStat_MsgBestart msg;
+ PgStat_MsgBestart msg;
if (!pgstat_collect_startcollector || pgStatSock < 0)
return;
void
pgstat_report_activity(char *what)
{
- PgStat_MsgActivity msg;
- int len;
+ PgStat_MsgActivity msg;
+ int len;
if (!pgstat_collect_querystring || pgStatSock < 0)
return;
len = strlen(what);
if (len >= PGSTAT_ACTIVITY_SIZE)
len = PGSTAT_ACTIVITY_SIZE - 1;
-
+
memcpy(msg.m_what, what, len);
msg.m_what[len] = '\0';
- len += offsetof(PgStat_MsgActivity, m_what) + 1;
+ len += offsetof(PgStat_MsgActivity, m_what) +1;
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_ACTIVITY);
pgstat_send(&msg, len);
void
pgstat_report_tabstat(void)
{
- int i;
- int n;
- int len;
+ int i;
+ int n;
+ int len;
if (!pgstat_collect_querystring && !pgstat_collect_tuplelevel &&
- !pgstat_collect_blocklevel)
+ !pgstat_collect_blocklevel)
return;
if (pgStatSock < 0)
return;
/*
- * For each message buffer used during the last query
- * set the header fields and send it out.
+ * For each message buffer used during the last query set the header
+ * fields and send it out.
*/
for (i = 0; i < pgStatTabstatUsed; i++)
{
n = pgStatTabstatMessages[i]->m_nentries;
len = offsetof(PgStat_MsgTabstat, m_entry[n]);
- pgStatTabstatMessages[i]->m_xact_commit = pgStatXactCommit;
+ pgStatTabstatMessages[i]->m_xact_commit = pgStatXactCommit;
pgStatTabstatMessages[i]->m_xact_rollback = pgStatXactRollback;
- pgStatXactCommit = 0;
+ pgStatXactCommit = 0;
pgStatXactRollback = 0;
- pgstat_setheader(&pgStatTabstatMessages[i]->m_hdr,
- PGSTAT_MTYPE_TABSTAT);
+ pgstat_setheader(&pgStatTabstatMessages[i]->m_hdr,
+ PGSTAT_MTYPE_TABSTAT);
pgstat_send(pgStatTabstatMessages[i], len);
}
int
pgstat_vacuum_tabstat(void)
{
- Relation dbrel;
- HeapScanDesc dbscan;
- HeapTuple dbtup;
- Oid *dbidlist;
- int dbidalloc;
- int dbidused;
- HASH_SEQ_STATUS hstat;
- PgStat_StatDBEntry *dbentry;
- PgStat_StatTabEntry *tabentry;
- HeapTuple reltup;
- int nobjects = 0;
- PgStat_MsgTabpurge msg;
- int len;
- int i;
+ Relation dbrel;
+ HeapScanDesc dbscan;
+ HeapTuple dbtup;
+ Oid *dbidlist;
+ int dbidalloc;
+ int dbidused;
+ HASH_SEQ_STATUS hstat;
+ PgStat_StatDBEntry *dbentry;
+ PgStat_StatTabEntry *tabentry;
+ HeapTuple reltup;
+ int nobjects = 0;
+ PgStat_MsgTabpurge msg;
+ int len;
+ int i;
if (pgStatSock < 0)
return 0;
/*
- * We don't vacuum inside of transaction blocks, because
- * a possible later rollback might reactivate objects we
- * didn't find because of earlier destruction in the xact.
+ * We don't vacuum inside of transaction blocks, because a possible
+ * later rollback might reactivate objects we didn't find because of
+ * earlier destruction in the xact.
*/
if (IsTransactionBlock())
return 0;
*/
if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId()))
{
- pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
+ pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
&pgStatBeTable, &pgStatNumBackends);
pgStatDBHashXact = GetCurrentTransactionId();
}
/*
* Lookup our own database entry
*/
- dbentry = (PgStat_StatDBEntry *)hash_search(pgStatDBHash,
- (void *) &MyDatabaseId,
- HASH_FIND, NULL);
+ dbentry = (PgStat_StatDBEntry *) hash_search(pgStatDBHash,
+ (void *) &MyDatabaseId,
+ HASH_FIND, NULL);
if (dbentry == NULL)
return -1;
/*
* Check for all tables if they still exist.
*/
- hash_seq_init(&hstat, dbentry->tables);
+ hash_seq_init(&hstat, dbentry->tables);
while ((tabentry = (PgStat_StatTabEntry *) hash_seq_search(&hstat)) != NULL)
{
/*
- * Check if this relation is still alive by
- * looking up it's pg_class tuple in the
- * system catalog cache.
+ * Check if this relation is still alive by looking up it's
+ * pg_class tuple in the system catalog cache.
*/
reltup = SearchSysCache(RELOID,
- ObjectIdGetDatum(tabentry->tableid),
- 0, 0, 0);
+ ObjectIdGetDatum(tabentry->tableid),
+ 0, 0, 0);
if (HeapTupleIsValid(reltup))
{
ReleaseSysCache(reltup);
*/
dbidalloc = 256;
dbidused = 0;
- dbidlist = (Oid *)palloc(sizeof(Oid) * dbidalloc);
+ dbidlist = (Oid *) palloc(sizeof(Oid) * dbidalloc);
dbrel = heap_openr(DatabaseRelationName, AccessShareLock);
dbscan = heap_beginscan(dbrel, 0, SnapshotNow, 0, NULL);
if (dbidused >= dbidalloc)
{
dbidalloc *= 2;
- dbidlist = (Oid *)repalloc((char *)dbidlist,
- sizeof(Oid) * dbidalloc);
+ dbidlist = (Oid *) repalloc((char *) dbidlist,
+ sizeof(Oid) * dbidalloc);
}
dbidlist[dbidused++] = dbtup->t_data->t_oid;
}
heap_close(dbrel, AccessShareLock);
/*
- * Search the database hash table for dead databases and
- * tell the collector to drop them as well.
+ * Search the database hash table for dead databases and tell the
+ * collector to drop them as well.
*/
hash_seq_init(&hstat, pgStatDBHash);
while ((dbentry = (PgStat_StatDBEntry *) hash_seq_search(&hstat)) != NULL)
{
- Oid dbid = dbentry->databaseid;
+ Oid dbid = dbentry->databaseid;
for (i = 0; i < dbidused; i++)
{
/*
* Free the dbid list.
*/
- pfree((char *)dbidlist);
+ pfree((char *) dbidlist);
/*
* Tell the caller how many removeable objects we found
static void
pgstat_drop_database(Oid databaseid)
{
- PgStat_MsgDropdb msg;
+ PgStat_MsgDropdb msg;
if (pgStatSock < 0)
return;
void
pgstat_reset_counters(void)
{
- PgStat_MsgResetcounter msg;
+ PgStat_MsgResetcounter msg;
if (pgStatSock < 0)
return;
void
pgstat_ping(void)
{
- PgStat_MsgDummy msg;
+ PgStat_MsgDummy msg;
if (pgStatSock < 0)
return;
void
pgstat_initstats(PgStat_Info *stats, Relation rel)
{
- PgStat_TableEntry *useent = NULL;
- Oid rel_id = rel->rd_id;
- int mb;
- int i;
+ PgStat_TableEntry *useent = NULL;
+ Oid rel_id = rel->rd_id;
+ int mb;
+ int i;
/*
* Initialize data not to count at all.
*/
- stats->tabentry = NULL;
- stats->no_stats = FALSE;
- stats->heap_scan_counted = FALSE;
- stats->index_scan_counted = FALSE;
+ stats->tabentry = NULL;
+ stats->no_stats = FALSE;
+ stats->heap_scan_counted = FALSE;
+ stats->index_scan_counted = FALSE;
if (!pgstat_collect_startcollector || pgStatSock < 0)
{
{
pgStatTabstatAlloc = 4;
pgStatTabstatMessages = (PgStat_MsgTabstat **)
- malloc(sizeof(PgStat_MsgTabstat *) * pgStatTabstatAlloc);
+ malloc(sizeof(PgStat_MsgTabstat *) * pgStatTabstatAlloc);
if (pgStatTabstatMessages == NULL)
{
perror("PGSTATBE: malloc(2)");
for (i = 0; i < pgStatTabstatAlloc; i++)
{
pgStatTabstatMessages[i] = (PgStat_MsgTabstat *)
- malloc(sizeof(PgStat_MsgTabstat));
+ malloc(sizeof(PgStat_MsgTabstat));
if (pgStatTabstatMessages[i] == NULL)
{
perror("PGSTATBE: malloc(2)");
{
if (pgStatTabstatMessages[mb]->m_entry[i].t_id == rel_id)
{
- stats->tabentry = (void *)&(pgStatTabstatMessages[mb]->m_entry[i]);
+ stats->tabentry = (void *) &(pgStatTabstatMessages[mb]->m_entry[i]);
return;
}
}
if (pgStatTabstatMessages[mb]->m_nentries >= PGSTAT_NUM_TABENTRIES)
continue;
-
+
/*
* Not found, but found a message buffer with an empty slot
* instead. Fine, let's use this one.
useent = &pgStatTabstatMessages[mb]->m_entry[i];
memset(useent, 0, sizeof(PgStat_TableEntry));
useent->t_id = rel_id;
- stats->tabentry = (void *)useent;
+ stats->tabentry = (void *) useent;
return;
}
{
pgStatTabstatAlloc += 4;
pgStatTabstatMessages = (PgStat_MsgTabstat **)
- realloc(pgStatTabstatMessages,
+ realloc(pgStatTabstatMessages,
sizeof(PgStat_MsgTabstat *) * pgStatTabstatAlloc);
if (pgStatTabstatMessages == NULL)
{
for (i = pgStatTabstatUsed; i < pgStatTabstatAlloc; i++)
{
pgStatTabstatMessages[i] = (PgStat_MsgTabstat *)
- malloc(sizeof(PgStat_MsgTabstat));
+ malloc(sizeof(PgStat_MsgTabstat));
if (pgStatTabstatMessages[i] == NULL)
{
pgStatTabstatAlloc -= 4;
useent = &pgStatTabstatMessages[mb]->m_entry[0];
memset(useent, 0, sizeof(PgStat_TableEntry));
useent->t_id = rel_id;
- stats->tabentry = (void *)useent;
+ stats->tabentry = (void *) useent;
return;
}
pgstat_count_xact_commit(void)
{
if (!pgstat_collect_querystring && !pgstat_collect_tuplelevel &&
- !pgstat_collect_blocklevel)
+ !pgstat_collect_blocklevel)
return;
pgStatXactCommit++;
/*
- * If there was no relation activity yet, just make
- * one existing message buffer used without slots,
- * causing the next report to tell new xact-counters.
+ * If there was no relation activity yet, just make one existing
+ * message buffer used without slots, causing the next report to tell
+ * new xact-counters.
*/
if (pgStatTabstatAlloc > 0)
{
pgstat_count_xact_rollback(void)
{
if (!pgstat_collect_querystring && !pgstat_collect_tuplelevel &&
- !pgstat_collect_blocklevel)
+ !pgstat_collect_blocklevel)
return;
pgStatXactRollback++;
/*
- * If there was no relation activity yet, just make
- * one existing message buffer used without slots,
- * causing the next report to tell new xact-counters.
+ * If there was no relation activity yet, just make one existing
+ * message buffer used without slots, causing the next report to tell
+ * new xact-counters.
*/
if (pgStatTabstatAlloc > 0)
{
PgStat_StatDBEntry *
pgstat_fetch_stat_dbentry(Oid dbid)
{
- PgStat_StatDBEntry *dbentry;
+ PgStat_StatDBEntry *dbentry;
/*
* If not done for this transaction, read the statistics collector
- * stats file into some hash tables. Be careful with the read_statsfile()
- * call below!
+ * stats file into some hash tables. Be careful with the
+ * read_statsfile() call below!
*/
if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId()))
{
- pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
+ pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
&pgStatBeTable, &pgStatNumBackends);
pgStatDBHashXact = GetCurrentTransactionId();
}
PgStat_StatTabEntry *
pgstat_fetch_stat_tabentry(Oid relid)
{
- PgStat_StatDBEntry *dbentry;
- PgStat_StatTabEntry *tabentry;
+ PgStat_StatDBEntry *dbentry;
+ PgStat_StatTabEntry *tabentry;
/*
* If not done for this transaction, read the statistics collector
- * stats file into some hash tables. Be careful with the read_statsfile()
- * call below!
+ * stats file into some hash tables. Be careful with the
+ * read_statsfile() call below!
*/
if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId()))
{
- pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
+ pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
&pgStatBeTable, &pgStatNumBackends);
pgStatDBHashXact = GetCurrentTransactionId();
}
{
if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId()))
{
- pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
+ pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
&pgStatBeTable, &pgStatNumBackends);
pgStatDBHashXact = GetCurrentTransactionId();
}
{
if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId()))
{
- pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
+ pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
&pgStatBeTable, &pgStatNumBackends);
pgStatDBHashXact = GetCurrentTransactionId();
}
static void
pgstat_setheader(PgStat_MsgHdr *hdr, int mtype)
{
- hdr->m_type = mtype;
- hdr->m_backendid = MyBackendId;
- hdr->m_procpid = MyProcPid;
- hdr->m_databaseid = MyDatabaseId;
- hdr->m_userid = GetSessionUserId();
+ hdr->m_type = mtype;
+ hdr->m_backendid = MyBackendId;
+ hdr->m_procpid = MyProcPid;
+ hdr->m_databaseid = MyDatabaseId;
+ hdr->m_userid = GetSessionUserId();
}
if (pgStatSock < 0)
return;
- ((PgStat_MsgHdr *)msg)->m_size = len;
+ ((PgStat_MsgHdr *) msg)->m_size = len;
send(pgStatSock, msg, len, 0);
/* We deliberately ignore any error from send() */
/* ------------------------------------------------------------
* Local functions implementing the statistics collector itself follow
- *------------------------------------------------------------
+ *------------------------------------------------------------
*/
pgstat_main(void)
{
PgStat_Msg msg;
- fd_set rfds;
- int readPipe;
- int pmPipe = pgStatPmPipe[0];
- int maxfd;
- int nready;
- int len = 0;
- struct timeval timeout;
- struct timeval next_statwrite;
- bool need_statwrite;
- HASHCTL hash_ctl;
-
- /*
- * Close the writing end of the postmaster pipe, so we'll see
- * it closing when the postmaster terminates and can terminate
- * as well.
+ fd_set rfds;
+ int readPipe;
+ int pmPipe = pgStatPmPipe[0];
+ int maxfd;
+ int nready;
+ int len = 0;
+ struct timeval timeout;
+ struct timeval next_statwrite;
+ bool need_statwrite;
+ HASHCTL hash_ctl;
+
+ /*
+ * Close the writing end of the postmaster pipe, so we'll see it
+ * closing when the postmaster terminates and can terminate as well.
*/
close(pgStatPmPipe[1]);
pgStatPmPipe[1] = -1;
pqsignal(SIGWINCH, SIG_DFL);
/*
- * Start a buffering process to read from the socket, so
- * we have a little more time to process incoming messages.
+ * Start a buffering process to read from the socket, so we have a
+ * little more time to process incoming messages.
*
* NOTE: the process structure is: postmaster is parent of buffer process
- * is parent of collector process. This way, the buffer can detect
+ * is parent of collector process. This way, the buffer can detect
* collector failure via SIGCHLD, whereas otherwise it wouldn't notice
- * collector failure until it tried to write on the pipe. That would mean
- * that after the postmaster started a new collector, we'd have two buffer
- * processes competing to read from the UDP socket --- not good.
+ * collector failure until it tried to write on the pipe. That would
+ * mean that after the postmaster started a new collector, we'd have
+ * two buffer processes competing to read from the UDP socket --- not
+ * good.
*/
if (pipe(pgStatPipe) < 0)
{
}
/*
- * In the child we can have default SIGCHLD handling (in case we
- * want to call system() here...)
+ * In the child we can have default SIGCHLD handling (in case we want
+ * to call system() here...)
*/
pqsignal(SIGCHLD, SIG_DFL);
need_statwrite = TRUE;
/*
- * Read in an existing statistics stats file or initialize the
- * stats to zero.
+ * Read in an existing statistics stats file or initialize the stats
+ * to zero.
*/
pgStatRunningInCollector = TRUE;
pgstat_read_statsfile(&pgStatDBHash, InvalidOid, NULL, NULL);
* Create the dead backend hashtable
*/
memset(&hash_ctl, 0, sizeof(hash_ctl));
- hash_ctl.keysize = sizeof(int);
+ hash_ctl.keysize = sizeof(int);
hash_ctl.entrysize = sizeof(PgStat_StatBeDead);
- hash_ctl.hash = tag_hash;
+ hash_ctl.hash = tag_hash;
pgStatBeDead = hash_create("Dead Backends", PGSTAT_BE_HASH_SIZE,
&hash_ctl, HASH_ELEM | HASH_FUNCTION);
if (pgStatBeDead == NULL)
{
- fprintf(stderr,
+ fprintf(stderr,
"PGSTAT: Creation of dead backend hash table failed\n");
exit(1);
}
/*
* Create the known backends table
*/
- pgStatBeTable = (PgStat_StatBeEntry *)malloc(
- sizeof(PgStat_StatBeEntry) * MaxBackends);
+ pgStatBeTable = (PgStat_StatBeEntry *) malloc(
+ sizeof(PgStat_StatBeEntry) * MaxBackends);
if (pgStatBeTable == NULL)
{
perror("PGSTAT: Allocation of backend table failed");
readPipe = pgStatPipe[0];
/*
- * Process incoming messages and handle all the reporting stuff
- * until there are no more messages.
+ * Process incoming messages and handle all the reporting stuff until
+ * there are no more messages.
*/
for (;;)
{
/*
- * If we need to write the status file again (there have
- * been changes in the statistics since we wrote it last)
- * calculate the timeout until we have to do so.
+ * If we need to write the status file again (there have been
+ * changes in the statistics since we wrote it last) calculate the
+ * timeout until we have to do so.
*/
if (need_statwrite)
{
gettimeofday(&timeout, NULL);
timeout.tv_usec = next_statwrite.tv_usec - timeout.tv_usec;
- timeout.tv_sec = next_statwrite.tv_sec - timeout.tv_sec;
+ timeout.tv_sec = next_statwrite.tv_sec - timeout.tv_sec;
if (timeout.tv_usec < 0)
{
- timeout.tv_sec -= 1;
+ timeout.tv_sec -= 1;
timeout.tv_usec += 1000000;
}
if (timeout.tv_sec < 0)
{
- timeout.tv_sec = 0;
+ timeout.tv_sec = 0;
timeout.tv_usec = 0;
}
}
/*
* Now wait for something to do.
*/
- nready = select(maxfd + 1, &rfds, NULL, NULL,
+ nready = select(maxfd + 1, &rfds, NULL, NULL,
(need_statwrite) ? &timeout : NULL);
if (nready < 0)
{
}
/*
- * If there are no descriptors ready, our timeout for writing
- * the stats file happened.
+ * If there are no descriptors ready, our timeout for writing the
+ * stats file happened.
*/
if (nready == 0)
{
if (FD_ISSET(readPipe, &rfds))
{
/*
- * We may need to issue multiple read calls in case the
- * buffer process didn't write the message in a single write,
- * which is possible since it dumps its buffer bytewise.
- * In any case, we'd need two reads since we don't know the
- * message length initially.
+ * We may need to issue multiple read calls in case the buffer
+ * process didn't write the message in a single write, which
+ * is possible since it dumps its buffer bytewise. In any
+ * case, we'd need two reads since we don't know the message
+ * length initially.
*/
- int nread = 0;
- int targetlen = sizeof(PgStat_MsgHdr); /* initial */
+ int nread = 0;
+ int targetlen = sizeof(PgStat_MsgHdr); /* initial */
while (nread < targetlen)
{
targetlen > (int) sizeof(msg))
{
/*
- * Bogus message length implies that we got out
- * of sync with the buffer process somehow.
- * Abort so that we can restart both processes.
+ * Bogus message length implies that we got out of
+ * sync with the buffer process somehow. Abort so
+ * that we can restart both processes.
*/
fprintf(stderr, "PGSTAT: bogus message length\n");
exit(1);
}
}
}
+
/*
* EOF on the pipe implies that the buffer process exited.
* Fall out of outer loop.
break;
/*
- * Distribute the message to the specific function handling it.
+ * Distribute the message to the specific function handling
+ * it.
*/
switch (msg.msg_hdr.m_type)
{
break;
case PGSTAT_MTYPE_BESTART:
- pgstat_recv_bestart((PgStat_MsgBestart *)&msg, nread);
+ pgstat_recv_bestart((PgStat_MsgBestart *) &msg, nread);
break;
case PGSTAT_MTYPE_BETERM:
- pgstat_recv_beterm((PgStat_MsgBeterm *)&msg, nread);
+ pgstat_recv_beterm((PgStat_MsgBeterm *) &msg, nread);
break;
case PGSTAT_MTYPE_TABSTAT:
- pgstat_recv_tabstat((PgStat_MsgTabstat *)&msg, nread);
+ pgstat_recv_tabstat((PgStat_MsgTabstat *) &msg, nread);
break;
case PGSTAT_MTYPE_TABPURGE:
- pgstat_recv_tabpurge((PgStat_MsgTabpurge *)&msg, nread);
+ pgstat_recv_tabpurge((PgStat_MsgTabpurge *) &msg, nread);
break;
case PGSTAT_MTYPE_ACTIVITY:
- pgstat_recv_activity((PgStat_MsgActivity *)&msg, nread);
+ pgstat_recv_activity((PgStat_MsgActivity *) &msg, nread);
break;
case PGSTAT_MTYPE_DROPDB:
- pgstat_recv_dropdb((PgStat_MsgDropdb *)&msg, nread);
+ pgstat_recv_dropdb((PgStat_MsgDropdb *) &msg, nread);
break;
case PGSTAT_MTYPE_RESETCOUNTER:
- pgstat_recv_resetcounter((PgStat_MsgResetcounter *)&msg,
+ pgstat_recv_resetcounter((PgStat_MsgResetcounter *) &msg,
nread);
break;
pgStatNumMessages++;
/*
- * If this is the first message after we wrote the stats
- * file the last time, setup the timeout that it'd be
- * written.
+ * If this is the first message after we wrote the stats file
+ * the last time, setup the timeout that it'd be written.
*/
if (!need_statwrite)
{
gettimeofday(&next_statwrite, NULL);
next_statwrite.tv_usec += ((PGSTAT_STAT_INTERVAL) * 1000);
- next_statwrite.tv_sec += (next_statwrite.tv_usec / 1000000);
+ next_statwrite.tv_sec += (next_statwrite.tv_usec / 1000000);
next_statwrite.tv_usec %= 1000000;
need_statwrite = TRUE;
}
/*
* Note that we do NOT check for postmaster exit inside the loop;
- * only EOF on the buffer pipe causes us to fall out. This ensures
- * we don't exit prematurely if there are still a few messages in
- * the buffer or pipe at postmaster shutdown.
+ * only EOF on the buffer pipe causes us to fall out. This
+ * ensures we don't exit prematurely if there are still a few
+ * messages in the buffer or pipe at postmaster shutdown.
*/
}
/*
- * Okay, we saw EOF on the buffer pipe, so there are no more messages to
- * process. If the buffer process quit because of postmaster shutdown,
- * we want to save the final stats to reuse at next startup. But if the
- * buffer process failed, it seems best not to (there may even now be a
- * new collector firing up, and we don't want it to read a partially-
- * rewritten stats file). We can tell whether the postmaster is still
- * alive by checking to see if the postmaster pipe is still open. If it
- * is read-ready (ie, EOF), the postmaster must have quit.
+ * Okay, we saw EOF on the buffer pipe, so there are no more messages
+ * to process. If the buffer process quit because of postmaster
+ * shutdown, we want to save the final stats to reuse at next startup.
+ * But if the buffer process failed, it seems best not to (there may
+ * even now be a new collector firing up, and we don't want it to read
+ * a partially- rewritten stats file). We can tell whether the
+ * postmaster is still alive by checking to see if the postmaster pipe
+ * is still open. If it is read-ready (ie, EOF), the postmaster must
+ * have quit.
*/
if (FD_ISSET(pmPipe, &rfds))
pgstat_write_statsfile();
static void
pgstat_recvbuffer(void)
{
- fd_set rfds;
- fd_set wfds;
- int writePipe = pgStatPipe[1];
- int pmPipe = pgStatPmPipe[0];
- int maxfd;
- int nready;
- int len;
- int xfr;
- int frm;
- PgStat_Msg input_buffer;
- char *msgbuffer;
- int msg_send = 0; /* next send index in buffer */
- int msg_recv = 0; /* next receive index */
- int msg_have = 0; /* number of bytes stored */
- struct sockaddr_in fromaddr;
- int fromlen;
- bool overflow = false;
+ fd_set rfds;
+ fd_set wfds;
+ int writePipe = pgStatPipe[1];
+ int pmPipe = pgStatPmPipe[0];
+ int maxfd;
+ int nready;
+ int len;
+ int xfr;
+ int frm;
+ PgStat_Msg input_buffer;
+ char *msgbuffer;
+ int msg_send = 0; /* next send index in buffer */
+ int msg_recv = 0; /* next receive index */
+ int msg_have = 0; /* number of bytes stored */
+ struct sockaddr_in fromaddr;
+ int fromlen;
+ bool overflow = false;
/*
* Identify myself via ps
set_ps_display("");
/*
- * We want to die if our child collector process does. There are two ways
- * we might notice that it has died: receive SIGCHLD, or get a write
- * failure on the pipe leading to the child. We can set SIGPIPE to kill
- * us here. Our SIGCHLD handler was already set up before we forked (must
- * do it that way, else it's a race condition).
+ * We want to die if our child collector process does. There are two
+ * ways we might notice that it has died: receive SIGCHLD, or get a
+ * write failure on the pipe leading to the child. We can set SIGPIPE
+ * to kill us here. Our SIGCHLD handler was already set up before we
+ * forked (must do it that way, else it's a race condition).
*/
pqsignal(SIGPIPE, SIG_DFL);
PG_SETMASK(&UnBlockSig);
maxfd = -1;
/*
- * As long as we have buffer space we add the socket
- * to the read descriptor set.
+ * As long as we have buffer space we add the socket to the read
+ * descriptor set.
*/
if (msg_have <= (int) (PGSTAT_RECVBUFFERSZ - sizeof(PgStat_Msg)))
{
}
/*
- * If we have messages to write out, we add the pipe
- * to the write descriptor set. Otherwise, we check if
- * the postmaster might have terminated.
+ * If we have messages to write out, we add the pipe to the write
+ * descriptor set. Otherwise, we check if the postmaster might
+ * have terminated.
*/
if (msg_have > 0)
{
if (FD_ISSET(pgStatSock, &rfds))
{
fromlen = sizeof(fromaddr);
- len = recvfrom(pgStatSock,
+ len = recvfrom(pgStatSock,
&input_buffer, sizeof(PgStat_Msg), 0,
(struct sockaddr *) &fromaddr, &fromlen);
if (len < 0)
* The source address of the packet must be our own socket.
* This ensures that only real hackers or our own backends
* tell us something. (This should be redundant with a
- * kernel-level check due to having used connect(), but
- * let's do it anyway.)
+ * kernel-level check due to having used connect(), but let's
+ * do it anyway.)
*/
if (fromaddr.sin_addr.s_addr != pgStatAddr.sin_addr.s_addr)
continue;
if (fromaddr.sin_port != pgStatAddr.sin_port)
continue;
-
+
/*
* O.K. - we accept this message. Copy it to the circular
* msgbuffer.
* pipe. We may or may not be able to write all that we have.
*
* NOTE: if what we have is less than PIPE_BUF bytes but more than
- * the space available in the pipe buffer, most kernels will refuse
- * to write any of it, and will return EAGAIN. This means we will
- * busy-loop until the situation changes (either because the collector
- * caught up, or because more data arrives so that we have more than
- * PIPE_BUF bytes buffered). This is not good, but is there any way
- * around it? We have no way to tell when the collector has
- * caught up...
+ * the space available in the pipe buffer, most kernels will
+ * refuse to write any of it, and will return EAGAIN. This means
+ * we will busy-loop until the situation changes (either because
+ * the collector caught up, or because more data arrives so that
+ * we have more than PIPE_BUF bytes buffered). This is not good,
+ * but is there any way around it? We have no way to tell when
+ * the collector has caught up...
*/
if (FD_ISSET(writePipe, &wfds))
{
continue;
/*
- * If the pipe from the postmaster is ready for reading,
- * the kernel must have closed it on exit() (the postmaster
- * never really writes to it). So we've done our job.
+ * If the pipe from the postmaster is ready for reading, the
+ * kernel must have closed it on exit() (the postmaster never
+ * really writes to it). So we've done our job.
*/
if (FD_ISSET(pmPipe, &rfds))
exit(0);
static int
pgstat_add_backend(PgStat_MsgHdr *msg)
{
- PgStat_StatDBEntry *dbentry;
- PgStat_StatBeEntry *beentry;
- PgStat_StatBeDead *deadbe;
- bool found;
+ PgStat_StatDBEntry *dbentry;
+ PgStat_StatBeEntry *beentry;
+ PgStat_StatBeDead *deadbe;
+ bool found;
/*
* Check that the backend ID is valid
if (beentry->databaseid != InvalidOid)
{
/*
- * If the slot contains the PID of this backend,
- * everything is fine and we got nothing to do.
+ * If the slot contains the PID of this backend, everything is
+ * fine and we got nothing to do.
*/
if (beentry->procpid == msg->m_procpid)
return 0;
}
/*
- * Lookup if this backend is known to be dead. This can be caused
- * due to messages arriving in the wrong order - i.e. Postmaster's
- * BETERM message might have arrived before we received all the
- * backends stats messages, or even a new backend with the same
- * backendid was faster in sending his BESTART.
+ * Lookup if this backend is known to be dead. This can be caused due
+ * to messages arriving in the wrong order - i.e. Postmaster's BETERM
+ * message might have arrived before we received all the backends
+ * stats messages, or even a new backend with the same backendid was
+ * faster in sending his BESTART.
*
* If the backend is known to be dead, we ignore this add.
*/
return 1;
/*
- * Backend isn't known to be dead. If it's slot is currently used,
- * we have to kick out the old backend.
+ * Backend isn't known to be dead. If it's slot is currently used, we
+ * have to kick out the old backend.
*/
if (beentry->databaseid != InvalidOid)
pgstat_sub_backend(beentry->procpid);
* Put this new backend into the slot.
*/
beentry->databaseid = msg->m_databaseid;
- beentry->procpid = msg->m_procpid;
- beentry->userid = msg->m_userid;
+ beentry->procpid = msg->m_procpid;
+ beentry->userid = msg->m_userid;
MemSet(beentry->activity, 0, PGSTAT_ACTIVITY_SIZE);
/*
* Lookup or create the database entry for this backends DB.
*/
dbentry = (PgStat_StatDBEntry *) hash_search(pgStatDBHash,
- (void *) &(msg->m_databaseid),
+ (void *) &(msg->m_databaseid),
HASH_ENTER, &found);
- if (dbentry == NULL)
+ if (dbentry == NULL)
{
fprintf(stderr, "PGSTAT: DB hash table out of memory - abort\n");
exit(1);
*/
if (!found)
{
- HASHCTL hash_ctl;
+ HASHCTL hash_ctl;
- dbentry->tables = NULL;
- dbentry->n_xact_commit = 0;
- dbentry->n_xact_rollback = 0;
- dbentry->n_blocks_fetched = 0;
- dbentry->n_blocks_hit = 0;
- dbentry->n_connects = 0;
- dbentry->destroy = 0;
+ dbentry->tables = NULL;
+ dbentry->n_xact_commit = 0;
+ dbentry->n_xact_rollback = 0;
+ dbentry->n_blocks_fetched = 0;
+ dbentry->n_blocks_hit = 0;
+ dbentry->n_connects = 0;
+ dbentry->destroy = 0;
memset(&hash_ctl, 0, sizeof(hash_ctl));
- hash_ctl.keysize = sizeof(Oid);
+ hash_ctl.keysize = sizeof(Oid);
hash_ctl.entrysize = sizeof(PgStat_StatTabEntry);
- hash_ctl.hash = tag_hash;
+ hash_ctl.hash = tag_hash;
dbentry->tables = hash_create("Per-database table",
PGSTAT_TAB_HASH_SIZE,
&hash_ctl,
if (dbentry->tables == NULL)
{
fprintf(stderr, "PGSTAT: failed to initialize hash table for "
- "new database entry\n");
+ "new database entry\n");
exit(1);
}
}
static void
pgstat_sub_backend(int procpid)
{
- int i;
- PgStat_StatBeDead *deadbe;
- bool found;
+ int i;
+ PgStat_StatBeDead *deadbe;
+ bool found;
/*
- * Search in the known-backends table for the slot containing
- * this PID.
+ * Search in the known-backends table for the slot containing this
+ * PID.
*/
for (i = 0; i < MaxBackends; i++)
{
{
/*
* That's him. Add an entry to the known to be dead backends.
- * Due to possible misorder in the arrival of UDP packets
- * it's possible that even if we know the backend is dead,
- * there could still be messages queued that arrive later.
- * Those messages must not cause our number of backends
- * statistics to get screwed up, so we remember for a couple
- * of seconds that this PID is dead and ignore them (only
- * the counting of backends, not the table access stats they
- * sent).
+ * Due to possible misorder in the arrival of UDP packets it's
+ * possible that even if we know the backend is dead, there
+ * could still be messages queued that arrive later. Those
+ * messages must not cause our number of backends statistics
+ * to get screwed up, so we remember for a couple of seconds
+ * that this PID is dead and ignore them (only the counting of
+ * backends, not the table access stats they sent).
*/
deadbe = (PgStat_StatBeDead *) hash_search(pgStatBeDead,
(void *) &procpid,
- HASH_ENTER, &found);
+ HASH_ENTER, &found);
if (deadbe == NULL)
{
fprintf(stderr, "PGSTAT: dead backend hash table out of memory "
- "- abort\n");
+ "- abort\n");
exit(1);
}
if (!found)
}
/*
- * No big problem if not found. This can happen if UDP messages
- * arrive out of order here.
+ * No big problem if not found. This can happen if UDP messages arrive
+ * out of order here.
*/
}
static void
pgstat_write_statsfile(void)
{
- HASH_SEQ_STATUS hstat;
- HASH_SEQ_STATUS tstat;
- PgStat_StatDBEntry *dbentry;
- PgStat_StatTabEntry *tabentry;
- PgStat_StatBeDead *deadbe;
- FILE *fpout;
- int i;
+ HASH_SEQ_STATUS hstat;
+ HASH_SEQ_STATUS tstat;
+ PgStat_StatDBEntry *dbentry;
+ PgStat_StatTabEntry *tabentry;
+ PgStat_StatBeDead *deadbe;
+ FILE *fpout;
+ int i;
/*
- * Open the statistics temp file to write out
- * the current values.
+ * Open the statistics temp file to write out the current values.
*/
fpout = fopen(pgStat_tmpfname, PG_BINARY_W);
if (fpout == NULL)
while ((dbentry = (PgStat_StatDBEntry *) hash_seq_search(&hstat)) != NULL)
{
/*
- * If this database is marked destroyed, count down and do
- * so if it reaches 0.
+ * If this database is marked destroyed, count down and do so if
+ * it reaches 0.
*/
if (dbentry->destroy > 0)
{
if (dbentry->tables != NULL)
hash_destroy(dbentry->tables);
- if (hash_search(pgStatDBHash,
+ if (hash_search(pgStatDBHash,
(void *) &(dbentry->databaseid),
HASH_REMOVE, NULL) == NULL)
{
fprintf(stderr, "PGSTAT: database hash table corrupted "
- "during cleanup - abort\n");
+ "during cleanup - abort\n");
exit(1);
}
}
+
/*
* Don't include statistics for it.
*/
while ((tabentry = (PgStat_StatTabEntry *) hash_seq_search(&tstat)) != NULL)
{
/*
- * If table entry marked for destruction, same as above
- * for the database entry.
+ * If table entry marked for destruction, same as above for
+ * the database entry.
*/
if (tabentry->destroy > 0)
{
HASH_REMOVE, NULL) == NULL)
{
fprintf(stderr, "PGSTAT: tables hash table for "
- "database %d corrupted during "
- "cleanup - abort\n",
- dbentry->databaseid);
+ "database %d corrupted during "
+ "cleanup - abort\n",
+ dbentry->databaseid);
exit(1);
}
}
}
/*
- * At least we think this is still a life table. Print
- * it's access stats.
+ * At least we think this is still a life table. Print it's
+ * access stats.
*/
fputc('T', fpout);
fwrite(tabentry, sizeof(PgStat_StatTabEntry), 1, fpout);
}
-
+
/*
* Mark the end of this DB
*/
}
/*
- * No more output to be done. Close the temp file and
- * replace the old pgstat.stat with it's content.
+ * No more output to be done. Close the temp file and replace the old
+ * pgstat.stat with it's content.
*/
fputc('E', fpout);
if (fclose(fpout) < 0)
if (rename(pgStat_tmpfname, pgStat_fname) < 0)
{
fprintf(stderr, "PGSTAT: Cannot rename temp stats file\n"
- "PGSTAT: ");
+ "PGSTAT: ");
perror(pgStat_fname);
fflush(stderr);
}
while ((deadbe = (PgStat_StatBeDead *) hash_seq_search(&hstat)) != NULL)
{
/*
- * Count down the destroy delay and remove entries where
- * it reaches 0.
+ * Count down the destroy delay and remove entries where it
+ * reaches 0.
*/
if (--(deadbe->destroy) <= 0)
{
HASH_REMOVE, NULL) == NULL)
{
fprintf(stderr, "PGSTAT: dead backend hash table corrupted "
- "during cleanup - abort\n");
+ "during cleanup - abort\n");
exit(1);
}
}
* ----------
*/
static void
-pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
- PgStat_StatBeEntry **betab, int *numbackends)
+pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
+ PgStat_StatBeEntry **betab, int *numbackends)
{
- PgStat_StatDBEntry *dbentry;
- PgStat_StatDBEntry dbbuf;
- PgStat_StatTabEntry *tabentry;
- PgStat_StatTabEntry tabbuf;
- HASHCTL hash_ctl;
- HTAB *tabhash = NULL;
- FILE *fpin;
- int maxbackends = 0;
- int havebackends = 0;
- bool found;
- MemoryContext use_mcxt;
- int mcxt_flags;
-
- /*
- * If running in the collector we use the DynaHashCxt
- * memory context. If running in a backend, we use the
- * TopTransactionContext instead, so the caller must only know the
- * last XactId when this call happened to know if his tables are
- * still valid or already gone!
+ PgStat_StatDBEntry *dbentry;
+ PgStat_StatDBEntry dbbuf;
+ PgStat_StatTabEntry *tabentry;
+ PgStat_StatTabEntry tabbuf;
+ HASHCTL hash_ctl;
+ HTAB *tabhash = NULL;
+ FILE *fpin;
+ int maxbackends = 0;
+ int havebackends = 0;
+ bool found;
+ MemoryContext use_mcxt;
+ int mcxt_flags;
+
+ /*
+ * If running in the collector we use the DynaHashCxt memory context.
+ * If running in a backend, we use the TopTransactionContext instead,
+ * so the caller must only know the last XactId when this call
+ * happened to know if his tables are still valid or already gone!
*/
if (pgStatRunningInCollector)
{
* Create the DB hashtable
*/
memset(&hash_ctl, 0, sizeof(hash_ctl));
- hash_ctl.keysize = sizeof(Oid);
+ hash_ctl.keysize = sizeof(Oid);
hash_ctl.entrysize = sizeof(PgStat_StatDBEntry);
- hash_ctl.hash = tag_hash;
- hash_ctl.hcxt = use_mcxt;
- *dbhash = hash_create("Databases hash", PGSTAT_DB_HASH_SIZE, &hash_ctl,
- HASH_ELEM | HASH_FUNCTION | mcxt_flags);
+ hash_ctl.hash = tag_hash;
+ hash_ctl.hcxt = use_mcxt;
+ *dbhash = hash_create("Databases hash", PGSTAT_DB_HASH_SIZE, &hash_ctl,
+ HASH_ELEM | HASH_FUNCTION | mcxt_flags);
if (pgStatDBHash == NULL)
{
if (pgStatRunningInCollector)
fprintf(stderr, "PGSTAT: Creation of DB hash table failed\n");
exit(1);
}
- elog(ERROR, "PGSTAT: Creation of DB hash table failed");
+ elog(ERROR, "PGSTAT: Creation of DB hash table failed");
}
/*
- * Initialize the number of known backends to zero, just in case we
- * do a silent error return below.
+ * Initialize the number of known backends to zero, just in case we do
+ * a silent error return below.
*/
if (numbackends != NULL)
*numbackends = 0;
/*
* Try to open the status file. If it doesn't exist, the backends
- * simply return zero for anything and the collector simply
- * starts from scratch with empty counters.
+ * simply return zero for anything and the collector simply starts
+ * from scratch with empty counters.
*/
if ((fpin = fopen(pgStat_fname, PG_BINARY_R)) == NULL)
return;
/*
- * We found an existing collector stats file. Read it and put
- * all the hashtable entries into place.
+ * We found an existing collector stats file. Read it and put all the
+ * hashtable entries into place.
*/
for (;;)
{
switch (fgetc(fpin))
{
- /*
- * 'D' A PgStat_StatDBEntry struct describing a database
- * follows. Subsequently, zero to many 'T' entries will
- * follow until a 'd' is encountered.
- */
+ /*
+ * 'D' A PgStat_StatDBEntry struct describing a database
+ * follows. Subsequently, zero to many 'T' entries will
+ * follow until a 'd' is encountered.
+ */
case 'D':
if (fread(&dbbuf, 1, sizeof(dbbuf), fpin) != sizeof(dbbuf))
{
if (pgStatRunningInCollector)
{
- fprintf(stderr,
+ fprintf(stderr,
"PGSTAT: corrupted pgstat.stat file\n");
fclose(fpin);
return;
}
else
{
- elog(NOTICE,
- "PGSTAT: corrupted pgstat.stat file");
+ elog(NOTICE,
+ "PGSTAT: corrupted pgstat.stat file");
fclose(fpin);
return;
}
* Add to the DB hash
*/
dbentry = (PgStat_StatDBEntry *) hash_search(*dbhash,
- (void *) &dbbuf.databaseid,
- HASH_ENTER, &found);
+ (void *) &dbbuf.databaseid,
+ HASH_ENTER, &found);
if (dbentry == NULL)
{
if (pgStatRunningInCollector)
{
if (pgStatRunningInCollector)
{
- fprintf(stderr,
+ fprintf(stderr,
"PGSTAT: corrupted pgstat.stat file\n");
fclose(fpin);
return;
}
else
{
- elog(NOTICE,
- "PGSTAT: corrupted pgstat.stat file");
+ elog(NOTICE,
+ "PGSTAT: corrupted pgstat.stat file");
fclose(fpin);
return;
}
}
memcpy(dbentry, &dbbuf, sizeof(PgStat_StatDBEntry));
- dbentry->tables = NULL;
- dbentry->destroy = 0;
- dbentry->n_backends = 0;
+ dbentry->tables = NULL;
+ dbentry->destroy = 0;
+ dbentry->n_backends = 0;
/*
* Don't collect tables if not the requested DB
memset(&hash_ctl, 0, sizeof(hash_ctl));
- hash_ctl.keysize = sizeof(Oid);
+ hash_ctl.keysize = sizeof(Oid);
hash_ctl.entrysize = sizeof(PgStat_StatTabEntry);
- hash_ctl.hash = tag_hash;
- hash_ctl.hcxt = use_mcxt;
+ hash_ctl.hash = tag_hash;
+ hash_ctl.hcxt = use_mcxt;
dbentry->tables = hash_create("Per-database table",
PGSTAT_TAB_HASH_SIZE,
&hash_ctl,
- HASH_ELEM | HASH_FUNCTION | mcxt_flags);
+ HASH_ELEM | HASH_FUNCTION | mcxt_flags);
if (dbentry->tables == NULL)
{
if (pgStatRunningInCollector)
{
fprintf(stderr, "PGSTAT: failed to initialize "
- "hash table for new database entry\n");
+ "hash table for new database entry\n");
exit(1);
}
else
{
fclose(fpin);
elog(ERROR, "PGSTAT: failed to initialize "
- "hash table for new database entry\n");
+ "hash table for new database entry\n");
}
}
tabhash = dbentry->tables;
break;
- /*
- * 'd' End of this database.
- */
+ /*
+ * 'd' End of this database.
+ */
case 'd':
tabhash = NULL;
break;
- /*
- * 'T' A PgStat_StatTabEntry follows.
- */
+ /*
+ * 'T' A PgStat_StatTabEntry follows.
+ */
case 'T':
if (fread(&tabbuf, 1, sizeof(tabbuf), fpin) != sizeof(tabbuf))
{
if (pgStatRunningInCollector)
{
- fprintf(stderr,
+ fprintf(stderr,
"PGSTAT: corrupted pgstat.stat file\n");
fclose(fpin);
return;
}
else
{
- elog(NOTICE,
- "PGSTAT: corrupted pgstat.stat file");
+ elog(NOTICE,
+ "PGSTAT: corrupted pgstat.stat file");
fclose(fpin);
return;
}
break;
tabentry = (PgStat_StatTabEntry *) hash_search(tabhash,
- (void *) &tabbuf.tableid,
- HASH_ENTER, &found);
+ (void *) &tabbuf.tableid,
+ HASH_ENTER, &found);
if (tabentry == NULL)
{
if (pgStatRunningInCollector)
{
if (pgStatRunningInCollector)
{
- fprintf(stderr,
+ fprintf(stderr,
"PGSTAT: corrupted pgstat.stat file\n");
fclose(fpin);
return;
}
else
{
- elog(NOTICE,
- "PGSTAT: corrupted pgstat.stat file");
+ elog(NOTICE,
+ "PGSTAT: corrupted pgstat.stat file");
fclose(fpin);
return;
}
memcpy(tabentry, &tabbuf, sizeof(tabbuf));
break;
- /*
- * 'M' The maximum number of backends to expect follows.
- */
+ /*
+ * 'M' The maximum number of backends to expect follows.
+ */
case 'M':
if (betab == NULL || numbackends == NULL)
{
return;
}
if (fread(&maxbackends, 1, sizeof(maxbackends), fpin) !=
- sizeof(maxbackends))
+ sizeof(maxbackends))
{
if (pgStatRunningInCollector)
{
- fprintf(stderr,
+ fprintf(stderr,
"PGSTAT: corrupted pgstat.stat file\n");
fclose(fpin);
return;
}
else
{
- elog(NOTICE,
- "PGSTAT: corrupted pgstat.stat file");
+ elog(NOTICE,
+ "PGSTAT: corrupted pgstat.stat file");
fclose(fpin);
return;
}
}
/*
- * Allocate space (in TopTransactionContext too) for
- * the backend table.
+ * Allocate space (in TopTransactionContext too) for the
+ * backend table.
*/
if (use_mcxt == NULL)
- *betab = (PgStat_StatBeEntry *)malloc(
- sizeof(PgStat_StatBeEntry) * maxbackends);
+ *betab = (PgStat_StatBeEntry *) malloc(
+ sizeof(PgStat_StatBeEntry) * maxbackends);
else
- *betab = (PgStat_StatBeEntry *)MemoryContextAlloc(
- use_mcxt,
- sizeof(PgStat_StatBeEntry) * maxbackends);
+ *betab = (PgStat_StatBeEntry *) MemoryContextAlloc(
+ use_mcxt,
+ sizeof(PgStat_StatBeEntry) * maxbackends);
break;
- /*
- * 'B' A PgStat_StatBeEntry follows.
- */
+ /*
+ * 'B' A PgStat_StatBeEntry follows.
+ */
case 'B':
if (betab == NULL || numbackends == NULL)
{
fclose(fpin);
return;
}
+
/*
* Read it directly into the table.
*/
- if (fread(&(*betab)[havebackends], 1,
- sizeof(PgStat_StatBeEntry), fpin) !=
- sizeof(PgStat_StatBeEntry))
+ if (fread(&(*betab)[havebackends], 1,
+ sizeof(PgStat_StatBeEntry), fpin) !=
+ sizeof(PgStat_StatBeEntry))
{
if (pgStatRunningInCollector)
{
- fprintf(stderr,
+ fprintf(stderr,
"PGSTAT: corrupted pgstat.stat file\n");
fclose(fpin);
return;
}
else
{
- elog(NOTICE,
- "PGSTAT: corrupted pgstat.stat file");
+ elog(NOTICE,
+ "PGSTAT: corrupted pgstat.stat file");
fclose(fpin);
return;
}
/*
* Count backends per database here.
*/
- dbentry = (PgStat_StatDBEntry *)hash_search(*dbhash,
- (void *) &((*betab)[havebackends].databaseid),
- HASH_FIND, NULL);
+ dbentry = (PgStat_StatDBEntry *) hash_search(*dbhash,
+ (void *) &((*betab)[havebackends].databaseid),
+ HASH_FIND, NULL);
if (dbentry)
dbentry->n_backends++;
}
break;
- /*
- * 'E' The EOF marker of a complete stats file.
- */
+ /*
+ * 'E' The EOF marker of a complete stats file.
+ */
case 'E':
fclose(fpin);
return;
pgstat_recv_activity(PgStat_MsgActivity *msg, int len)
{
/*
- * Here we check explicitly for 0 return, since we don't
- * want to mangle the activity of an active backend by
- * a delayed packed from a dead one.
+ * Here we check explicitly for 0 return, since we don't want to
+ * mangle the activity of an active backend by a delayed packed from a
+ * dead one.
*/
if (pgstat_add_backend(&msg->m_hdr) != 0)
return;
-
+
strncpy(pgStatBeTable[msg->m_hdr.m_backendid - 1].activity,
msg->m_what, PGSTAT_ACTIVITY_SIZE);
}
static void
pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len)
{
- PgStat_TableEntry *tabmsg = &(msg->m_entry[0]);
- PgStat_StatDBEntry *dbentry;
- PgStat_StatTabEntry *tabentry;
- int i;
- bool found;
+ PgStat_TableEntry *tabmsg = &(msg->m_entry[0]);
+ PgStat_StatDBEntry *dbentry;
+ PgStat_StatTabEntry *tabentry;
+ int i;
+ bool found;
/*
* Make sure the backend is counted for.
* Lookup the database in the hashtable.
*/
dbentry = (PgStat_StatDBEntry *) hash_search(pgStatDBHash,
- (void *) &(msg->m_hdr.m_databaseid),
- HASH_FIND, NULL);
+ (void *) &(msg->m_hdr.m_databaseid),
+ HASH_FIND, NULL);
if (!dbentry)
return;
/*
- * If the database is marked for destroy, this is a delayed
- * UDP packet and not worth being counted.
+ * If the database is marked for destroy, this is a delayed UDP packet
+ * and not worth being counted.
*/
if (dbentry->destroy > 0)
return;
- dbentry->n_xact_commit += (PgStat_Counter)(msg->m_xact_commit);
- dbentry->n_xact_rollback += (PgStat_Counter)(msg->m_xact_rollback);
+ dbentry->n_xact_commit += (PgStat_Counter) (msg->m_xact_commit);
+ dbentry->n_xact_rollback += (PgStat_Counter) (msg->m_xact_rollback);
/*
* Process all table entries in the message.
for (i = 0; i < msg->m_nentries; i++)
{
tabentry = (PgStat_StatTabEntry *) hash_search(dbentry->tables,
- (void *) &(tabmsg[i].t_id),
- HASH_ENTER, &found);
+ (void *) &(tabmsg[i].t_id),
+ HASH_ENTER, &found);
if (tabentry == NULL)
{
fprintf(stderr, "PGSTAT: tables hash table out of memory for "
- "database %d - abort\n", dbentry->databaseid);
+ "database %d - abort\n", dbentry->databaseid);
exit(1);
}
if (!found)
{
/*
- * If it's a new table entry, initialize counters
- * to the values we just got.
+ * If it's a new table entry, initialize counters to the
+ * values we just got.
*/
- tabentry->numscans = tabmsg[i].t_numscans;
- tabentry->tuples_returned = tabmsg[i].t_tuples_returned;
- tabentry->tuples_fetched = tabmsg[i].t_tuples_fetched;
- tabentry->tuples_inserted = tabmsg[i].t_tuples_inserted;
- tabentry->tuples_updated = tabmsg[i].t_tuples_updated;
- tabentry->tuples_deleted = tabmsg[i].t_tuples_deleted;
- tabentry->blocks_fetched = tabmsg[i].t_blocks_fetched;
- tabentry->blocks_hit = tabmsg[i].t_blocks_hit;
+ tabentry->numscans = tabmsg[i].t_numscans;
+ tabentry->tuples_returned = tabmsg[i].t_tuples_returned;
+ tabentry->tuples_fetched = tabmsg[i].t_tuples_fetched;
+ tabentry->tuples_inserted = tabmsg[i].t_tuples_inserted;
+ tabentry->tuples_updated = tabmsg[i].t_tuples_updated;
+ tabentry->tuples_deleted = tabmsg[i].t_tuples_deleted;
+ tabentry->blocks_fetched = tabmsg[i].t_blocks_fetched;
+ tabentry->blocks_hit = tabmsg[i].t_blocks_hit;
tabentry->destroy = 0;
}
/*
* Otherwise add the values to the existing entry.
*/
- tabentry->numscans += tabmsg[i].t_numscans;
- tabentry->tuples_returned += tabmsg[i].t_tuples_returned;
- tabentry->tuples_fetched += tabmsg[i].t_tuples_fetched;
- tabentry->tuples_inserted += tabmsg[i].t_tuples_inserted;
- tabentry->tuples_updated += tabmsg[i].t_tuples_updated;
- tabentry->tuples_deleted += tabmsg[i].t_tuples_deleted;
- tabentry->blocks_fetched += tabmsg[i].t_blocks_fetched;
- tabentry->blocks_hit += tabmsg[i].t_blocks_hit;
+ tabentry->numscans += tabmsg[i].t_numscans;
+ tabentry->tuples_returned += tabmsg[i].t_tuples_returned;
+ tabentry->tuples_fetched += tabmsg[i].t_tuples_fetched;
+ tabentry->tuples_inserted += tabmsg[i].t_tuples_inserted;
+ tabentry->tuples_updated += tabmsg[i].t_tuples_updated;
+ tabentry->tuples_deleted += tabmsg[i].t_tuples_deleted;
+ tabentry->blocks_fetched += tabmsg[i].t_blocks_fetched;
+ tabentry->blocks_hit += tabmsg[i].t_blocks_hit;
}
/*
* And add the block IO to the database entry.
*/
- dbentry->n_blocks_fetched += tabmsg[i].t_blocks_fetched;
- dbentry->n_blocks_hit += tabmsg[i].t_blocks_hit;
+ dbentry->n_blocks_fetched += tabmsg[i].t_blocks_fetched;
+ dbentry->n_blocks_hit += tabmsg[i].t_blocks_hit;
}
}
static void
pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len)
{
- PgStat_StatDBEntry *dbentry;
- PgStat_StatTabEntry *tabentry;
- int i;
+ PgStat_StatDBEntry *dbentry;
+ PgStat_StatTabEntry *tabentry;
+ int i;
/*
* Make sure the backend is counted for.
* Lookup the database in the hashtable.
*/
dbentry = (PgStat_StatDBEntry *) hash_search(pgStatDBHash,
- (void *) &(msg->m_hdr.m_databaseid),
- HASH_FIND, NULL);
+ (void *) &(msg->m_hdr.m_databaseid),
+ HASH_FIND, NULL);
if (!dbentry)
return;
/*
- * If the database is marked for destroy, this is a delayed
- * UDP packet and the tables will go away at DB destruction.
+ * If the database is marked for destroy, this is a delayed UDP packet
+ * and the tables will go away at DB destruction.
*/
if (dbentry->destroy > 0)
return;
for (i = 0; i < msg->m_nentries; i++)
{
tabentry = (PgStat_StatTabEntry *) hash_search(dbentry->tables,
- (void *) &(msg->m_tableid[i]),
- HASH_FIND, NULL);
+ (void *) &(msg->m_tableid[i]),
+ HASH_FIND, NULL);
if (tabentry)
tabentry->destroy = PGSTAT_DESTROY_COUNT;
}
static void
pgstat_recv_dropdb(PgStat_MsgDropdb *msg, int len)
{
- PgStat_StatDBEntry *dbentry;
+ PgStat_StatDBEntry *dbentry;
/*
* Make sure the backend is counted for.
* Lookup the database in the hashtable.
*/
dbentry = (PgStat_StatDBEntry *) hash_search(pgStatDBHash,
- (void *) &(msg->m_databaseid),
- HASH_FIND, NULL);
+ (void *) &(msg->m_databaseid),
+ HASH_FIND, NULL);
if (!dbentry)
return;
static void
pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len)
{
- HASHCTL hash_ctl;
- PgStat_StatDBEntry *dbentry;
+ HASHCTL hash_ctl;
+ PgStat_StatDBEntry *dbentry;
/*
* Make sure the backend is counted for.
* Lookup the database in the hashtable.
*/
dbentry = (PgStat_StatDBEntry *) hash_search(pgStatDBHash,
- (void *) &(msg->m_hdr.m_databaseid),
- HASH_FIND, NULL);
+ (void *) &(msg->m_hdr.m_databaseid),
+ HASH_FIND, NULL);
if (!dbentry)
return;
if (dbentry->tables != NULL)
hash_destroy(dbentry->tables);
- dbentry->tables = NULL;
- dbentry->n_xact_commit = 0;
- dbentry->n_xact_rollback = 0;
- dbentry->n_blocks_fetched = 0;
- dbentry->n_blocks_hit = 0;
- dbentry->n_connects = 0;
- dbentry->destroy = 0;
+ dbentry->tables = NULL;
+ dbentry->n_xact_commit = 0;
+ dbentry->n_xact_rollback = 0;
+ dbentry->n_blocks_fetched = 0;
+ dbentry->n_blocks_hit = 0;
+ dbentry->n_connects = 0;
+ dbentry->destroy = 0;
memset(&hash_ctl, 0, sizeof(hash_ctl));
- hash_ctl.keysize = sizeof(Oid);
+ hash_ctl.keysize = sizeof(Oid);
hash_ctl.entrysize = sizeof(PgStat_StatTabEntry);
- hash_ctl.hash = tag_hash;
+ hash_ctl.hash = tag_hash;
dbentry->tables = hash_create("Per-database table",
PGSTAT_TAB_HASH_SIZE,
&hash_ctl,
if (dbentry->tables == NULL)
{
fprintf(stderr, "PGSTAT: failed to reinitialize hash table for "
- "database entry\n");
+ "database entry\n");
exit(1);
}
}
-
-
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.251 2001/10/22 19:41:38 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.252 2001/10/25 05:49:40 momjian Exp $
*
* NOTES
*
sigset_t UnBlockSig,
BlockSig,
AuthBlockSig;
+
#else
int UnBlockSig,
BlockSig,
extern char *optarg;
extern int optind,
opterr;
+
#ifdef HAVE_INT_OPTRESET
extern int optreset;
#endif
static int ServerLoop(void);
static int BackendStartup(Port *port);
static int ProcessStartupPacket(Port *port, bool SSLdone);
-static void processCancelRequest(Port *port, void *pkt);
+static void processCancelRequest(Port *port, void *pkt);
static int initMasks(fd_set *rmask, fd_set *wmask);
-enum CAC_state { CAC_OK, CAC_STARTUP, CAC_SHUTDOWN, CAC_RECOVERY, CAC_TOOMANY };
+enum CAC_state
+{
+ CAC_OK, CAC_STARTUP, CAC_SHUTDOWN, CAC_RECOVERY, CAC_TOOMANY
+};
static enum CAC_state canAcceptConnections(void);
static long PostmasterRandom(void);
static void RandomSalt(char *cryptSalt, char *md5Salt);
static int CountChildren(void);
static bool CreateOptsFile(int argc, char *argv[]);
static pid_t SSDataBase(int xlop);
-static void postmaster_error(const char *fmt, ...)
+static void
+postmaster_error(const char *fmt,...)
/* This lets gcc check the format string for consistency. */
__attribute__((format(printf, 1, 2)));
if (checkdir == NULL)
{
fprintf(stderr, gettext(
- "%s does not know where to find the database system data.\n"
- "You must specify the directory that contains the database system\n"
- "either by specifying the -D invocation option or by setting the\n"
- "PGDATA environment variable.\n\n"),
+ "%s does not know where to find the database system data.\n"
+ "You must specify the directory that contains the database system\n"
+ "either by specifying the -D invocation option or by setting the\n"
+ "PGDATA environment variable.\n\n"),
progname);
ExitPostmaster(2);
}
-
+
/*
* Check if the directory has group or world access. If so, reject.
*/
if (fp == NULL)
{
fprintf(stderr, gettext(
- "%s does not find the database system.\n"
- "Expected to find it in the PGDATA directory \"%s\",\n"
- "but unable to open file \"%s\": %s\n\n"),
+ "%s does not find the database system.\n"
+ "Expected to find it in the PGDATA directory \"%s\",\n"
+ "but unable to open file \"%s\": %s\n\n"),
progname, checkdir, path, strerror(errno));
ExitPostmaster(2);
}
/* already done above */
break;
case 'd':
+
/*
* Turn on debugging for the postmaster and the backend
* servers descended from it.
}
/*
- * Now that we are done processing the postmaster arguments,
- * reset getopt(3) library so that it will work correctly in
- * subprocesses.
+ * Now that we are done processing the postmaster arguments, reset
+ * getopt(3) library so that it will work correctly in subprocesses.
*/
optind = 1;
#ifdef HAVE_INT_OPTRESET
ExitPostmaster(1);
/*
- * Remove old temporary files. At this point there can be no other
- * Postgres processes running in this directory, so this should be safe.
+ * Remove old temporary files. At this point there can be no other
+ * Postgres processes running in this directory, so this should be
+ * safe.
*/
RemovePgTempFiles();
/*
* Reset whereToSendOutput from Debug (its starting state) to None.
* This prevents elog from sending messages to stderr unless the
- * syslog/stderr switch permits. We don't do this until the postmaster
- * is fully launched, since startup failures may as well be reported
- * to stderr.
+ * syslog/stderr switch permits. We don't do this until the
+ * postmaster is fully launched, since startup failures may as well be
+ * reported to stderr.
*/
whereToSendOutput = None;
}
/*
- * New connection pending on our well-known port's socket?
- * If so, fork a child process to deal with it.
+ * New connection pending on our well-known port's socket? If so,
+ * fork a child process to deal with it.
*/
#ifdef HAVE_UNIX_SOCKETS
if (port)
{
BackendStartup(port);
+
/*
- * We no longer need the open socket or port structure
- * in this process
+ * We no longer need the open socket or port structure in
+ * this process
*/
StreamClose(port->sock);
ConnFree(port);
if (port)
{
BackendStartup(port);
+
/*
- * We no longer need the open socket or port structure
- * in this process
+ * We no longer need the open socket or port structure in
+ * this process
*/
StreamClose(port->sock);
ConnFree(port);
{
elog(DEBUG, "failed to send SSL negotiation response: %s",
strerror(errno));
- return STATUS_ERROR; /* close the connection */
+ return STATUS_ERROR; /* close the connection */
}
#ifdef USE_SSL
/*
* Truncate given database and user names to length of a Postgres
- * name. This avoids lookup failures when overlength names are
- * given.
+ * name. This avoids lookup failures when overlength names are given.
*/
if ((int) sizeof(port->database) >= NAMEDATALEN)
port->database[NAMEDATALEN - 1] = '\0';
return CAC_STARTUP;
if (FatalError)
return CAC_RECOVERY;
+
/*
* Don't start too many children.
*
- * We allow more connections than we can have backends here because
- * some might still be authenticating; they might fail auth, or some
- * existing backend might exit before the auth cycle is completed.
- * The exact MaxBackends limit is enforced when a new backend tries
- * to join the shared-inval backend array.
+ * We allow more connections than we can have backends here because some
+ * might still be authenticating; they might fail auth, or some
+ * existing backend might exit before the auth cycle is completed. The
+ * exact MaxBackends limit is enforced when a new backend tries to
+ * join the shared-inval backend array.
*/
if (CountChildren() >= 2 * MaxBackends)
return CAC_TOOMANY;
static void
reset_shared(unsigned short port)
{
-
/*
* Reset assignment of shared mem and semaphore IPC keys. Doing this
* means that in normal cases we'll assign the same keys on each
reaper(SIGNAL_ARGS)
{
int save_errno = errno;
+
#ifdef HAVE_WAITPID
int status; /* backend exit status */
+
#else
union wait status; /* backend exit status */
#endif
{
exitstatus = status.w_status;
#endif
+
/*
- * Check if this child was the statistics collector. If
- * so, start a new one.
+ * Check if this child was the statistics collector. If so, start
+ * a new one.
*/
if (pgstat_ispgstat(pid))
{
MyCancelKey = PostmasterRandom();
/*
- * Make room for backend data structure. Better before the fork()
- * so we can handle failure cleanly.
+ * Make room for backend data structure. Better before the fork() so
+ * we can handle failure cleanly.
*/
bn = (Backend *) malloc(sizeof(Backend));
if (!bn)
if (pid == 0) /* child */
{
- int status;
+ int status;
free(bn);
#ifdef __BEOS__
/*
* Initialize libpq and enable reporting of elog errors to the client.
- * Must do this now because authentication uses libpq to send messages.
+ * Must do this now because authentication uses libpq to send
+ * messages.
*/
pq_init(); /* initialize libpq to talk to client */
- whereToSendOutput = Remote; /* now safe to elog to client */
+ whereToSendOutput = Remote; /* now safe to elog to client */
/*
* We arrange for a simple exit(0) if we receive SIGTERM or SIGQUIT
*
* PreAuthDelay is a debugging aid for investigating problems in the
* authentication cycle: it can be set in postgresql.conf to allow
- * time to attach to the newly-forked backend with a debugger.
- * (See also the -W backend switch, which we allow clients to pass
- * through PGOPTIONS, but it is not honored until after authentication.)
+ * time to attach to the newly-forked backend with a debugger. (See
+ * also the -W backend switch, which we allow clients to pass through
+ * PGOPTIONS, but it is not honored until after authentication.)
*/
pqsignal(SIGTERM, authdie);
pqsignal(SIGQUIT, authdie);
if (PreAuthDelay > 0)
sleep(PreAuthDelay);
- if (! enable_sigalrm_interrupt(AuthenticationTimeout * 1000))
+ if (!enable_sigalrm_interrupt(AuthenticationTimeout * 1000))
elog(FATAL, "DoBackend: Unable to set timer for auth timeout");
/*
/*
* Now that we have the user and database name, we can set the process
- * title for ps. It's good to do this as early as possible in startup.
+ * title for ps. It's good to do this as early as possible in
+ * startup.
*
* But first, we need the remote host name.
*/
ClientAuthentication(port); /* might not return, if failure */
/*
- * Done with authentication. Disable timeout, and prevent SIGTERM/SIGQUIT
- * again until backend startup is complete.
+ * Done with authentication. Disable timeout, and prevent
+ * SIGTERM/SIGQUIT again until backend startup is complete.
*/
- if (! disable_sigalrm_interrupt())
+ if (!disable_sigalrm_interrupt())
elog(FATAL, "DoBackend: Unable to disable timer for auth timeout");
PG_SETMASK(&BlockSig);
cryptSalt[0] = CharRemap(rand % 62);
cryptSalt[1] = CharRemap(rand / 62);
+
/*
- * It's okay to reuse the first random value for one of the MD5 salt bytes,
- * since only one of the two salts will be sent to the client. After that
- * we need to compute more random bits.
+ * It's okay to reuse the first random value for one of the MD5 salt
+ * bytes, since only one of the two salts will be sent to the client.
+ * After that we need to compute more random bits.
*
* We use % 255, sacrificing one possible byte value, so as to ensure
- * that all bits of the random() value participate in the result. While
- * at it, add one to avoid generating any null bytes.
+ * that all bits of the random() value participate in the result.
+ * While at it, add one to avoid generating any null bytes.
*/
md5Salt[0] = (rand % 255) + 1;
rand = PostmasterRandom();
ExitPostmaster(1);
}
}
-
#endif
/*
beos_backend_startup();
#endif
- IsUnderPostmaster = true; /* we are a postmaster subprocess now */
+ IsUnderPostmaster = true; /* we are a postmaster subprocess
+ * now */
/* Lose the postmaster's on-exit routines and port connections */
on_exit_reset();
beos_backend_startup_failed();
#endif
- switch(xlop)
+ switch (xlop)
{
case BS_XLOG_STARTUP:
elog(DEBUG, "could not launch startup process (fork failure): %s",
static void
-postmaster_error(const char *fmt, ...)
+postmaster_error(const char *fmt,...)
{
- va_list ap;
+ va_list ap;
fprintf(stderr, "%s: ", progname);
va_start(ap, fmt);
states empty; /* empty set of states */
};
-static int matcher(struct re_guts * g, pg_wchar * string, size_t nmatch,
+static int matcher(struct re_guts * g, pg_wchar *string, size_t nmatch,
regmatch_t *pmatch, int eflags);
-static pg_wchar *dissect(struct match * m, pg_wchar * start, pg_wchar * stop,
+static pg_wchar *dissect(struct match * m, pg_wchar *start, pg_wchar *stop,
sopno startst, sopno stopst);
-static pg_wchar *backref(struct match * m, pg_wchar * start, pg_wchar * stop,
+static pg_wchar *backref(struct match * m, pg_wchar *start, pg_wchar *stop,
sopno startst, sopno stopst, sopno lev);
-static pg_wchar *fast(struct match * m, pg_wchar * start, pg_wchar * stop,
+static pg_wchar *fast(struct match * m, pg_wchar *start, pg_wchar *stop,
sopno startst, sopno stopst);
-static pg_wchar *slow(struct match * m, pg_wchar * start, pg_wchar * stop,
+static pg_wchar *slow(struct match * m, pg_wchar *start, pg_wchar *stop,
sopno startst, sopno stopst);
static states step(struct re_guts * g, sopno start,
sopno stop, states bef, int ch, states aft);
#endif
#ifdef REDEBUG
-static void print(struct match * m, pg_wchar * caption, states st, int ch,
+static void print(struct match * m, pg_wchar *caption, states st, int ch,
FILE *d);
-static void at(struct match * m, pg_wchar * title, pg_wchar * start,
- pg_wchar * stop, sopno startst, sopno stopst);
+static void at(struct match * m, pg_wchar *title, pg_wchar *start,
+ pg_wchar *stop, sopno startst, sopno stopst);
static pg_wchar *pchar(int ch);
static int pg_isprint(int c);
-
#endif
#ifdef REDEBUG
* matcher - the actual matching engine
*/
static int /* 0 success, REG_NOMATCH failure */
-matcher(struct re_guts * g, pg_wchar * string, size_t nmatch,
+matcher(struct re_guts * g, pg_wchar *string, size_t nmatch,
regmatch_t *pmatch, int eflags)
{
pg_wchar *endp;
* dissect - figure out what matched what, no back references
*/
static pg_wchar * /* == stop (success) always */
-dissect(struct match * m, pg_wchar * start, pg_wchar * stop,
+dissect(struct match * m, pg_wchar *start, pg_wchar *stop,
sopno startst, sopno stopst)
{
int i;
* lev is PLUS nesting level
*/
static pg_wchar * /* == stop (success) or NULL (failure) */
-backref(struct match * m, pg_wchar * start, pg_wchar * stop,
+backref(struct match * m, pg_wchar *start, pg_wchar *stop,
sopno startst, sopno stopst, sopno lev)
{
int i;
return dp;
/* that one missed, try next one */
if (OP(m->g->strip[esub]) == O_CH)
- return NULL;/* there is none */
+ return NULL; /* there is none */
esub++;
assert(OP(m->g->strip[esub]) == OOR2);
ssub = esub + 1;
* fast - step through the string at top speed
*/
static pg_wchar * /* where tentative match ended, or NULL */
-fast(struct match * m, pg_wchar * start, pg_wchar * stop,
+fast(struct match * m, pg_wchar *start, pg_wchar *stop,
sopno startst, sopno stopst)
{
states st = m->st;
* slow - step through the string more deliberately
*/
static pg_wchar * /* where it ended */
-slow(struct match * m, pg_wchar * start, pg_wchar * stop,
+slow(struct match * m, pg_wchar *start, pg_wchar *stop,
sopno startst, sopno stopst)
{
states st = m->st;
* print - print a set of states
*/
static void
-print(struct match * m, pg_wchar * caption, states st,
+print(struct match * m, pg_wchar *caption, states st,
int ch, FILE *d)
{
struct re_guts *g = m->g;
* at - print current situation
*/
static void
-at(struct match * m, pg_wchar * title, pg_wchar * start, pg_wchar * stop,
+at(struct match * m, pg_wchar *title, pg_wchar *start, pg_wchar *stop,
sopno startst, sopno stopst)
{
if (!(m->eflags & REG_TRACE))
return (isprint((unsigned char) c));
#endif
}
-
#endif
#endif
#else
static char othercase(int ch);
-
#endif
static void bothcases(struct parse * p, int ch);
static void ordinary(struct parse * p, int ch);
#ifdef MULTIBYTE
pg_wchar *wcp;
-
#endif
#ifdef REDEBUG
#ifdef MULTIBYTE
pg_wchar sp1[] = {'[', ':', '<', ':', ']', ']'};
pg_wchar sp2[] = {'[', ':', '>', ':', ']', ']'};
-
#endif
/* Dept of Truly Sickening Special-Case Kludges */
/*
* p_b_symbol - parse a character or [..]ed multicharacter collating symbol
*/
-static pg_wchar /* value of symbol */
+static pg_wchar /* value of symbol */
p_b_symbol(struct parse * p)
{
pg_wchar value;
pg_wchar *oldend = p->end;
pg_wchar bracket[3];
- assert(othercase(ch) != ch);/* p_bracket() would recurse */
+ assert(othercase(ch) != ch); /* p_bracket() would recurse */
p->next = bracket;
p->end = bracket + 2;
bracket[0] = ch;
case REP(0, N): /* as x{1,n}? */
case REP(0, INF): /* as x{1,}? */
/* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
- INSERT(OCH_, start);/* offset is wrong... */
+ INSERT(OCH_, start); /* offset is wrong... */
repeat(p, start + 1, 1, to);
ASTERN(OOR1, start);
AHEAD(start); /* ... fix it */
do { \
free((m)->space); \
} while (0)
-
+
#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
#define onestate int
#define INIT(o, n) ((o) = (n))
#ifdef MULTIBYTE
pg_wchar *str;
int sts;
-
#endif
#ifdef REDEBUG
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.97 2001/07/09 23:50:32 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.98 2001/10/25 05:49:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static Query *rewriteRuleAction(Query *parsetree,
- Query *rule_action,
- Node *rule_qual,
- int rt_index,
- CmdType event);
+ Query *rule_action,
+ Node *rule_qual,
+ int rt_index,
+ CmdType event);
static List *adjustJoinTreeList(Query *parsetree, bool removert, int rt_index);
static void markQueryForUpdate(Query *qry, bool skipOldNew);
static List *matchLocks(CmdType event, RuleLock *rulelocks,
PRS2_OLD_VARNO + rt_length, rt_index, 0);
/*
- * Generate expanded rtable consisting of main parsetree's rtable
- * plus rule action's rtable; this becomes the complete rtable for the
- * rule action. Some of the entries may be unused after we finish
- * rewriting, but if we tried to clean those out we'd have a much harder
- * job to adjust RT indexes in the query's Vars. It's OK to have unused
- * RT entries, since planner will ignore them.
+ * Generate expanded rtable consisting of main parsetree's rtable plus
+ * rule action's rtable; this becomes the complete rtable for the rule
+ * action. Some of the entries may be unused after we finish
+ * rewriting, but if we tried to clean those out we'd have a much
+ * harder job to adjust RT indexes in the query's Vars. It's OK to
+ * have unused RT entries, since planner will ignore them.
*
* NOTE: because planner will destructively alter rtable, we must ensure
- * that rule action's rtable is separate and shares no substructure with
- * the main rtable. Hence do a deep copy here.
+ * that rule action's rtable is separate and shares no substructure
+ * with the main rtable. Hence do a deep copy here.
*/
sub_action->rtable = nconc((List *) copyObject(parsetree->rtable),
sub_action->rtable);
* joined twice, however, so avoid keeping it if the rule action
* mentions it.
*
- * As above, the action's jointree must not share substructure with
- * the main parsetree's.
+ * As above, the action's jointree must not share substructure with the
+ * main parsetree's.
*/
if (sub_action->jointree != NULL)
{
keeporig = (!rangeTableEntry_used((Node *) sub_action->jointree,
rt_index, 0)) &&
(rangeTableEntry_used(rule_qual, rt_index, 0) ||
- rangeTableEntry_used(parsetree->jointree->quals, rt_index, 0));
+ rangeTableEntry_used(parsetree->jointree->quals, rt_index, 0));
newjointree = adjustJoinTreeList(parsetree, !keeporig, rt_index);
sub_action->jointree->fromlist =
nconc(newjointree, sub_action->jointree->fromlist);
* We copy the qualifications of the parsetree to the action and vice
* versa. So force hasSubLinks if one of them has it. If this is not
* right, the flag will get cleared later, but we mustn't risk having
- * it not set when it needs to be. (XXX this should probably be handled
- * by AddQual and friends, not here...)
+ * it not set when it needs to be. (XXX this should probably be
+ * handled by AddQual and friends, not here...)
*/
if (parsetree->hasSubLinks)
sub_action->hasSubLinks = TRUE;
*/
if (intMember(rt_index, parsetree->rowMarks))
{
-
/*
* Remove the view from the list of rels that will actually be
* marked FOR UPDATE by the executor. It will still be access-
rel = heap_openr(rte->relname, lockmode);
/*
- * Check to see if relation's OID matches the RTE. If not, the RTE
- * actually refers to an older relation that had the same name.
- * Eventually we might want to reparse the referencing rule, but
- * for now all we can do is punt.
+ * Check to see if relation's OID matches the RTE. If not, the
+ * RTE actually refers to an older relation that had the same
+ * name. Eventually we might want to reparse the referencing rule,
+ * but for now all we can do is punt.
*/
if (RelationGetRelid(rel) != rte->relid)
elog(ERROR, "Relation \"%s\" with OID %u no longer exists",
/*
* Check to see if relation's OID matches the RTE. If not, the RTE
* actually refers to an older relation that had the same name.
- * Eventually we might want to reparse the referencing rule, but
- * for now all we can do is punt.
+ * Eventually we might want to reparse the referencing rule, but for
+ * now all we can do is punt.
*/
if (RelationGetRelid(rt_entry_relation) != rt_entry->relid)
elog(ERROR, "Relation \"%s\" with OID %u no longer exists",
}
/*
- * For INSERTs, the original query is done first; for UPDATE/DELETE, it is
- * done last. This is needed because update and delete rule actions might
- * not do anything if they are invoked after the update or delete is
- * performed. The command counter increment between the query execution
- * makes the deleted (and maybe the updated) tuples disappear so the scans
- * for them in the rule actions cannot find them.
+ * For INSERTs, the original query is done first; for UPDATE/DELETE,
+ * it is done last. This is needed because update and delete rule
+ * actions might not do anything if they are invoked after the update
+ * or delete is performed. The command counter increment between the
+ * query execution makes the deleted (and maybe the updated) tuples
+ * disappear so the scans for them in the rule actions cannot find
+ * them.
*/
if (parsetree->commandType == CMD_INSERT)
{
*/
if (qual_products != NIL)
rewritten = nconc(qual_products, rewritten);
+
/*
* Add the unmodified original query, if no INSTEAD rule was seen.
*/
*/
if (qual_products != NIL)
rewritten = nconc(rewritten, qual_products);
+
/*
* Add the unmodified original query, if no INSTEAD rule was seen.
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.58 2001/09/07 20:52:31 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.59 2001/10/25 05:49:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool
checkExprHasAggs(Node *node)
{
-
/*
* If a Query is passed, examine it --- but we will not recurse into
* sub-Queries.
bool
checkExprHasSubLink(Node *node)
{
-
/*
* If a Query is passed, examine it --- but we will not recurse into
* sub-Queries.
* There's noplace to put the qual on a utility statement.
*
* If it's a NOTIFY, silently ignore the qual; this means that the
- * NOTIFY will execute, whether or not there are any qualifying rows.
- * While clearly wrong, this is much more useful than refusing to
- * execute the rule at all, and extra NOTIFY events are harmless for
- * typical uses of NOTIFY.
+ * NOTIFY will execute, whether or not there are any qualifying
+ * rows. While clearly wrong, this is much more useful than
+ * refusing to execute the rule at all, and extra NOTIFY events
+ * are harmless for typical uses of NOTIFY.
*
- * If it isn't a NOTIFY, error out, since unconditional execution
- * of other utility stmts is unlikely to be wanted. (This case is
+ * If it isn't a NOTIFY, error out, since unconditional execution of
+ * other utility stmts is unlikely to be wanted. (This case is
* not currently allowed anyway, but keep the test for safety.)
*/
if (parsetree->utilityStmt && IsA(parsetree->utilityStmt, NotifyStmt))
AddHavingQual(parsetree, notqual);
}
-
#endif
void
}
return NULL;
}
-
#endif
query_tree_mutator(parsetree, HandleRIRAttributeRule_mutator,
(void *) &context, true);
}
-
#endif /* NOT_USED */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.45 2001/10/01 05:36:13 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.46 2001/10/25 05:49:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
* link the buffers into a circular, doubly-linked list to
- * initialize free list, and initialize the buffer headers.
- * Still don't know anything about replacement strategy in this file.
+ * initialize free list, and initialize the buffer headers. Still
+ * don't know anything about replacement strategy in this file.
*/
for (i = 0; i < Data_Descriptors; block += BLCKSZ, buf++, i++)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.24 2001/10/05 17:28:12 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.25 2001/10/25 05:49:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
BufferDesc *
BufTableLookup(BufferTag *tagPtr)
{
- BufferLookupEnt *result;
+ BufferLookupEnt *result;
if (tagPtr->blockNum == P_NEW)
return NULL;
bool
BufTableDelete(BufferDesc *buf)
{
- BufferLookupEnt *result;
+ BufferLookupEnt *result;
/*
* buffer not initialized or has been removed from table already.
bool
BufTableInsert(BufferDesc *buf)
{
- BufferLookupEnt *result;
+ BufferLookupEnt *result;
bool found;
/* cannot insert it twice */
hash_stats("Shared", SharedBufHash);
}
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.117 2001/09/29 04:02:23 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.118 2001/10/25 05:49:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define BUFFER_IS_BROKEN(buf) ((buf->flags & BM_IO_ERROR) && !(buf->flags & BM_DIRTY))
static Buffer ReadBufferInternal(Relation reln, BlockNumber blockNum,
- bool bufferLockHeld);
+ bool bufferLockHeld);
static BufferDesc *BufferAlloc(Relation reln, BlockNumber blockNum,
- bool *foundPtr);
+ bool *foundPtr);
static int ReleaseBufferWithBufferLock(Buffer buffer);
static int BufferReplace(BufferDesc *bufHdr);
void PrintBufferDescs(void);
blockNum = reln->rd_nblocks = smgrnblocks(DEFAULT_SMGR, reln);
reln->rd_nblocks++;
}
+
/*
* lookup the buffer. IO_IN_PROGRESS is set if the requested
* block is not currently in memory.
/* That is, we're done if we expected to be able to find it ... */
if (!isExtend)
return BufferDescriptorGetBuffer(bufHdr);
+
/*
- * If we found a buffer when we were expecting to extend the relation,
- * the implication is that a buffer was already created for the next
- * page position, but then smgrextend failed to write the page.
- * We'd better try the smgrextend again. But since BufferAlloc
- * won't have done StartBufferIO, we must do that first.
+ * If we found a buffer when we were expecting to extend the
+ * relation, the implication is that a buffer was already created
+ * for the next page position, but then smgrextend failed to write
+ * the page. We'd better try the smgrextend again. But since
+ * BufferAlloc won't have done StartBufferIO, we must do that
+ * first.
*/
if (!isLocalBuf)
{
buf = BufTableLookup(&newTag);
if (buf != NULL)
{
-
/*
* Found it. Now, (a) pin the buffer so no one steals it from the
* buffer pool, (b) check IO_IN_PROGRESS, someone may be faulting
}
if (BUFFER_IS_BROKEN(buf))
{
-
/*
* I couldn't understand the following old comment. If there's
* no IO for the buffer and the buffer is BROKEN,it should be
buf2 = BufTableLookup(&newTag);
if (buf2 != NULL)
{
-
/*
* Found it. Someone has already done what we're about to
* do. We'll just handle this as if it were found in the
/*
* Changed to wait until there's no IO - Inoue 01/13/2000
*
- * Note this is *necessary* because an error abort in the process
- * doing I/O could release the io_in_progress_lock prematurely.
- * See AbortBufferIO.
+ * Note this is *necessary* because an error abort in the process doing
+ * I/O could release the io_in_progress_lock prematurely. See
+ * AbortBufferIO.
*/
while ((buf->flags & BM_IO_IN_PROGRESS) != 0)
{
{
BufferDesc *buf = &BufferDescriptors[i];
- PrivateRefCount[i] = 1; /* make sure we release shared pin */
+ PrivateRefCount[i] = 1; /* make sure we release shared pin */
LWLockAcquire(BufMgrLock, LW_EXCLUSIVE);
UnpinBuffer(buf);
LWLockRelease(BufMgrLock);
RelationGetNumberOfBlocks(Relation relation)
{
/*
- * relation->rd_nblocks should be accurate already if the relation
- * is myxactonly. (XXX how safe is that really?) Don't call smgr
- * on a view, either.
+ * relation->rd_nblocks should be accurate already if the relation is
+ * myxactonly. (XXX how safe is that really?) Don't call smgr on a
+ * view, either.
*/
if (relation->rd_rel->relkind == RELKIND_VIEW)
relation->rd_nblocks = 0;
recheck:
if (RelFileNodeEquals(bufHdr->tag.rnode, rel->rd_node))
{
-
/*
* If there is I/O in progress, better wait till it's done;
* don't want to delete the relation out from under someone
recheck:
if (RelFileNodeEquals(bufHdr->tag.rnode, rnode))
{
-
/*
* If there is I/O in progress, better wait till it's done;
* don't want to delete the relation out from under someone
*/
if (bufHdr->tag.rnode.tblNode == dbid)
{
-
/*
* If there is I/O in progress, better wait till it's done;
* don't want to delete the database out from under someone
BufTableDelete(&BufferDescriptors[i - 1]);
}
}
-
#endif
/* ---------------------------------------------------------------------
PrivateRefCount[buffer - 1], file, line);
}
}
-
#endif
#ifdef NOT_USED
PrivateRefCount[buffer - 1], file, line);
}
}
-
#endif
#ifdef NOT_USED
}
return b;
}
-
#endif
#ifdef BMTRACE
kill(getpid(), SIGILL);
}
-
#endif /* BMTRACE */
/*
for (i = 0; i < NBuffers; i++)
{
- bits8 buflocks = BufferLocks[i];
+ bits8 buflocks = BufferLocks[i];
if (buflocks == 0)
continue;
if (buflocks & BL_PIN_COUNT_LOCK)
{
LWLockAcquire(BufMgrLock, LW_EXCLUSIVE);
+
/*
- * Don't complain if flag bit not set; it could have been reset
- * but we got a cancel/die interrupt before getting the signal.
+ * Don't complain if flag bit not set; it could have been
+ * reset but we got a cancel/die interrupt before getting the
+ * signal.
*/
if ((buf->flags & BM_PIN_COUNT_WAITER) != 0 &&
buf->wait_backend_id == MyBackendId)
buf = &(BufferDescriptors[buffer - 1]);
if (mode == BUFFER_LOCK_UNLOCK)
- {
LWLockRelease(buf->cntx_lock);
- }
else if (mode == BUFFER_LOCK_SHARE)
- {
LWLockAcquire(buf->cntx_lock, LW_SHARED);
- }
else if (mode == BUFFER_LOCK_EXCLUSIVE)
{
LWLockAcquire(buf->cntx_lock, LW_EXCLUSIVE);
buf->cntxDirty = true;
}
else
- {
elog(ERROR, "LockBuffer: unknown lock mode %d", mode);
- }
}
/*
{
InProgressBuf = (BufferDesc *) 0;
}
-
#endif
/*
if (buf)
{
/*
- * Since LWLockReleaseAll has already been called,
- * we're not holding the buffer's io_in_progress_lock.
- * We have to re-acquire it so that we can use TerminateBufferIO.
- * Anyone who's executing WaitIO on the buffer will be in a busy spin
- * until we succeed in doing this.
+ * Since LWLockReleaseAll has already been called, we're not
+ * holding the buffer's io_in_progress_lock. We have to re-acquire
+ * it so that we can use TerminateBufferIO. Anyone who's executing
+ * WaitIO on the buffer will be in a busy spin until we succeed in
+ * doing this.
*/
LWLockAcquire(buf->io_in_progress_lock, LW_EXCLUSIVE);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.25 2001/09/29 04:02:23 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.26 2001/10/25 05:49:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
void
PinBuffer(BufferDesc *buf)
{
- int b = BufferDescriptorGetBuffer(buf) - 1;
+ int b = BufferDescriptorGetBuffer(buf) - 1;
if (buf->refcount == 0)
{
PrivateRefCount[buffer - 1], file, line);
}
}
-
#endif
#undef UnpinBuffer
void
UnpinBuffer(BufferDesc *buf)
{
- int b = BufferDescriptorGetBuffer(buf) - 1;
+ int b = BufferDescriptorGetBuffer(buf) - 1;
IsNotInQueue(buf);
Assert(buf->refcount > 0);
PrivateRefCount[buffer - 1], file, line);
}
}
-
#endif
/*
printf("\tfree list corrupted: %d-th buffer is %d\n",
nfree, buf->buf_id);
}
-
#endif
#ifdef NOT_USED
buf = &(BufferDescriptors[buf->freeNext]);
}
}
-
#endif
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.10 2001/03/22 03:59:45 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.11 2001/10/25 05:49:41 momjian Exp $
*
* NOTES:
*
* multiple temporary files if more than MAX_PHYSICAL_FILESIZE bytes are
* written to it).
*/
-BufFile *
+BufFile *
BufFileCreateTemp(void)
{
BufFile *file;
* to attach a BufFile to a non-temporary file. Note that BufFiles created
* in this way CANNOT be expanded into multiple files.
*/
-BufFile *
+BufFile *
BufFileCreate(File file)
{
return makeBufFile(file);
}
-
#endif
/*
*/
while (wpos < file->nbytes)
{
-
/*
* Advance to next component file if necessary and possible.
*/
newOffset >= file->curOffset &&
newOffset <= file->curOffset + file->nbytes)
{
-
/*
* Seek is to a point within existing buffer; we can just adjust
* pos-within-buffer, without flushing buffer. Note this is OK
blknum += file->curFile * RELSEG_SIZE;
return blknum;
}
-
#endif
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.84 2001/09/30 18:57:45 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.85 2001/10/25 05:49:41 momjian Exp $
*
* NOTES:
*
* far beyond what they can really support. This GUC parameter limits what
* we will believe.
*/
-int max_files_per_process = 1000;
+int max_files_per_process = 1000;
/* Debugging.... */
#define FD_TEMPORARY (1 << 1)/* should be unlinked when closed */
File nextFree; /* link to next free VFD, if in freelist */
- File lruMoreRecently;/* doubly linked recency-of-use list */
+ File lruMoreRecently; /* doubly linked recency-of-use list */
File lruLessRecently;
long seekPos; /* current logical file position */
char *fileName; /* name of file, or NULL for unused VFD */
elog(DEBUG, "pg_nofile: sysconf(_SC_OPEN_MAX) failed; using %ld",
no_files);
}
-#else /* !HAVE_SYSCONF */
+#else /* !HAVE_SYSCONF */
#ifdef NOFILE
no_files = (long) NOFILE;
#else
no_files = (long) max_files_per_process;
#endif
-#endif /* HAVE_SYSCONF */
+#endif /* HAVE_SYSCONF */
/*
- * Some platforms return hopelessly optimistic values. Apply a
+ * Some platforms return hopelessly optimistic values. Apply a
* configurable upper limit.
*/
if (no_files > (long) max_files_per_process)
sprintf(buf + strlen(buf), "LEAST");
elog(DEBUG, buf);
}
-
#endif /* FDDEBUG */
static void
if (nfile > 0)
{
-
/*
* There are opened files and so there should be at least one used
* vfd in the ring.
if (VfdCache[0].nextFree == 0)
{
-
/*
* The free list is empty so it is time to increase the size of
* the array. We choose to double it each time this happens.
newCacheSize = 32;
/*
- * Be careful not to clobber VfdCache ptr if realloc fails;
- * we will need it during proc_exit cleanup!
+ * Be careful not to clobber VfdCache ptr if realloc fails; we
+ * will need it during proc_exit cleanup!
*/
newVfdCache = (Vfd *) realloc(VfdCache, sizeof(Vfd) * newCacheSize);
if (newVfdCache == NULL)
sprintf(buf, "%s/%s", DatabasePath, filename);
}
else
- {
buf = pstrdup(filename);
- }
#ifdef FILEDEBUG
printf("filepath: path is %s\n", buf);
}
else if (VfdCache[0].lruLessRecently != file)
{
-
/*
* We now know that the file is open and that it is not the last
* one accessed, so we need to move it to the head of the Lru
if (!FileIsNotOpen(file))
LruDelete(file);
}
-
#endif
static File
0600);
if (file <= 0)
{
- char *dirpath;
+ char *dirpath;
/*
- * We might need to create the pg_tempfiles subdirectory, if
- * no one has yet done so.
+ * We might need to create the pg_tempfiles subdirectory, if no
+ * one has yet done so.
*
* Don't check for error from mkdir; it could fail if someone else
- * just did the same thing. If it doesn't work then we'll bomb out
- * on the second create attempt, instead.
+ * just did the same thing. If it doesn't work then we'll bomb
+ * out on the second create attempt, instead.
*/
dirpath = filepath(PG_TEMP_FILES_DIR);
mkdir(dirpath, S_IRWXU);
file, VfdCache[file].fileName));
return VfdCache[file].seekPos;
}
-
#endif
int
}
else
{
-
/*
* We don't use FileAccess() because we don't want to force the
* file to the front of the LRU ring; we aren't expecting to
void
RemovePgTempFiles(void)
{
- char db_path[MAXPGPATH];
- char temp_path[MAXPGPATH];
- char rm_path[MAXPGPATH];
+ char db_path[MAXPGPATH];
+ char temp_path[MAXPGPATH];
+ char rm_path[MAXPGPATH];
DIR *db_dir;
DIR *temp_dir;
- struct dirent *db_de;
- struct dirent *temp_de;
+ struct dirent *db_de;
+ struct dirent *temp_de;
/*
- * Cycle through pg_tempfiles for all databases
- * and remove old temp files.
+ * Cycle through pg_tempfiles for all databases and remove old temp
+ * files.
*/
snprintf(db_path, sizeof(db_path), "%s/base", DataDir);
if ((db_dir = opendir(db_path)) != NULL)
if (strncmp(temp_de->d_name,
PG_TEMP_FILE_PREFIX,
strlen(PG_TEMP_FILE_PREFIX)) == 0)
- {
unlink(rm_path);
- }
else
{
/*
- * would prefer to use elog here, but it's not
- * up and running during postmaster startup...
+ * would prefer to use elog here, but it's not up
+ * and running during postmaster startup...
*/
fprintf(stderr,
"Unexpected file found in temporary-files directory: %s\n",
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.7 2001/10/05 17:28:12 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.8 2001/10/25 05:49:42 momjian Exp $
*
*
* NOTES:
* These currently work as follows:
*
* The number of distinct relations tracked is limited by a configuration
- * variable (MaxFSMRelations). When this would be exceeded, we discard the
- * least frequently used relation. A previously-unknown relation is always
+ * variable (MaxFSMRelations). When this would be exceeded, we discard the
+ * least frequently used relation. A previously-unknown relation is always
* entered into the map with useCount 1 on first reference, even if this
* causes an existing entry with higher useCount to be discarded. This may
* cause a little bit of thrashing among the bottom entries in the list,
* but if we didn't do it then there'd be no way for a relation not in the
- * map to get in once the map is full. Note we allow a relation to be in the
+ * map to get in once the map is full. Note we allow a relation to be in the
* map even if no pages are currently stored for it: this allows us to track
* its useCount & threshold, which may eventually go high enough to give it
* priority for page storage.
*/
struct FSMRelation
{
- RelFileNode key; /* hash key (must be first) */
+ RelFileNode key; /* hash key (must be first) */
FSMRelation *nextRel; /* next rel in useCount order */
FSMRelation *priorRel; /* prior rel in useCount order */
int useCount; /* use count for prioritizing rels */
Size threshold; /* minimum amount of free space to keep */
int nextPage; /* index (from 0) to start next search at */
- int numPages; /* total number of pages we have info about */
+ int numPages; /* total number of pages we have info
+ * about */
int numChunks; /* number of FSMChunks allocated to rel */
FSMChunk *relChunks; /* linked list of page info chunks */
};
* to the freelist; but there's no point in doing the compaction before that.
*/
-#define CHUNKPAGES 32 /* each chunk can store this many pages */
+#define CHUNKPAGES 32 /* each chunk can store this many pages */
struct FSMChunk
{
FSMChunk *next; /* linked-list link */
int numPages; /* number of pages described here */
- BlockNumber pages[CHUNKPAGES]; /* page numbers within relation */
- ItemLength bytes[CHUNKPAGES]; /* free space available on each page */
+ BlockNumber pages[CHUNKPAGES]; /* page numbers within relation */
+ ItemLength bytes[CHUNKPAGES]; /* free space available on each
+ * page */
};
-int MaxFSMRelations; /* these are set by guc.c */
-int MaxFSMPages;
+int MaxFSMRelations; /* these are set by guc.c */
+int MaxFSMPages;
-static FSMHeader *FreeSpaceMap; /* points to FSMHeader in shared memory */
+static FSMHeader *FreeSpaceMap; /* points to FSMHeader in shared memory */
static FSMRelation *lookup_fsm_rel(RelFileNode *rel);
static void free_chunk_chain(FSMChunk *fchunk);
static BlockNumber find_free_space(FSMRelation *fsmrel, Size spaceNeeded);
static void fsm_record_free_space(FSMRelation *fsmrel, BlockNumber page,
- Size spaceAvail);
+ Size spaceAvail);
static bool lookup_fsm_page_entry(FSMRelation *fsmrel, BlockNumber page,
- FSMChunk **outChunk, int *outChunkRelIndex);
+ FSMChunk **outChunk, int *outChunkRelIndex);
static bool insert_fsm_page_entry(FSMRelation *fsmrel,
- BlockNumber page, Size spaceAvail,
- FSMChunk *chunk, int chunkRelIndex);
+ BlockNumber page, Size spaceAvail,
+ FSMChunk *chunk, int chunkRelIndex);
static bool push_fsm_page_entry(BlockNumber page, Size spaceAvail,
- FSMChunk *chunk, int chunkRelIndex);
+ FSMChunk *chunk, int chunkRelIndex);
static void delete_fsm_page_entry(FSMRelation *fsmrel, FSMChunk *chunk,
- int chunkRelIndex);
+ int chunkRelIndex);
static void compact_fsm_page_list(FSMRelation *fsmrel);
static void acquire_fsm_free_space(void);
* will turn out to have too little space available by the time the caller
* gets a lock on it. In that case, the caller should report the actual
* amount of free space available on that page (via RecordFreeSpace) and
- * then try again. If InvalidBlockNumber is returned, extend the relation.
+ * then try again. If InvalidBlockNumber is returned, extend the relation.
*/
BlockNumber
GetPageWithFreeSpace(RelFileNode *rel, Size spaceNeeded)
{
FSMRelation *fsmrel;
- BlockNumber freepage;
+ BlockNumber freepage;
LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE);
+
/*
* We always add a rel to the hashtable when it is inquired about.
*/
fsmrel = create_fsm_rel(rel);
+
/*
- * Adjust the threshold towards the space request. This essentially
+ * Adjust the threshold towards the space request. This essentially
* implements an exponential moving average with an equivalent period
* of about 63 requests. Ignore silly requests, however, to ensure
* that the average stays in bounds.
*
* In theory, if the threshold increases here we should immediately
- * delete any pages that fall below the new threshold. In practice
- * it seems OK to wait until we have a need to compact space.
+ * delete any pages that fall below the new threshold. In practice it
+ * seems OK to wait until we have a need to compact space.
*/
if (spaceNeeded > 0 && spaceNeeded < BLCKSZ)
{
- int cur_avg = (int) fsmrel->threshold;
+ int cur_avg = (int) fsmrel->threshold;
cur_avg += ((int) spaceNeeded - cur_avg) / 32;
fsmrel->threshold = (Size) cur_avg;
AssertArg(spaceAvail < BLCKSZ);
LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE);
+
/*
* We choose not to add rels to the hashtable unless they've been
* inquired about with GetPageWithFreeSpace. Also, a Record operation
Size spaceNeeded)
{
FSMRelation *fsmrel;
- BlockNumber freepage;
+ BlockNumber freepage;
/* Sanity check: ensure spaceAvail will fit into ItemLength */
AssertArg(oldSpaceAvail < BLCKSZ);
LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE);
+
/*
* We always add a rel to the hashtable when it is inquired about.
*/
fsmrel = create_fsm_rel(rel);
+
/*
* Adjust the threshold towards the space request, same as in
* GetPageWithFreeSpace.
*
- * Note that we do this before storing data for oldPage, which means
- * this isn't exactly equivalent to Record followed by Get; but it
- * seems appropriate to adjust the threshold first.
+ * Note that we do this before storing data for oldPage, which means this
+ * isn't exactly equivalent to Record followed by Get; but it seems
+ * appropriate to adjust the threshold first.
*/
if (spaceNeeded > 0 && spaceNeeded < BLCKSZ)
{
- int cur_avg = (int) fsmrel->threshold;
+ int cur_avg = (int) fsmrel->threshold;
cur_avg += ((int) spaceNeeded - cur_avg) / 32;
fsmrel->threshold = (Size) cur_avg;
* pages in that page number range (inclusive). This allows obsolete info
* to be discarded. Second, if nPages > 0, record the page numbers and free
* space amounts in the given arrays. As with RecordFreeSpace, the FSM is at
- * liberty to discard some of the information. However, it *must* discard
+ * liberty to discard some of the information. However, it *must* discard
* previously stored info in the minPage..maxPage range (for example, this
* case is used to remove info about deleted pages during relation truncation).
*/
done = false;
while (chunk && !done)
{
- int numPages = chunk->numPages;
+ int numPages = chunk->numPages;
for (; chunkRelIndex < numPages; chunkRelIndex++)
{
/* Now compact out the zeroed entries */
compact_fsm_page_list(fsmrel);
}
+
/*
* Add new entries, if appropriate.
*
* XXX we could probably be smarter about this than doing it
- * completely separately for each one. FIXME later.
+ * completely separately for each one. FIXME later.
*
- * One thing we can do is short-circuit the process entirely if
- * a page (a) has too little free space to be recorded, and (b)
- * is within the minPage..maxPage range --- then we deleted any
- * old entry above, and we aren't going to make a new one.
- * This is particularly useful since in most cases, all the passed
- * pages will in fact be in the minPage..maxPage range.
+ * One thing we can do is short-circuit the process entirely if a
+ * page (a) has too little free space to be recorded, and (b) is
+ * within the minPage..maxPage range --- then we deleted any old
+ * entry above, and we aren't going to make a new one. This is
+ * particularly useful since in most cases, all the passed pages
+ * will in fact be in the minPage..maxPage range.
*/
for (i = 0; i < nPages; i++)
{
- BlockNumber page = pages[i];
+ BlockNumber page = pages[i];
Size avail = spaceAvail[i];
if (avail >= fsmrel->threshold ||
LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE);
for (fsmrel = FreeSpaceMap->relList; fsmrel; fsmrel = nextrel)
{
- nextrel = fsmrel->nextRel; /* in case we delete it */
+ nextrel = fsmrel->nextRel; /* in case we delete it */
if (fsmrel->key.tblNode == dbid)
delete_fsm_rel(fsmrel);
}
{
/* New hashtable entry, initialize it (hash_search set the key) */
fsmrel->useCount = 1;
- fsmrel->threshold = BLCKSZ/2; /* starting point for new entry */
+ fsmrel->threshold = BLCKSZ / 2; /* starting point for new entry */
fsmrel->nextPage = 0;
fsmrel->numPages = 0;
fsmrel->numChunks = 0;
/* Discard lowest-priority existing rel, if we are over limit */
if (FreeSpaceMap->numRels >= MaxFSMRelations)
delete_fsm_rel(FreeSpaceMap->relListTail);
+
/*
* Add new entry in front of any others with useCount 1 (since it
* is more recently used than them).
}
else
{
- int myCount;
+ int myCount;
/* Existing entry, advance its useCount */
- if (++(fsmrel->useCount) >= INT_MAX/2)
+ if (++(fsmrel->useCount) >= INT_MAX / 2)
{
/* When useCounts threaten to overflow, reduce 'em all 2X */
for (oldrel = FreeSpaceMap->relList;
oldrel != NULL;
oldrel = oldrel->nextRel)
- {
oldrel->useCount >>= 1;
- }
}
/* If warranted, move it up the priority list */
oldrel = fsmrel->priorRel;
/*
* Look to see if a page with at least the specified amount of space is
- * available in the given FSMRelation. If so, return its page number,
+ * available in the given FSMRelation. If so, return its page number,
* and advance the nextPage counter so that the next inquiry will return
* a different page if possible. Return InvalidBlockNumber if no success.
*/
/* Check the next page */
if ((Size) curChunk->bytes[chunkRelIndex] >= spaceNeeded)
{
- fsmrel->nextPage = pageIndex+1;
+ fsmrel->nextPage = pageIndex + 1;
return curChunk->pages[chunkRelIndex];
}
/* Advance pageIndex and chunkRelIndex, wrapping around if needed */
/*
* No existing entry; add one if spaceAvail exceeds threshold.
*
- * CORNER CASE: if we have to do acquire_fsm_free_space then
- * our own threshold will increase, possibly meaning that we
- * shouldn't store the page after all. Loop to redo the test
- * if that happens. The loop also covers the possibility that
- * acquire_fsm_free_space must be executed more than once to
- * free any space (ie, thresholds must be more than doubled).
+ * CORNER CASE: if we have to do acquire_fsm_free_space then our own
+ * threshold will increase, possibly meaning that we shouldn't
+ * store the page after all. Loop to redo the test if that
+ * happens. The loop also covers the possibility that
+ * acquire_fsm_free_space must be executed more than once to free
+ * any space (ie, thresholds must be more than doubled).
*/
while (spaceAvail >= fsmrel->threshold)
{
acquire_fsm_free_space();
if (spaceAvail < fsmrel->threshold)
break;
+
/*
* Need to redo the lookup since our own page list may well
* have lost entries, so position is not correct anymore.
for (chunk = fsmrel->relChunks; chunk; chunk = chunk->next)
{
- int numPages = chunk->numPages;
+ int numPages = chunk->numPages;
/* Can skip the chunk quickly if page must be after last in chunk */
- if (numPages > 0 && page <= chunk->pages[numPages-1])
+ if (numPages > 0 && page <= chunk->pages[numPages - 1])
{
for (chunkRelIndex = 0; chunkRelIndex < numPages; chunkRelIndex++)
{
/* Should not get here, given above test */
Assert(false);
}
+
/*
- * If we are about to fall off the end, and there's space available
- * in the end chunk, return a pointer to it.
+ * If we are about to fall off the end, and there's space
+ * available in the end chunk, return a pointer to it.
*/
if (chunk->next == NULL && numPages < CHUNKPAGES)
{
return false;
}
}
+
/*
* Adding the page would require a new chunk (or, perhaps, compaction
* of available free space --- not my problem here).
{
/* No free space within chunk list, so need another chunk */
if ((newChunk = FreeSpaceMap->freeChunks) == NULL)
- return false; /* can't do it */
+ return false; /* can't do it */
FreeSpaceMap->freeChunks = newChunk->next;
FreeSpaceMap->numFreeChunks--;
newChunk->next = NULL;
fsmrel->nextPage++; /* don't return same page twice running */
return true;
}
+
/*
- * There is space available, but evidently it's before the place
- * where the page entry needs to go. Compact the list and try again.
- * This will require us to redo the search for the appropriate place.
+ * There is space available, but evidently it's before the place where
+ * the page entry needs to go. Compact the list and try again. This
+ * will require us to redo the search for the appropriate place.
*/
compact_fsm_page_list(fsmrel);
if (lookup_fsm_page_entry(fsmrel, page, &newChunk, &newChunkRelIndex))
/*
* Auxiliary routine for insert_fsm_page_entry: try to push entries to the
- * right to insert at chunk/chunkRelIndex. Return TRUE if successful.
+ * right to insert at chunk/chunkRelIndex. Return TRUE if successful.
* Note that the FSMRelation's own fields are not updated.
*/
static bool
if (chunk->next == NULL)
return false; /* no space */
/* try to push chunk's last item to next chunk */
- if (! push_fsm_page_entry(chunk->pages[CHUNKPAGES-1],
- chunk->bytes[CHUNKPAGES-1],
- chunk->next, 0))
+ if (!push_fsm_page_entry(chunk->pages[CHUNKPAGES - 1],
+ chunk->bytes[CHUNKPAGES - 1],
+ chunk->next, 0))
return false;
/* successfully pushed it */
chunk->numPages--;
}
for (i = chunk->numPages; i > chunkRelIndex; i--)
{
- chunk->pages[i] = chunk->pages[i-1];
- chunk->bytes[i] = chunk->bytes[i-1];
+ chunk->pages[i] = chunk->pages[i - 1];
+ chunk->bytes[i] = chunk->bytes[i - 1];
}
chunk->numPages++;
chunk->pages[chunkRelIndex] = page;
lim = --chunk->numPages;
for (i = chunkRelIndex; i < lim; i++)
{
- chunk->pages[i] = chunk->pages[i+1];
- chunk->bytes[i] = chunk->bytes[i+1];
+ chunk->pages[i] = chunk->pages[i + 1];
+ chunk->bytes[i] = chunk->bytes[i + 1];
}
/* Compact the whole list if a chunk can be freed */
fsmrel->numPages--;
- if (fsmrel->numPages <= (fsmrel->numChunks-1) * CHUNKPAGES)
+ if (fsmrel->numPages <= (fsmrel->numChunks - 1) * CHUNKPAGES)
compact_fsm_page_list(fsmrel);
}
while (srcChunk != NULL)
{
- int srcPages = srcChunk->numPages;
+ int srcPages = srcChunk->numPages;
while (srcIndex < srcPages)
{
nChunks = nPages = 0;
for (chunk = fsmrel->relChunks; chunk; chunk = chunk->next)
{
- int numPages = chunk->numPages;
+ int numPages = chunk->numPages;
nChunks++;
for (chunkRelIndex = 0; chunkRelIndex < numPages; chunkRelIndex++)
fprintf(stderr, "DumpFreeSpace: %d chunks in list, but numFreeChunks = %d\n",
nChunks, FreeSpaceMap->numFreeChunks);
}
-
#endif /* FREESPACE_DEBUG */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.71 2001/10/01 23:26:55 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.72 2001/10/25 05:49:42 momjian Exp $
*
* NOTES
*
void
proc_exit(int code)
{
-
/*
* Once we set this flag, we are committed to exit. Any elog() will
* NOT send control back to the main loop, but right back here.
if (semId < 0)
{
-
/*
* Fail quietly if error indicates a collision with existing set.
* One would expect EEXIST, given that we said IPC_EXCL, but
"\nThis error usually means that PostgreSQL's request for a shared memory\n"
"segment exceeded your kernel's SHMMAX parameter. You can either\n"
"reduce the request size or reconfigure the kernel with larger SHMMAX.\n"
- "To reduce the request size (currently %u bytes), reduce\n"
+ "To reduce the request size (currently %u bytes), reduce\n"
"PostgreSQL's shared_buffers parameter (currently %d) and/or\n"
"its max_connections parameter (currently %d).\n"
"\n"
else if (errno == ENOMEM)
fprintf(stderr,
"\nThis error usually means that PostgreSQL's request for a shared\n"
- "memory segment exceeded available memory or swap space.\n"
- "To reduce the request size (currently %u bytes), reduce\n"
+ "memory segment exceeded available memory or swap space.\n"
+ "To reduce the request size (currently %u bytes), reduce\n"
"PostgreSQL's shared_buffers parameter (currently %d) and/or\n"
"its max_connections parameter (currently %d).\n"
"\n"
"It occurs either if all available shared memory IDs have been taken,\n"
"in which case you need to raise the SHMMNI parameter in your kernel,\n"
"or because the system's overall limit for shared memory has been\n"
- "reached. If you cannot increase the shared memory limit,\n"
+ "reached. If you cannot increase the shared memory limit,\n"
"reduce PostgreSQL's shared memory request (currently %u bytes),\n"
"by reducing its shared_buffers parameter (currently %d) and/or\n"
"its max_connections parameter (currently %d).\n"
*/
if (shmctl(shmId, IPC_STAT, &shmStat) < 0)
{
-
/*
* EINVAL actually has multiple possible causes documented in the
* shmctl man page, but we assume it must mean the segment no
fprintf(stderr, "PrivateMemoryCreate: malloc(%u) failed\n", size);
proc_exit(1);
}
- MemSet(memAddress, 0, size);/* keep Purify quiet */
+ MemSet(memAddress, 0, size); /* keep Purify quiet */
/* Register on-exit routine to release storage */
on_shmem_exit(PrivateMemoryDelete, PointerGetDatum(memAddress));
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.43 2001/09/29 04:02:23 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.44 2001/10/25 05:49:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
InitShmemAllocation(seghdr);
/*
- * Now initialize LWLocks, which do shared memory allocation and
- * are needed for InitShmemIndex.
+ * Now initialize LWLocks, which do shared memory allocation and are
+ * needed for InitShmemIndex.
*/
CreateLWLocks();
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.61 2001/10/05 17:28:12 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.62 2001/10/25 05:49:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
ShmemEnd = ShmemBase + shmhdr->totalsize;
/*
- * Initialize the spinlock used by ShmemAlloc. We have to do the
- * space allocation the hard way, since ShmemAlloc can't be called yet.
+ * Initialize the spinlock used by ShmemAlloc. We have to do the
+ * space allocation the hard way, since ShmemAlloc can't be called
+ * yet.
*/
ShmemLock = (slock_t *) (((char *) shmhdr) + shmhdr->freeoffset);
shmhdr->freeoffset += MAXALIGN(sizeof(slock_t));
* table at once.
*/
HTAB *
-ShmemInitHash(const char *name, /* table string name for shmem index */
+ShmemInitHash(const char *name, /* table string name for shmem index */
long init_size, /* initial table size */
long max_size, /* max size of the table */
HASHCTL *infoP, /* info about key and bucket size */
/* look it up in the shmem index */
location = ShmemInitStruct(name,
- sizeof(HASHHDR) + infoP->dsize * sizeof(HASHSEGMENT),
+ sizeof(HASHHDR) + infoP->dsize * sizeof(HASHSEGMENT),
&found);
/*
return NULL;
/*
- * if it already exists, attach to it rather than allocate and initialize
- * new space
+ * if it already exists, attach to it rather than allocate and
+ * initialize new space
*/
if (found)
hash_flags |= HASH_ATTACH;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmqueue.c,v 1.16 2001/03/22 03:59:45 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmqueue.c,v 1.17 2001/10/25 05:49:42 momjian Exp $
*
* NOTES
*
#define SHMQUEUE_DEBUG_ELOG NOTICE
static void dumpQ(SHM_QUEUE *q, char *s);
-
#endif
Assert(SHM_PTR_VALID(queue));
return (queue)->prev == INVALID_OFFSET;
}
-
#endif
/*
dumpQ(queue, "in SHMQueueInsertAfter: end");
#endif
}
-
#endif /* NOT_USED */
/*--------------------
strcat(buf, elem);
elog(SHMQUEUE_DEBUG_ELOG, "%s: %s", s, buf);
}
-
#endif /* SHMQUEUE_DEBUG */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.42 2001/09/29 15:29:48 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.43 2001/10/25 05:49:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
void
InitBackendSharedInvalidationState(void)
{
- int flag;
+ int flag;
LWLockAcquire(SInvalLock, LW_EXCLUSIVE);
flag = SIBackendInit(shmInvalBuffer);
*/
void
ReceiveSharedInvalidMessages(
- void (*invalFunction) (SharedInvalidationMessage *msg),
- void (*resetFunction) (void))
+ void (*invalFunction) (SharedInvalidationMessage *msg),
+ void (*resetFunction) (void))
{
SharedInvalidationMessage data;
int getResult;
for (;;)
{
/*
- * We can run SIGetDataEntry in parallel with other backends running
- * SIGetDataEntry for themselves, since each instance will modify
- * only fields of its own backend's ProcState, and no instance will
- * look at fields of other backends' ProcStates. We express this
- * by grabbing SInvalLock in shared mode. Note that this is not
- * exactly the normal (read-only) interpretation of a shared lock!
- * Look closely at the interactions before allowing SInvalLock to
- * be grabbed in shared mode for any other reason!
+ * We can run SIGetDataEntry in parallel with other backends
+ * running SIGetDataEntry for themselves, since each instance will
+ * modify only fields of its own backend's ProcState, and no
+ * instance will look at fields of other backends' ProcStates. We
+ * express this by grabbing SInvalLock in shared mode. Note that
+ * this is not exactly the normal (read-only) interpretation of a
+ * shared lock! Look closely at the interactions before allowing
+ * SInvalLock to be grabbed in shared mode for any other reason!
*
- * The routines later in this file that use shared mode are okay
- * with this, because they aren't looking at the ProcState fields
- * associated with SI message transfer; they only use the ProcState
- * array as an easy way to find all the PROC structures.
+ * The routines later in this file that use shared mode are okay with
+ * this, because they aren't looking at the ProcState fields
+ * associated with SI message transfer; they only use the
+ * ProcState array as an easy way to find all the PROC structures.
*/
LWLockAcquire(SInvalLock, LW_SHARED);
getResult = SIGetDataEntry(shmInvalBuffer, MyBackendId, &data);
if (pOffset != INVALID_OFFSET)
{
PROC *proc = (PROC *) MAKE_PTR(pOffset);
+
/* Fetch xid just once - see GetNewTransactionId */
TransactionId pxid = proc->xid;
* then only backends running in my own database are considered.
*
* This is used by VACUUM to decide which deleted tuples must be preserved
- * in a table. allDbs = TRUE is needed for shared relations, but allDbs =
+ * in a table. allDbs = TRUE is needed for shared relations, but allDbs =
* FALSE is sufficient for non-shared relations, since only backends in my
* own database could ever see the tuples in them.
*
/*--------------------
* Unfortunately, we have to call ReadNewTransactionId() after acquiring
* SInvalLock above. It's not good because ReadNewTransactionId() does
- * LWLockAcquire(XidGenLock), but *necessary*. We need to be sure that
+ * LWLockAcquire(XidGenLock), but *necessary*. We need to be sure that
* no transactions exit the set of currently-running transactions
* between the time we fetch xmax and the time we finish building our
* snapshot. Otherwise we could have a situation like this:
if (pOffset != INVALID_OFFSET)
{
PROC *proc = (PROC *) MAKE_PTR(pOffset);
+
/* Fetch xid just once - see GetNewTransactionId */
TransactionId xid = proc->xid;
/*
* Ignore my own proc (dealt with my xid above), procs not
- * running a transaction, and xacts started since we read
- * the next transaction ID. There's no need to store XIDs
- * above what we got from ReadNewTransactionId, since we'll
- * treat them as running anyway.
+ * running a transaction, and xacts started since we read the
+ * next transaction ID. There's no need to store XIDs above
+ * what we got from ReadNewTransactionId, since we'll treat
+ * them as running anyway.
*/
if (proc == MyProc ||
- ! TransactionIdIsNormal(xid) ||
+ !TransactionIdIsNormal(xid) ||
TransactionIdFollowsOrEquals(xid, snapshot->xmax))
continue;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.89 2001/08/10 20:52:24 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.90 2001/10/25 05:49:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool neednextpage;
bytea *datafield;
bool pfreeit;
- struct {
- struct varlena hdr;
- char data[LOBLKSIZE];
+ struct
+ {
+ struct varlena hdr;
+ char data[LOBLKSIZE];
} workbuf;
char *workb = VARATT_DATA(&workbuf.hdr);
HeapTuple newtup;
while (nwritten < nbytes)
{
-
/*
* If possible, get next pre-existing page of the LO. We assume
* the indexscan will deliver these in order --- but there may be
*/
if (olddata != NULL && olddata->pageno == pageno)
{
-
/*
* Update an existing page with fresh data.
*
}
else
{
-
/*
* Write a brand new page.
*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.6 2001/09/30 00:45:47 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.7 2001/10/25 05:49:42 momjian Exp $
*
* Interface:
*
#ifdef DEBUG_DEADLOCK
static void PrintLockQueue(LOCK *lock, const char *info);
-
#endif
/* This proc soft-blocks checkProc */
if (FindLockCycleRecurse(proc, softEdges, nSoftEdges))
{
-
/*
* Add this edge to the list of soft edges in the
* cycle
/* This proc soft-blocks checkProc */
if (FindLockCycleRecurse(proc, softEdges, nSoftEdges))
{
-
/*
* Add this edge to the list of soft edges in the
* cycle
printf("\n");
fflush(stdout);
}
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.51 2001/09/27 16:29:12 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.52 2001/10/25 05:49:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
XactLockTableWait(TransactionId xid)
{
LOCKTAG tag;
- TransactionId myxid = GetCurrentTransactionId();
+ TransactionId myxid = GetCurrentTransactionId();
- Assert(! TransactionIdEquals(xid, myxid));
+ Assert(!TransactionIdEquals(xid, myxid));
MemSet(&tag, 0, sizeof(tag));
tag.relId = XactLockTableId;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.100 2001/10/05 17:28:12 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.101 2001/10/25 05:49:42 momjian Exp $
*
* NOTES
* Outside modules can create a lock table and acquire/release
/* This configuration variable is used to set the lock table size */
-int max_locks_per_xact; /* set by guc.c */
+int max_locks_per_xact; /* set by guc.c */
#define NLOCKENTS(maxBackends) (max_locks_per_xact * (maxBackends))
static char *lock_mode_names[] =
{
- "INVALID",
- "AccessShareLock",
- "RowShareLock",
- "RowExclusiveLock",
- "ShareUpdateExclusiveLock",
- "ShareLock",
- "ShareRowExclusiveLock",
- "ExclusiveLock",
- "AccessExclusiveLock"
+ "INVALID",
+ "AccessShareLock",
+ "RowShareLock",
+ "RowExclusiveLock",
+ "ShareUpdateExclusiveLock",
+ "ShareLock",
+ "ShareRowExclusiveLock",
+ "ExclusiveLock",
+ "AccessExclusiveLock"
};
LOCK_DEBUG_ENABLED(const LOCK *lock)
{
return
- (((LOCK_LOCKMETHOD(*lock) == DEFAULT_LOCKMETHOD && Trace_locks)
- || (LOCK_LOCKMETHOD(*lock) == USER_LOCKMETHOD && Trace_userlocks))
- && (lock->tag.relId >= (Oid) Trace_lock_oidmin))
- || (Trace_lock_table && (lock->tag.relId == Trace_lock_table));
+ (((LOCK_LOCKMETHOD(*lock) == DEFAULT_LOCKMETHOD && Trace_locks)
+ || (LOCK_LOCKMETHOD(*lock) == USER_LOCKMETHOD && Trace_userlocks))
+ && (lock->tag.relId >= (Oid) Trace_lock_oidmin))
+ || (Trace_lock_table && (lock->tag.relId == Trace_lock_table));
}
|| (HOLDER_LOCKMETHOD(*holderP) == USER_LOCKMETHOD && Trace_userlocks))
&& (((LOCK *) MAKE_PTR(holderP->tag.lock))->tag.relId >= (Oid) Trace_lock_oidmin))
|| (Trace_lock_table && (((LOCK *) MAKE_PTR(holderP->tag.lock))->tag.relId == Trace_lock_table))
- )
+ )
elog(DEBUG,
"%s: holder(%lx) lock(%lx) tbl(%d) proc(%lx) xid(%u) hold(%d,%d,%d,%d,%d,%d,%d)=%d",
where, MAKE_OFFSET(holderP), holderP->tag.lock,
#define LOCK_PRINT(where, lock, type)
#define HOLDER_PRINT(where, holderP)
-
#endif /* not LOCK_DEBUG */
else
{
Assert(status == STATUS_FOUND);
+
/*
* We can't acquire the lock immediately. If caller specified no
- * blocking, remove the holder entry and return FALSE without waiting.
+ * blocking, remove the holder entry and return FALSE without
+ * waiting.
*/
if (dontWait)
{
lock,
holder) != STATUS_OK)
{
-
/*
* We failed as a result of a deadlock, see HandleDeadLock(). Quit
* now. Removal of the holder and lock objects, if no longer
if (lock->nRequested == 0)
{
-
/*
* if there's no one waiting in the queue, we just released the
* last lock on this object. Delete it from the lock table.
elog(DEBUG, "DumpAllLocks: holder->tag.lock = NULL");
}
}
-
#endif /* LOCK_DEBUG */
* Lightweight locks are intended primarily to provide mutual exclusion of
* access to shared-memory data structures. Therefore, they offer both
* exclusive and shared lock modes (to support read/write and read-only
- * access to a shared object). There are few other frammishes. User-level
+ * access to a shared object). There are few other frammishes. User-level
* locking should be done with the full lock manager --- which depends on
* an LWLock to protect its shared state.
*
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.1 2001/09/29 04:02:24 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.2 2001/10/25 05:49:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* the array.
*/
static LWLock *LWLockArray = NULL;
+
/* shared counter for dynamic allocation of LWLockIds */
-static int *LWLockCounter;
+static int *LWLockCounter;
/*
*/
#define MAX_SIMUL_LWLOCKS 100
-static int num_held_lwlocks = 0;
-static LWLockId held_lwlocks[MAX_SIMUL_LWLOCKS];
+static int num_held_lwlocks = 0;
+static LWLockId held_lwlocks[MAX_SIMUL_LWLOCKS];
#ifdef LOCK_DEBUG
(int) lock->exclusive, lock->shared, lock->head);
}
-#else /* not LOCK_DEBUG */
+#else /* not LOCK_DEBUG */
#define PRINT_LWDEBUG(a,b,c)
-#endif /* LOCK_DEBUG */
+#endif /* LOCK_DEBUG */
/*
int
NumLWLocks(void)
{
- int numLocks;
+ int numLocks;
/*
- * Possibly this logic should be spread out among the affected modules,
- * the same way that shmem space estimation is done. But for now,
- * there are few enough users of LWLocks that we can get away with
- * just keeping the knowledge here.
+ * Possibly this logic should be spread out among the affected
+ * modules, the same way that shmem space estimation is done. But for
+ * now, there are few enough users of LWLocks that we can get away
+ * with just keeping the knowledge here.
*/
/* Predefined LWLocks */
int
LWLockShmemSize(void)
{
- int numLocks = NumLWLocks();
- uint32 spaceLocks;
+ int numLocks = NumLWLocks();
+ uint32 spaceLocks;
/* Allocate the LWLocks plus space for shared allocation counter. */
spaceLocks = numLocks * sizeof(LWLock) + 2 * sizeof(int);
void
CreateLWLocks(void)
{
- int numLocks = NumLWLocks();
- uint32 spaceLocks = LWLockShmemSize();
- LWLock *lock;
- int id;
+ int numLocks = NumLWLocks();
+ uint32 spaceLocks = LWLockShmemSize();
+ LWLock *lock;
+ int id;
/* Allocate space */
LWLockArray = (LWLock *) ShmemAlloc(spaceLocks);
void
LWLockAcquire(LWLockId lockid, LWLockMode mode)
{
- LWLock *lock = LWLockArray + lockid;
- bool mustwait;
+ LWLock *lock = LWLockArray + lockid;
+ bool mustwait;
PRINT_LWDEBUG("LWLockAcquire", lockid, lock);
if (mustwait)
{
/* Add myself to wait queue */
- PROC *proc = MyProc;
- int extraWaits = 0;
+ PROC *proc = MyProc;
+ int extraWaits = 0;
/*
- * If we don't have a PROC structure, there's no way to wait.
- * This should never occur, since MyProc should only be null
- * during shared memory initialization.
+ * If we don't have a PROC structure, there's no way to wait. This
+ * should never occur, since MyProc should only be null during
+ * shared memory initialization.
*/
if (proc == NULL)
elog(FATAL, "LWLockAcquire: can't wait without a PROC structure");
* Wait until awakened.
*
* Since we share the process wait semaphore with the regular lock
- * manager and ProcWaitForSignal, and we may need to acquire an LWLock
- * while one of those is pending, it is possible that we get awakened
- * for a reason other than being granted the LWLock. If so, loop back
- * and wait again. Once we've gotten the lock, re-increment the sema
- * by the number of additional signals received, so that the lock
- * manager or signal manager will see the received signal when it
- * next waits.
+ * manager and ProcWaitForSignal, and we may need to acquire an
+ * LWLock while one of those is pending, it is possible that we
+ * get awakened for a reason other than being granted the LWLock.
+ * If so, loop back and wait again. Once we've gotten the lock,
+ * re-increment the sema by the number of additional signals
+ * received, so that the lock manager or signal manager will see
+ * the received signal when it next waits.
*/
for (;;)
{
break;
extraWaits++;
}
+
/*
* The awakener already updated the lock struct's state, so we
* don't need to do anything more to it. Just need to fix the
bool
LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode)
{
- LWLock *lock = LWLockArray + lockid;
- bool mustwait;
+ LWLock *lock = LWLockArray + lockid;
+ bool mustwait;
PRINT_LWDEBUG("LWLockConditionalAcquire", lockid, lock);
void
LWLockRelease(LWLockId lockid)
{
- LWLock *lock = LWLockArray + lockid;
- PROC *head;
- PROC *proc;
- int i;
+ LWLock *lock = LWLockArray + lockid;
+ PROC *head;
+ PROC *proc;
+ int i;
PRINT_LWDEBUG("LWLockRelease", lockid, lock);
/*
- * Remove lock from list of locks held. Usually, but not always,
- * it will be the latest-acquired lock; so search array backwards.
+ * Remove lock from list of locks held. Usually, but not always, it
+ * will be the latest-acquired lock; so search array backwards.
*/
- for (i = num_held_lwlocks; --i >= 0; )
+ for (i = num_held_lwlocks; --i >= 0;)
{
if (lockid == held_lwlocks[i])
break;
elog(ERROR, "LWLockRelease: lock %d is not held", (int) lockid);
num_held_lwlocks--;
for (; i < num_held_lwlocks; i++)
- held_lwlocks[i] = held_lwlocks[i+1];
+ held_lwlocks[i] = held_lwlocks[i + 1];
/* Acquire mutex. Time spent holding mutex should be short! */
SpinLockAcquire_NoHoldoff(&lock->mutex);
}
/*
- * See if I need to awaken any waiters. If I released a non-last shared
- * hold, there cannot be anything to do.
+ * See if I need to awaken any waiters. If I released a non-last
+ * shared hold, there cannot be anything to do.
*/
head = lock->head;
if (head != NULL)
if (lock->exclusive == 0 && lock->shared == 0)
{
/*
- * Remove the to-be-awakened PROCs from the queue, and update the
- * lock state to show them as holding the lock.
+ * Remove the to-be-awakened PROCs from the queue, and update
+ * the lock state to show them as holding the lock.
*/
proc = head;
if (proc->lwExclusive)
- {
lock->exclusive++;
- }
else
{
lock->shared++;
/*
* LWLockReleaseAll - release all currently-held locks
*
- * Used to clean up after elog(ERROR). An important difference between this
+ * Used to clean up after elog(ERROR). An important difference between this
* function and retail LWLockRelease calls is that InterruptHoldoffCount is
* unchanged by this operation. This is necessary since InterruptHoldoffCount
- * has been set to an appropriate level earlier in error recovery. We could
+ * has been set to an appropriate level earlier in error recovery. We could
* decrement it below zero if we allow it to drop for each released lock!
*/
void
{
HOLD_INTERRUPTS(); /* match the upcoming RESUME_INTERRUPTS */
- LWLockRelease(held_lwlocks[num_held_lwlocks-1]);
+ LWLockRelease(held_lwlocks[num_held_lwlocks - 1]);
}
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.112 2001/10/01 18:16:32 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.113 2001/10/25 05:49:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* besides those used for regular backends.
*/
Assert(maxBackends > 0);
- semMapEntries = PROC_SEM_MAP_ENTRIES(maxBackends+1);
- procGlobalSize = sizeof(PROC_HDR) + (semMapEntries-1) * sizeof(SEM_MAP_ENTRY);
+ semMapEntries = PROC_SEM_MAP_ENTRIES(maxBackends + 1);
+ procGlobalSize = sizeof(PROC_HDR) + (semMapEntries - 1) *sizeof(SEM_MAP_ENTRY);
/* Create or attach to the ProcGlobal shared structure */
ProcGlobal = (PROC_HDR *)
*/
DummyProc = (PROC *) ShmemAlloc(sizeof(PROC));
DummyProc->pid = 0; /* marks DummyProc as not in use */
- i = semMapEntries-1;
- ProcGlobal->procSemMap[i].freeSemMap |= 1 << (PROC_NSEMS_PER_SET-1);
+ i = semMapEntries - 1;
+ ProcGlobal->procSemMap[i].freeSemMap |= 1 << (PROC_NSEMS_PER_SET - 1);
DummyProc->sem.semId = ProcGlobal->procSemMap[i].procSemId;
- DummyProc->sem.semNum = PROC_NSEMS_PER_SET-1;
+ DummyProc->sem.semNum = PROC_NSEMS_PER_SET - 1;
/* Create ProcStructLock spinlock, too */
ProcStructLock = (slock_t *) ShmemAlloc(sizeof(slock_t));
void
InitProcess(void)
{
- SHMEM_OFFSET myOffset;
+ SHMEM_OFFSET myOffset;
/*
- * ProcGlobal should be set by a previous call to InitProcGlobal
- * (if we are a backend, we inherit this by fork() from the postmaster).
+ * ProcGlobal should be set by a previous call to InitProcGlobal (if
+ * we are a backend, we inherit this by fork() from the postmaster).
*/
if (ProcGlobal == NULL)
elog(STOP, "InitProcess: Proc Header uninitialized");
on_shmem_exit(ProcKill, 0);
/*
- * Set up a wait-semaphore for the proc. (We rely on ProcKill to clean
- * up MyProc if this fails.)
+ * Set up a wait-semaphore for the proc. (We rely on ProcKill to
+ * clean up MyProc if this fails.)
*/
if (IsUnderPostmaster)
ProcGetNewSemIdAndNum(&MyProc->sem.semId, &MyProc->sem.semNum);
InitDummyProcess(void)
{
/*
- * ProcGlobal should be set by a previous call to InitProcGlobal
- * (we inherit this by fork() from the postmaster).
+ * ProcGlobal should be set by a previous call to InitProcGlobal (we
+ * inherit this by fork() from the postmaster).
*/
if (ProcGlobal == NULL || DummyProc == NULL)
elog(STOP, "InitDummyProcess: Proc Header uninitialized");
MyProc = DummyProc;
/*
- * Initialize all fields of MyProc, except MyProc->sem which was
- * set up by InitProcGlobal.
+ * Initialize all fields of MyProc, except MyProc->sem which was set
+ * up by InitProcGlobal.
*/
MyProc->pid = MyProcPid; /* marks DummyProc as in use by me */
SHMQueueElemInit(&(MyProc->links));
/*
* DummyProcKill() -- Cut-down version of ProcKill for dummy (checkpoint)
- * processes. The PROC and sema are not released, only marked
+ * processes. The PROC and sema are not released, only marked
* as not-in-use.
*/
static void
ProcQueueInit(queue);
return queue;
}
-
#endif
/*
if (lockctl->conflictTab[lockmode] & proc->heldLocks)
{
/*
- * Yes, so we have a deadlock. Easiest way to clean up
- * correctly is to call RemoveFromWaitQueue(), but we
- * can't do that until we are *on* the wait queue.
- * So, set a flag to check below, and break out of loop.
+ * Yes, so we have a deadlock. Easiest way to clean
+ * up correctly is to call RemoveFromWaitQueue(), but
+ * we can't do that until we are *on* the wait queue.
+ * So, set a flag to check below, and break out of
+ * loop.
*/
early_deadlock = true;
break;
MyProc->waitHolder = holder;
MyProc->waitLockMode = lockmode;
- MyProc->errType = STATUS_OK; /* initialize result for success */
+ MyProc->errType = STATUS_OK; /* initialize result for success */
/*
* If we detected deadlock, give up without waiting. This must agree
- * with HandleDeadLock's recovery code, except that we shouldn't release
- * the semaphore since we haven't tried to lock it yet.
+ * with HandleDeadLock's recovery code, except that we shouldn't
+ * release the semaphore since we haven't tried to lock it yet.
*/
if (early_deadlock)
{
* By delaying the check until we've waited for a bit, we can avoid
* running the rather expensive deadlock-check code in most cases.
*/
- if (! enable_sigalrm_interrupt(DeadlockTimeout))
+ if (!enable_sigalrm_interrupt(DeadlockTimeout))
elog(FATAL, "ProcSleep: Unable to set timer for process wakeup");
/*
/*
* Disable the timer, if it's still running
*/
- if (! disable_sigalrm_interrupt())
+ if (!disable_sigalrm_interrupt())
elog(FATAL, "ProcSleep: Unable to disable timer for process wakeup");
/*
}
else
{
-
/*
* Cannot wake this guy. Remember his request for later
* checks.
* Acquire locktable lock. Note that the SIGALRM interrupt had better
* not be enabled anywhere that this process itself holds the
* locktable lock, else this will wait forever. Also note that
- * LWLockAcquire creates a critical section, so that this
- * routine cannot be interrupted by cancel/die interrupts.
+ * LWLockAcquire creates a critical section, so that this routine
+ * cannot be interrupted by cancel/die interrupts.
*/
LWLockAcquire(LockMgrLock, LW_EXCLUSIVE);
void
ProcSendSignal(BackendId procId)
{
- PROC *proc = BackendIdGetProc(procId);
+ PROC *proc = BackendIdGetProc(procId);
if (proc != NULL)
IpcSemaphoreUnlock(proc->sem.semId, proc->sem.semNum);
/*
* Enable the SIGALRM interrupt to fire after the specified delay
*
- * Delay is given in milliseconds. Caller should be sure a SIGALRM
+ * Delay is given in milliseconds. Caller should be sure a SIGALRM
* signal handler is installed before this is called.
*
* Returns TRUE if okay, FALSE on failure.
/* BeOS doesn't have setitimer, but has set_alarm */
bigtime_t time_interval;
- time_interval = delayms * 1000; /* usecs */
+ time_interval = delayms * 1000; /* usecs */
if (set_alarm(time_interval, B_ONE_SHOT_RELATIVE_ALARM) < 0)
return false;
#endif
{
int i;
int semMapEntries = ProcGlobal->semMapEntries;
- SEM_MAP_ENTRY *procSemMap = ProcGlobal->procSemMap;
+ SEM_MAP_ENTRY *procSemMap = ProcGlobal->procSemMap;
int32 fullmask = (1 << PROC_NSEMS_PER_SET) - 1;
SpinLockAcquire(ProcStructLock);
SpinLockRelease(ProcStructLock);
/*
- * If we reach here, all the semaphores are in use. This is one of the
- * possible places to detect "too many backends", so give the standard
- * error message. (Whether we detect it here or in sinval.c depends on
- * whether MaxBackends is a multiple of PROC_NSEMS_PER_SET.)
+ * If we reach here, all the semaphores are in use. This is one of
+ * the possible places to detect "too many backends", so give the
+ * standard error message. (Whether we detect it here or in sinval.c
+ * depends on whether MaxBackends is a multiple of
+ * PROC_NSEMS_PER_SET.)
*/
elog(FATAL, "Sorry, too many clients already");
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.2 2001/09/29 04:02:25 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.3 2001/10/25 05:49:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
struct timeval delay;
/*
- * We loop tightly for awhile, then delay using select() and try again.
- * Preferably, "awhile" should be a small multiple of the maximum time
- * we expect a spinlock to be held. 100 iterations seems about right.
+ * We loop tightly for awhile, then delay using select() and try
+ * again. Preferably, "awhile" should be a small multiple of the
+ * maximum time we expect a spinlock to be held. 100 iterations seems
+ * about right.
*
* We use a 10 millisec select delay because that is the lower limit on
- * many platforms. The timeout is figured on this delay only, and so the
- * nominal 1 minute is a lower bound.
+ * many platforms. The timeout is figured on this delay only, and so
+ * the nominal 1 minute is a lower bound.
*/
#define SPINS_PER_DELAY 100
#define DELAY_MSEC 10
rts \n\
");
}
-
#endif /* __m68k__ */
#if defined(__APPLE__) && defined(__ppc__)
blr \n\
");
}
-
#endif /* __APPLE__ && __ppc__ */
#if defined(__powerpc__)
blr \n\
");
}
-
#endif /* __powerpc__ */
#if defined(__mips__) && !defined(__sgi)
tas_dummy()
{
__asm__ __volatile__(
- "\
+ "\
.global tas \n\
tas: \n\
.frame $sp, 0, $31 \n\
j $31 \n\
");
}
-
#endif /* __mips__ && !__sgi */
-#else /* not __GNUC__ */
+#else /* not __GNUC__ */
/***************************************************************************
* All non gcc
*/
asm(" rts");
asm(" .data");
}
-
#endif /* sun3 */
asm("retl");
asm("nop");
}
-
#endif /* NEED_SPARC_TAS_ASM */
#endif /* NEED_I386_TAS_ASM */
-
#endif /* not __GNUC__ */
exit(3);
}
-
#endif /* S_LOCK_TEST */
*
*
* For machines that have test-and-set (TAS) instructions, s_lock.h/.c
- * define the spinlock implementation. This file contains only a stub
- * implementation for spinlocks using SysV semaphores. The semaphore method
+ * define the spinlock implementation. This file contains only a stub
+ * implementation for spinlocks using SysV semaphores. The semaphore method
* is too slow to be very useful :-(
*
*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/spin.c,v 1.4 2001/10/01 18:16:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/spin.c,v 1.5 2001/10/25 05:49:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
/*
* Compute number of spinlocks needed. It would be cleaner to
- * distribute this logic into the affected modules,
- * similar to the way shmem space estimation is handled.
+ * distribute this logic into the affected modules, similar to the
+ * way shmem space estimation is handled.
*
* For now, though, we just need a few spinlocks (10 should be
* plenty) plus one for each LWLock.
/* Note that TAS macros return 0 if *success* */
return !IpcSemaphoreTryLock(lock->semId, lock->sem);
}
-
#endif /* !HAS_TEST_AND_SET */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.38 2001/10/23 02:20:15 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.39 2001/10/25 05:49:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
else
{
-
/*
* Don't actually do the shuffle till we've checked free
* space!
* It doesn't remove unused line pointers! Please don't change this.
* This routine is usable for heap pages only.
*
- * Returns number of unused line pointers on page. If "unused" is not NULL
+ * Returns number of unused line pointers on page. If "unused" is not NULL
* then the unused[] array is filled with indexes of unused line pointers.
*/
int
Offset upper;
/*
- * It's worth the trouble to be more paranoid here than in most places,
- * because we are about to reshuffle data in (what is usually) a shared
- * disk buffer. If we aren't careful then corrupted pointers, lengths,
- * etc could cause us to clobber adjacent disk buffers, spreading the
- * data loss further. So, check everything.
+ * It's worth the trouble to be more paranoid here than in most
+ * places, because we are about to reshuffle data in (what is usually)
+ * a shared disk buffer. If we aren't careful then corrupted
+ * pointers, lengths, etc could cause us to clobber adjacent disk
+ * buffers, spreading the data loss further. So, check everything.
*/
if (pd_lower < (sizeof(PageHeaderData) - sizeof(ItemIdData)) ||
pd_lower > pd_upper ||
}
else
{
- (*lp).lp_len = 0; /* indicate unused & deallocated */
+ (*lp).lp_len = 0; /* indicate unused & deallocated */
}
}
if (space < sizeof(ItemIdData))
return 0;
- space -= sizeof(ItemIdData); /* XXX not always appropriate */
+ space -= sizeof(ItemIdData); /* XXX not always appropriate */
return space;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.87 2001/08/24 14:07:49 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.88 2001/10/25 05:49:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int mdfd_nextFree; /* link to next freelist member, if free */
#ifndef LET_OS_MANAGE_FILESIZE
- struct _MdfdVec *mdfd_chain;/* for large relations */
+ struct _MdfdVec *mdfd_chain; /* for large relations */
#endif
} MdfdVec;
if (status == SM_SUCCESS)
{
char *segpath = (char *) palloc(strlen(path) + 12);
- BlockNumber segno;
+ BlockNumber segno;
for (segno = 1;; segno++)
{
/*
* Note: because caller obtained blocknum by calling mdnblocks, which
* did a seek(SEEK_END), this seek is often redundant and will be
- * optimized away by fd.c. It's not redundant, however, if there is a
- * partial page at the end of the file. In that case we want to try to
- * overwrite the partial page with a full page. It's also not redundant
- * if bufmgr.c had to dump another buffer of the same file to make room
- * for the new page's buffer.
+ * optimized away by fd.c. It's not redundant, however, if there is a
+ * partial page at the end of the file. In that case we want to try
+ * to overwrite the partial page with a full page. It's also not
+ * redundant if bufmgr.c had to dump another buffer of the same file
+ * to make room for the new page's buffer.
*/
if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)
return SM_FAIL;
{
if (nbytes > 0)
{
- int save_errno = errno;
+ int save_errno = errno;
/* Remove the partially-written page */
FileTruncate(v->mdfd_vfd, seekpos);
if (fd < 0)
{
-
/*
* During bootstrap, there are cases where a system relation will
* be accessed (by internal backend processes) before the
/* if not closed already */
if (v->mdfd_vfd >= 0)
{
-
/*
* We sync the file descriptor so that we don't need to reopen
* it at transaction commit to force changes to disk. (This
{
if (v->mdfd_vfd >= 0)
{
-
/*
* We sync the file descriptor so that we don't need to reopen
* it at transaction commit to force changes to disk. (This
if ((nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
{
/*
- * If we are at EOF, return zeroes without complaining.
- * (XXX Is this still necessary/a good idea??)
+ * If we are at EOF, return zeroes without complaining. (XXX Is
+ * this still necessary/a good idea??)
*/
if (nbytes == 0 ||
(nbytes > 0 && mdnblocks(reln) == blocknum))
{
int fd;
MdfdVec *v;
+
#ifndef LET_OS_MANAGE_FILESIZE
- BlockNumber nblocks;
- BlockNumber segno;
+ BlockNumber nblocks;
+ BlockNumber segno;
#endif
fd = _mdfd_getrelnfd(reln);
elog(FATAL, "segment too big in mdnblocks!");
if (nblocks < ((BlockNumber) RELSEG_SIZE))
return (segno * ((BlockNumber) RELSEG_SIZE)) + nblocks;
+
/*
* If segment is exactly RELSEG_SIZE, advance to next one.
*/
if (v->mdfd_chain == (MdfdVec *) NULL)
{
/*
- * Because we pass O_CREAT, we will create the next
- * segment (with zero length) immediately, if the last
- * segment is of length REL_SEGSIZE. This is unnecessary
- * but harmless, and testing for the case would take more
- * cycles than it seems worth.
+ * Because we pass O_CREAT, we will create the next segment
+ * (with zero length) immediately, if the last segment is of
+ * length REL_SEGSIZE. This is unnecessary but harmless, and
+ * testing for the case would take more cycles than it seems
+ * worth.
*/
v->mdfd_chain = _mdfd_openseg(reln, segno, O_CREAT);
if (v->mdfd_chain == (MdfdVec *) NULL)
{
int fd;
MdfdVec *v;
- BlockNumber curnblk;
+ BlockNumber curnblk;
+
#ifndef LET_OS_MANAGE_FILESIZE
- BlockNumber priorblocks;
+ BlockNumber priorblocks;
#endif
/*
*/
curnblk = mdnblocks(reln);
if (nblocks > curnblk)
- return InvalidBlockNumber; /* bogus request */
+ return InvalidBlockNumber; /* bogus request */
if (nblocks == curnblk)
return nblocks; /* no work */
* truncate the K+1st segment to 0 length but keep it. This is
* mainly so that the right thing happens if nblocks==0.
*/
- BlockNumber lastsegblocks = nblocks - priorblocks;
+ BlockNumber lastsegblocks = nblocks - priorblocks;
if (FileTruncate(v->mdfd_vfd, lastsegblocks * BLCKSZ) < 0)
return InvalidBlockNumber;
int
mdabort()
{
-
/*
* We don't actually have to do anything here. fd.c will discard
* fsync-needed bits in its AtEOXact_Files() routine.
{
MdfdVec *v;
int fd;
+
#ifndef LET_OS_MANAGE_FILESIZE
- BlockNumber segno;
- BlockNumber i;
+ BlockNumber segno;
+ BlockNumber i;
#endif
fd = _mdfd_getrelnfd(reln);
if (v->mdfd_chain == (MdfdVec *) NULL)
{
-
/*
* We will create the next segment only if the target block is
* within it. This prevents Sorcerer's Apprentice syndrome if
{
char *path;
int fd;
+
#ifndef LET_OS_MANAGE_FILESIZE
- BlockNumber segno;
+ BlockNumber segno;
#endif
path = relpath(rnode);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.27 2001/10/05 17:28:12 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.28 2001/10/25 05:49:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
MMRelTag rtag;
MMRelHashEntry *rentry;
- BlockNumber nblocks;
+ BlockNumber nblocks;
if (reln->rd_rel->relisshared)
rtag.mmrt_dbid = (Oid) 0;
return size;
}
-
#endif /* STABLE_MEMORY_STORAGE */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.53 2001/09/29 04:02:25 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.54 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int (*smgr_create) (Relation reln);
int (*smgr_unlink) (RelFileNode rnode);
int (*smgr_extend) (Relation reln, BlockNumber blocknum,
- char *buffer);
+ char *buffer);
int (*smgr_open) (Relation reln);
int (*smgr_close) (Relation reln);
int (*smgr_read) (Relation reln, BlockNumber blocknum,
- char *buffer);
+ char *buffer);
int (*smgr_write) (Relation reln, BlockNumber blocknum,
- char *buffer);
+ char *buffer);
int (*smgr_flush) (Relation reln, BlockNumber blocknum,
- char *buffer);
+ char *buffer);
int (*smgr_blindwrt) (RelFileNode rnode, BlockNumber blkno,
- char *buffer, bool dofsync);
+ char *buffer, bool dofsync);
int (*smgr_markdirty) (Relation reln, BlockNumber blkno);
int (*smgr_blindmarkdirty) (RelFileNode, BlockNumber blkno);
- BlockNumber (*smgr_nblocks) (Relation reln);
- BlockNumber (*smgr_truncate) (Relation reln, BlockNumber nblocks);
+ BlockNumber (*smgr_nblocks) (Relation reln);
+ BlockNumber (*smgr_truncate) (Relation reln, BlockNumber nblocks);
int (*smgr_commit) (void); /* may be NULL */
int (*smgr_abort) (void); /* may be NULL */
int (*smgr_sync) (void);
{mminit, mmshutdown, mmcreate, mmunlink, mmextend, mmopen, mmclose,
mmread, mmwrite, mmflush, mmblindwrt, mmmarkdirty, mmblindmarkdirty,
mmnblocks, NULL, mmcommit, mmabort},
-
#endif
};
false, /* main memory */
#endif
};
-
#endif
static int NSmgr = lengthof(smgrsw);
BlockNumber
smgrnblocks(int16 which, Relation reln)
{
- BlockNumber nblocks;
+ BlockNumber nblocks;
nblocks = (*(smgrsw[which].smgr_nblocks)) (reln);
+
/*
* NOTE: if a relation ever did grow to 2^32-1 blocks, this code would
* fail --- but that's a good thing, because it would stop us from
BlockNumber
smgrtruncate(int16 which, Relation reln, BlockNumber nblocks)
{
- BlockNumber newblks;
+ BlockNumber newblks;
newblks = nblocks;
if (smgrsw[which].smgr_truncate)
{
/*
* Tell the free space map to forget anything it may have stored
- * for the about-to-be-deleted blocks. We want to be sure it won't
- * return bogus block numbers later on.
+ * for the about-to-be-deleted blocks. We want to be sure it
+ * won't return bogus block numbers later on.
*/
MultiRecordFreeSpace(&reln->rd_node,
nblocks, MaxBlockNumber,
return smgrwo[smgrno];
}
-
#endif
void
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.44 2001/03/22 06:16:17 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.45 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
switch (dest)
{
- case Remote:
+ case Remote:
return printtup_create_DR(false);
case RemoteInternal:
{
switch (dest)
{
- case RemoteInternal:
- case Remote:
+ case RemoteInternal:
+ case Remote:
/*
* tell the fe that we saw an empty query string
*/
- pq_putbytes("I", 2);/* note we send I and \0 */
+ pq_putbytes("I", 2); /* note we send I and \0 */
break;
case Debug:
{
switch (dest)
{
- case RemoteInternal:
- case Remote:
+ case RemoteInternal:
+ case Remote:
if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 2)
pq_putbytes("Z", 1);
/* Flush output at end of cycle in any case. */
{
switch (operation)
{
- case CMD_INSERT:
+ case CMD_INSERT:
if (tuples > 1)
lastoid = InvalidOid;
sprintf(CommandInfo, " %u %u", lastoid, tuples);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.49 2001/06/01 15:45:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.50 2001/10/25 05:49:43 momjian Exp $
*
* NOTES
* This cruft is the server side of PQfn.
* each fastpath call as a separate transaction command, and so the
* cached data could never actually have been reused. If it had worked
* as intended, it would have had problems anyway with dangling references
- * in the FmgrInfo struct. So, forget about caching and just repeat the
- * syscache fetches on each usage. They're not *that* expensive.
+ * in the FmgrInfo struct. So, forget about caching and just repeat the
+ * syscache fetches on each usage. They're not *that* expensive.
*/
struct fp_info
{
* correct value until we are about to return with a good struct
* fp_info, since we can be interrupted (i.e., with an elog(ERROR,
* ...)) at any time. [No longer really an issue since we don't save
- * the struct fp_info across transactions anymore, but keep it anyway.]
+ * the struct fp_info across transactions anymore, but keep it
+ * anyway.]
*/
MemSet((char *) fip, 0, sizeof(struct fp_info));
fip->funcid = InvalidOid;
return EOF;
/*
- * There used to be a lame attempt at caching lookup info here.
- * Now we just do the lookups on every call.
+ * There used to be a lame attempt at caching lookup info here. Now we
+ * just do the lookups on every call.
*/
fip = &my_fp;
fetch_fp_info(fid, fip);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.238 2001/10/21 03:25:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.239 2001/10/25 05:49:43 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
extern int optind;
extern char *optarg;
-char *debug_query_string; /* used by pgmonitor */
+char *debug_query_string; /* used by pgmonitor */
/* Note: whereToSendOutput is initialized for the bootstrap/standalone case */
CommandDest whereToSendOutput = Debug;
#else
int UseNewLine = 0; /* Use EOF as query delimiters */
-
#endif /* TCOP_DONTUSENEWLINE */
/*
{
if (UseNewLine)
{
-
/*
* if we are using \n as a delimiter, then read characters
* until the \n.
}
else
{
-
/*
* otherwise read characters until EOF.
*/
switch (qtype)
{
-
/*
* 'Q': user entered a query
*/
if (!allowit)
{
-
/*
* the EndCommand() stuff is to tell the frontend that the
* command ended. -cim 6/1/90
if (querytree->commandType == CMD_UTILITY)
{
-
/*
* process utility functions (create, destroy, etc..)
*/
}
else
{
-
/*
* process a plannable query.
*/
if (xact_started)
finish_xact_command();
- debug_query_string = NULL; /* used by pgmonitor */
+ debug_query_string = NULL; /* used by pgmonitor */
}
/*
"\n\tThe Postmaster has informed me that some other backend"
"\n\tdied abnormally and possibly corrupted shared memory."
"\n\tI have rolled back the current transaction and am"
- "\n\tgoing to terminate your database system connection and exit."
+ "\n\tgoing to terminate your database system connection and exit."
"\n\tPlease reconnect to the database system and repeat your query.");
/*
bool secure;
int errs = 0;
GucContext ctx;
- char *tmp;
+ char *tmp;
int firstchar;
StringInfo parser_input;
if (!potential_DataDir)
{
fprintf(stderr, "%s does not know where to find the database system "
- "data. You must specify the directory that contains the "
- "database system either by specifying the -D invocation "
- "option or by setting the PGDATA environment variable.\n\n",
+ "data. You must specify the directory that contains the "
+ "database system either by specifying the -D invocation "
+ "option or by setting the PGDATA environment variable.\n\n",
argv[0]);
proc_exit(1);
}
pqsignal(SIGHUP, SigHupHandler); /* set flag to read config file */
pqsignal(SIGINT, QueryCancelHandler); /* cancel current query */
pqsignal(SIGTERM, die); /* cancel current query and exit */
- pqsignal(SIGQUIT, quickdie);/* hard crash time */
+ pqsignal(SIGQUIT, quickdie); /* hard crash time */
pqsignal(SIGALRM, HandleDeadLock); /* check for deadlock after
* timeout */
* Reset some signals that are accepted by postmaster but not by
* backend
*/
- pqsignal(SIGCHLD, SIG_DFL); /* system() requires this on some platforms */
+ pqsignal(SIGCHLD, SIG_DFL); /* system() requires this on some
+ * platforms */
pqsignal(SIGTTIN, SIG_DFL);
pqsignal(SIGTTOU, SIG_DFL);
pqsignal(SIGCONT, SIG_DFL);
argv[0]);
/*
- * Validate we have been given a reasonable-looking DataDir
- * (if under postmaster, assume postmaster did this already).
+ * Validate we have been given a reasonable-looking DataDir (if
+ * under postmaster, assume postmaster did this already).
*/
ValidatePgVersion(DataDir);
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.238 $ $Date: 2001/10/21 03:25:35 $\n");
+ puts("$Revision: 1.239 $ $Date: 2001/10/25 05:49:43 $\n");
}
/*
for (;;)
{
-
/*
* Release storage left over from prior query cycle, and create a
* new query input buffer in the cleared QueryContext.
*/
switch (firstchar)
{
-
/*
* 'F' indicates a fastpath call.
*/
case 'Q':
if (strspn(parser_input->data, " \t\r\n") == parser_input->len)
{
-
/*
* if there is nothing in the input buffer, don't
* bother trying to parse and execute anything; just
}
else
{
-
/*
* otherwise, process the input string.
*
return val;
}
-
#endif
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.45 2001/10/05 17:28:12 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.46 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* CreateQueryDesc
* ----------------------------------------------------------------
*/
-QueryDesc *
+QueryDesc *
CreateQueryDesc(Query *parsetree,
Plan *plantree,
CommandDest dest)
portal = GetPortalByName(portalName);
if (PortalIsValid(portal))
{
-
/*
* XXX Should we raise an error rather than closing the old
* portal?
intoName = parsetree->into;
if (parsetree->isBinary)
{
-
/*
* For internal format portals, we change Remote
* (externalized form) to RemoteInternal (internalized
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.121 2001/10/18 17:30:15 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.122 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
switch (nodeTag(parsetree))
{
-
/*
* ******************************** transactions ********************************
*
*/
if (stmt->column == NULL)
{
-
/*
* rename relation
*
}
else
{
-
/*
* rename attribute
*/
case T_GrantStmt:
{
- GrantStmt *stmt = (GrantStmt *) parsetree;
+ GrantStmt *stmt = (GrantStmt *) parsetree;
+
commandTag = stmt->is_grant ? "GRANT" : "REVOKE";
set_ps_display(commandTag);
AppendVarray((Varray *) (A), (void *) (V), (CopyingFunct) copyTgString)
#define deleteArr_TgString(A) FreeVarray(A)
-
#endif /* _ARR_TgString_ */
/* -- Defining types and function for Arr_TgElementPtr type -- */
AppendVarray((Varray *) (A), (void *) (V), (CopyingFunct) copyTgElementPtr)
#define deleteArr_TgElementPtr(A) FreeVarray(A)
-
#endif /* _ARR_TgElementPtr_ */
/* -- Defining types and function for Arr_TgNodePtr type -- */
AppendVarray((Varray *) (A), (void *) (V), (CopyingFunct) copyTgNodePtr)
#define deleteArr_TgNodePtr(A) FreeVarray(A)
-
#endif /* _ARR_TgNodePtr_ */
extern Varray *NewVarray(size_t nobj, size_t size);
extern int AppendVarray(Varray * array, void *value, CopyingFunct copy);
-
#endif /* _VARRAY_H_ */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tioga/Attic/tgRecipe.c,v 1.19 2001/03/22 03:59:48 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tioga/Attic/tgRecipe.c,v 1.20 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
XXX Currently, this is done by linear search. Change to using a hash table.
-------------------------------------- */
-TgElement *
+TgElement *
findElemInRecipe(TgRecipe * r, char *elemName)
{
int i;
if (!attnums_initialized)
{
-
/*
* the first time fillTgNode is called, we find out all the
* relevant attribute numbers in a TgNode so subsequent calls are
if (!attnums_initialized)
{
-
/*
* the first time fillTgElement is called, we find out all the
* relevant attribute numbers in a TgElement so subsequent calls
takes a query result in the PortalBuffer containing a Recipe
and converts it to a C TgRecipe strcture
------------------------------------ */
-TgRecipe *
+TgRecipe *
fillTgRecipe(PortalBuffer * pbuf, int tupno)
{
TgRecipe *r;
retrieveRecipe
find the recipe with the given name
------------------------------------ */
-TgRecipe *
+TgRecipe *
retrieveRecipe(char *name)
{
char qbuf[MAX_QBUF_LENGTH];
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: tgRecipe.h,v 1.17 2001/03/22 06:16:17 momjian Exp $
+ * $Id: tgRecipe.h,v 1.18 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*
*
*
+ *
* geo-decls.h */
-
#endif /* TIOGA_FRONTEND */
typedef enum
{
- TG_INGRED,
- TG_EYE,
- TG_RECIPE
+ TG_INGRED,
+ TG_EYE,
+ TG_RECIPE
} TgElemType;
typedef enum
{
- TG_SQL,
- TG_C,
- TG_RECIPE_GRAPH,
- TG_COMPILED
+ TG_SQL,
+ TG_C,
+ TG_RECIPE_GRAPH,
+ TG_COMPILED
} TgSrcLangType;
typedef enum
{
- TG_INGRED_NODE,
- TG_EYE_NODE,
- TG_RECIPE_NODE,
- TG_TEE_NODE /* tee nodes are not stored in the db we
+ TG_INGRED_NODE,
+ TG_EYE_NODE,
+ TG_RECIPE_NODE,
+ TG_TEE_NODE /* tee nodes are not stored in the db we
* create them when we read the recipe
* back */
} TgNodeType;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.64 2001/06/14 01:09:22 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.65 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static AclMode convert_priv_string(text *priv_type_text);
static bool has_table_privilege_cname_cname(char *username, char *relname,
- text *priv_type_text);
+ text *priv_type_text);
static bool has_table_privilege_cname_id(char *username, Oid reloid,
- text *priv_type_text);
+ text *priv_type_text);
static bool has_table_privilege_id_cname(int32 usesysid, char *relname,
- text *priv_type_text);
+ text *priv_type_text);
/*
/*
- * Add or replace an item in an ACL array. The result is a modified copy;
+ * Add or replace an item in an ACL array. The result is a modified copy;
* the input object is not changed.
*
* NB: caller is responsible for having detoasted the input ACL, if needed.
int l;
Assert(strlen(old_privlist) <= strlen(ACL_MODE_STR));
- priv = palloc(strlen(ACL_MODE_STR)+1);
+ priv = palloc(strlen(ACL_MODE_STR) + 1);
if (old_privlist == NULL || old_privlist[0] == '\0')
{
makeAclString(const char *privileges, const char *grantee, char grant_or_revoke)
{
StringInfoData str;
- char *ret;
+ char *ret;
initStringInfo(&str);
{
Name username = PG_GETARG_NAME(0);
Name relname = PG_GETARG_NAME(1);
- text *priv_type_text = PG_GETARG_TEXT_P(2);
+ text *priv_type_text = PG_GETARG_TEXT_P(2);
bool result;
result = has_table_privilege_cname_cname(NameStr(*username),
has_table_privilege_name(PG_FUNCTION_ARGS)
{
Name relname = PG_GETARG_NAME(0);
- text *priv_type_text = PG_GETARG_TEXT_P(1);
+ text *priv_type_text = PG_GETARG_TEXT_P(1);
int32 usesysid;
bool result;
{
Name username = PG_GETARG_NAME(0);
Oid reloid = PG_GETARG_OID(1);
- text *priv_type_text = PG_GETARG_TEXT_P(2);
+ text *priv_type_text = PG_GETARG_TEXT_P(2);
bool result;
result = has_table_privilege_cname_id(NameStr(*username),
has_table_privilege_id(PG_FUNCTION_ARGS)
{
Oid reloid = PG_GETARG_OID(0);
- text *priv_type_text = PG_GETARG_TEXT_P(1);
+ text *priv_type_text = PG_GETARG_TEXT_P(1);
char *relname;
int32 usesysid;
AclMode mode;
elog(ERROR, "has_table_privilege: invalid relation oid %u",
reloid);
- /*
+ /*
* Convert priv_type_text to an AclMode
*/
mode = convert_priv_string(priv_type_text);
- /*
+ /*
* Finally, check for the privilege
*/
result = pg_aclcheck(relname, usesysid, mode);
{
int32 usesysid = PG_GETARG_INT32(0);
Name relname = PG_GETARG_NAME(1);
- text *priv_type_text = PG_GETARG_TEXT_P(2);
+ text *priv_type_text = PG_GETARG_TEXT_P(2);
bool result;
result = has_table_privilege_id_cname(usesysid,
{
int32 usesysid = PG_GETARG_INT32(0);
Oid reloid = PG_GETARG_OID(1);
- text *priv_type_text = PG_GETARG_TEXT_P(2);
- char *relname;
+ text *priv_type_text = PG_GETARG_TEXT_P(2);
+ char *relname;
AclMode mode;
int32 result;
elog(ERROR, "has_table_privilege: invalid relation oid %u",
reloid);
- /*
+ /*
* Convert priv_type_text to an AclMode
*/
mode = convert_priv_string(priv_type_text);
- /*
+ /*
* Finally, check for the privilege
*/
result = pg_aclcheck(relname, usesysid, mode);
static AclMode
convert_priv_string(text *priv_type_text)
{
- char *priv_type = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(priv_type_text)));
+ char *priv_type = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(priv_type_text)));
/*
* Return mode from priv_type string
return ACL_TRIGGER;
elog(ERROR, "has_table_privilege: invalid privilege type %s", priv_type);
+
/*
* We should never get here, but stop the compiler from complaining
*/
usesysid = get_usesysid(username);
/*
- * Make use of has_table_privilege_id_cname.
- * It accepts the arguments we now have.
+ * Make use of has_table_privilege_id_cname. It accepts the arguments
+ * we now have.
*/
return has_table_privilege_id_cname(usesysid, relname, priv_type_text);
}
text *priv_type_text)
{
int32 usesysid;
- char *relname;
+ char *relname;
/*
* Lookup userid based on username
reloid);
/*
- * Make use of has_table_privilege_id_cname.
- * It accepts the arguments we now have.
+ * Make use of has_table_privilege_id_cname. It accepts the arguments
+ * we now have.
*/
return has_table_privilege_id_cname(usesysid, relname, priv_type_text);
}
int32 result;
/*
- * Check relname is valid.
- * This is needed to deal with the case when usename is a superuser
- * in which case pg_aclcheck simply returns ACLCHECK_OK
- * without validating relname
+ * Check relname is valid. This is needed to deal with the case when
+ * usename is a superuser in which case pg_aclcheck simply returns
+ * ACLCHECK_OK without validating relname
*/
tuple = SearchSysCache(RELNAME,
PointerGetDatum(relname),
relname);
ReleaseSysCache(tuple);
- /*
+ /*
* Convert priv_type_text to an AclMode
*/
mode = convert_priv_string(priv_type_text);
- /*
+ /*
* Finally, check for the privilege
*/
result = pg_aclcheck(relname, usesysid, mode);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.70 2001/03/22 03:59:49 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.71 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (arraylen > 0)
{
-
/*
* fixed-length arrays -- these are assumed to be 1-d, 0-based
*/
* lowerIndx[] and upperIndx[]. These are generally just temporaries.
*-----------------------------------------------------------------------------
*/
-ArrayType *
+ArrayType *
array_get_slice(ArrayType *array,
int nSubscripts,
int *upperIndx,
if (arraylen > 0)
{
-
/*
* fixed-length arrays -- currently, cannot slice these because
* parser labels output as being of the fixed-length array type!
* with NULL, which will probably not make him happy.
*-----------------------------------------------------------------------------
*/
-ArrayType *
+ArrayType *
array_set(ArrayType *array,
int nSubscripts,
int *indx,
if (arraylen > 0)
{
-
/*
* fixed-length arrays -- these are assumed to be 1-d, 0-based. We
* cannot extend them, either.
* with NULL, which will probably not make him happy.
*----------------------------------------------------------------------------
*/
-ArrayType *
+ArrayType *
array_set_slice(ArrayType *array,
int nSubscripts,
int *upperIndx,
if (arraylen > 0)
{
-
/*
* fixed-length arrays -- not got round to doing this...
*/
olddatasize = ARR_SIZE(array) - overheadlen;
if (ndim > 1)
{
-
/*
* here we do not need to cope with extension of the array; it
* would be a lot more complicated if we had to do so...
}
else
{
-
/*
* here we must allow for possibility of slice larger than orig
* array
if (ndim > 1)
{
-
/*
* here we do not need to cope with extension of the array; it
* would be a lot more complicated if we had to do so...
* NULL element values are not supported.
*----------
*/
-ArrayType *
+ArrayType *
construct_array(Datum *elems, int nelems,
bool elmbyval, int elmlen, char elmalign)
{
/* -----------------------------------------------------------------------
* ascii.c
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.9 2001/09/06 04:57:29 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.10 2001/10/25 05:49:43 momjian Exp $
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
*
if (enc == PG_LATIN1)
{
-
/*
* ISO-8859-1
*/
}
else if (enc == PG_LATIN2)
{
-
/*
* ISO-8859-2
*/
}
else if (enc == PG_WIN1250)
{
-
/*
* Window CP1250
*/
to_ascii_encname(PG_FUNCTION_ARGS)
{
PG_RETURN_TEXT_P
- (
- encode_to_ascii
- (
- PG_GETARG_TEXT_P_COPY(0),
- pg_char_to_encoding(NameStr(*PG_GETARG_NAME(1)))
- )
- );
+ (
+ encode_to_ascii
+ (
+ PG_GETARG_TEXT_P_COPY(0),
+ pg_char_to_encoding(NameStr(*PG_GETARG_NAME(1)))
+ )
+ );
}
/* ----------
to_ascii_enc(PG_FUNCTION_ARGS)
{
PG_RETURN_TEXT_P
- (
- encode_to_ascii
- (
- PG_GETARG_TEXT_P_COPY(0),
- PG_GETARG_INT32(1)
- )
- );
+ (
+ encode_to_ascii
+ (
+ PG_GETARG_TEXT_P_COPY(0),
+ PG_GETARG_INT32(1)
+ )
+ );
}
/* ----------
to_ascii_default(PG_FUNCTION_ARGS)
{
PG_RETURN_TEXT_P
- (
- encode_to_ascii
- (
- PG_GETARG_TEXT_P_COPY(0),
- GetDatabaseEncoding()
- )
- );
+ (
+ encode_to_ascii
+ (
+ PG_GETARG_TEXT_P_COPY(0),
+ GetDatabaseEncoding()
+ )
+ );
}
-
#endif /* MULTIBYTE */
* workings can be found in the book "Software Solutions in C" by
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.50 2001/03/22 03:59:49 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.51 2001/10/25 05:49:43 momjian Exp $
*/
#include "postgres.h"
#ifdef USE_LOCALE
struct lconv *lconvert = PGLC_localeconv();
-
#endif
#ifdef USE_LOCALE
#ifdef USE_LOCALE
struct lconv *lconvert = PGLC_localeconv();
-
#endif
#ifdef USE_LOCALE
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.31 2001/05/28 21:58:32 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.32 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
char result;
/*
- * An empty input string is converted to \0 (for consistency with charin).
- * If the input is longer than one character, the excess data is silently
- * discarded.
+ * An empty input string is converted to \0 (for consistency with
+ * charin). If the input is longer than one character, the excess data
+ * is silently discarded.
*/
if (VARSIZE(arg1) > VARHDRSZ)
result = *(VARDATA(arg1));
*(VARDATA(result)) = arg1;
}
else
- {
VARATT_SIZEP(result) = VARHDRSZ;
- }
PG_RETURN_TEXT_P(result);
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.62 2001/10/18 17:30:15 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.63 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
date_timestamptz(PG_FUNCTION_ARGS)
{
DateADT dateVal = PG_GETARG_DATEADT(0);
- TimestampTz result;
+ TimestampTz result;
struct tm tt,
*tm = &tt;
time_t utime;
Datum
timestamptz_date(PG_FUNCTION_ARGS)
{
- TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
+ TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
DateADT result;
struct tm tt,
*tm = &tt;
time_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
+
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
TimeTypmod = typmod;
}
- *time = (rint(((double) *time)*TimeScale)/TimeScale);
+ *time = (rint(((double) *time) * TimeScale) / TimeScale);
if (*time >= 86400)
*time -= 86400;
Datum
overlaps_time(PG_FUNCTION_ARGS)
{
-
/*
* The arguments are TimeADT, but we leave them as generic Datums to
* avoid dereferencing nulls (TimeADT is pass-by-reference!)
*/
if (TIMEADT_GT(ts1, ts2))
{
-
/*
* This case is ts1 < te2 OR te1 < te2, which may look redundant
* but in the presence of nulls it's not quite completely so.
}
else
{
-
/*
* For ts1 = ts2 the spec says te1 <> te2 OR te1 = te2, which is a
* rather silly way of saying "true if both are nonnull, else
timetz_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
+
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
Datum
overlaps_timetz(PG_FUNCTION_ARGS)
{
-
/*
* The arguments are TimeTzADT *, but we leave them as generic Datums
* for convenience of notation --- and to avoid dereferencing nulls.
*/
if (TIMETZ_GT(ts1, ts2))
{
-
/*
* This case is ts1 < te2 OR te1 < te2, which may look redundant
* but in the presence of nulls it's not quite completely so.
}
else
{
-
/*
* For ts1 = ts2 the spec says te1 <> te2 OR te1 = te2, which is a
* rather silly way of saying "true if both are nonnull, else
Datum
timestamptz_timetz(PG_FUNCTION_ARGS)
{
- TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
+ TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
TimeTzADT *result;
struct tm tt,
*tm = &tt;
{
DateADT date = PG_GETARG_DATEADT(0);
TimeTzADT *time = PG_GETARG_TIMETZADT_P(1);
- TimestampTz result;
+ TimestampTz result;
result = date * 86400.0 + time->time + time->zone;
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
elog(ERROR, "TIMETZ units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(units))));
+ PointerGetDatum(units))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
default:
elog(ERROR, "TIMETZ units '%s' not supported",
DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(units))));
+ PointerGetDatum(units))));
result = 0;
}
}
else if ((type == RESERV) && (val == DTK_EPOCH))
- {
result = time->time - time->zone;
- }
else
{
elog(ERROR, "TIMETZ units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(units))));
+ PointerGetDatum(units))));
result = 0;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.74 2001/10/20 01:02:18 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.75 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static int DecodeNumber(int flen, char *field,
- int fmask, int *tmask,
- struct tm * tm, double *fsec, int *is2digits);
+ int fmask, int *tmask,
+ struct tm * tm, double *fsec, int *is2digits);
static int DecodeNumberField(int len, char *str,
- int fmask, int *tmask,
- struct tm * tm, double *fsec, int *is2digits);
+ int fmask, int *tmask,
+ struct tm * tm, double *fsec, int *is2digits);
static int DecodeTime(char *str, int fmask, int *tmask,
- struct tm * tm, double *fsec);
+ struct tm * tm, double *fsec);
static int DecodeTimezone(char *str, int *tzp);
static datetkn *datebsearch(char *key, datetkn *base, unsigned int nel);
static int DecodeDate(char *str, int fmask, int *tmask, struct tm * tm);
static int DecodePosixTimezone(char *str, int *val);
-void TrimTrailingZeros(char *str);
+void TrimTrailingZeros(char *str);
int day_tab[2][13] = {
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0},
- {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}};
+{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}};
char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
+"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
- "Thursday", "Friday", "Saturday", NULL};
+"Thursday", "Friday", "Saturday", NULL};
/*****************************************************************************
};
static unsigned int australian_szdatetktbl = sizeof australian_datetktbl /
- sizeof australian_datetktbl[0];
+sizeof australian_datetktbl[0];
static datetkn deltatktbl[] = {
/* text, token, lexval */
{"cent", UNITS, DTK_CENTURY}, /* "century" relative */
{"centuries", UNITS, DTK_CENTURY}, /* "centuries" relative */
{DCENTURY, UNITS, DTK_CENTURY}, /* "century" relative */
- {"d", UNITS, DTK_DAY}, /* "day" relative */
- {DDAY, UNITS, DTK_DAY}, /* "day" relative */
- {"days", UNITS, DTK_DAY}, /* "days" relative */
- {"dec", UNITS, DTK_DECADE}, /* "decade" relative */
- {"decs", UNITS, DTK_DECADE}, /* "decades" relative */
+ {"d", UNITS, DTK_DAY}, /* "day" relative */
+ {DDAY, UNITS, DTK_DAY}, /* "day" relative */
+ {"days", UNITS, DTK_DAY}, /* "days" relative */
+ {"dec", UNITS, DTK_DECADE}, /* "decade" relative */
+ {"decs", UNITS, DTK_DECADE},/* "decades" relative */
{DDECADE, UNITS, DTK_DECADE}, /* "decade" relative */
{"decades", UNITS, DTK_DECADE}, /* "decades" relative */
- {"h", UNITS, DTK_HOUR}, /* "hour" relative */
- {DHOUR, UNITS, DTK_HOUR}, /* "hour" relative */
- {"hours", UNITS, DTK_HOUR}, /* "hours" relative */
- {"hr", UNITS, DTK_HOUR}, /* "hour" relative */
- {"hrs", UNITS, DTK_HOUR}, /* "hours" relative */
+ {"h", UNITS, DTK_HOUR}, /* "hour" relative */
+ {DHOUR, UNITS, DTK_HOUR}, /* "hour" relative */
+ {"hours", UNITS, DTK_HOUR}, /* "hours" relative */
+ {"hr", UNITS, DTK_HOUR}, /* "hour" relative */
+ {"hrs", UNITS, DTK_HOUR}, /* "hours" relative */
{INVALID, RESERV, DTK_INVALID}, /* reserved for invalid time */
- {"m", UNITS, DTK_MINUTE}, /* "minute" relative */
- {"microsecon", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
- {"mil", UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
- {"millennia", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */
- {DMILLENNIUM, UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
- {"millisecon", UNITS, DTK_MILLISEC}, /* relative */
+ {"m", UNITS, DTK_MINUTE}, /* "minute" relative */
+ {"microsecon", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
+ {"mil", UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
+ {"millennia", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */
+ {DMILLENNIUM, UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
+ {"millisecon", UNITS, DTK_MILLISEC}, /* relative */
{"mils", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */
- {"min", UNITS, DTK_MINUTE}, /* "minute" relative */
- {"mins", UNITS, DTK_MINUTE}, /* "minutes" relative */
- {"mins", UNITS, DTK_MINUTE}, /* "minutes" relative */
+ {"min", UNITS, DTK_MINUTE}, /* "minute" relative */
+ {"mins", UNITS, DTK_MINUTE},/* "minutes" relative */
+ {"mins", UNITS, DTK_MINUTE},/* "minutes" relative */
{DMINUTE, UNITS, DTK_MINUTE}, /* "minute" relative */
{"minutes", UNITS, DTK_MINUTE}, /* "minutes" relative */
- {"mon", UNITS, DTK_MONTH}, /* "months" relative */
- {"mons", UNITS, DTK_MONTH}, /* "months" relative */
- {DMONTH, UNITS, DTK_MONTH}, /* "month" relative */
+ {"mon", UNITS, DTK_MONTH}, /* "months" relative */
+ {"mons", UNITS, DTK_MONTH}, /* "months" relative */
+ {DMONTH, UNITS, DTK_MONTH}, /* "month" relative */
{"months", UNITS, DTK_MONTH},
{"ms", UNITS, DTK_MILLISEC},
{"msec", UNITS, DTK_MILLISEC},
{DMILLISEC, UNITS, DTK_MILLISEC},
{"mseconds", UNITS, DTK_MILLISEC},
{"msecs", UNITS, DTK_MILLISEC},
- {"qtr", UNITS, DTK_QUARTER}, /* "quarter" relative */
+ {"qtr", UNITS, DTK_QUARTER},/* "quarter" relative */
{DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative */
{"reltime", IGNORE, 0}, /* pre-v6.1 "Undefined Reltime" */
{"s", UNITS, DTK_SECOND},
{DSECOND, UNITS, DTK_SECOND},
{"seconds", UNITS, DTK_SECOND},
{"secs", UNITS, DTK_SECOND},
- {DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */
- {"timezone", UNITS, DTK_TZ}, /* "timezone" time offset */
- {"timezone_h", UNITS, DTK_TZ_HOUR}, /* timezone hour units */
- {"timezone_m", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */
+ {DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */
+ {"timezone", UNITS, DTK_TZ},/* "timezone" time offset */
+ {"timezone_h", UNITS, DTK_TZ_HOUR}, /* timezone hour units */
+ {"timezone_m", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */
{"undefined", RESERV, DTK_INVALID}, /* pre-v6.1 invalid time */
- {"us", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
+ {"us", UNITS, DTK_MICROSEC},/* "microsecond" relative */
{"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
{DMICROSEC, UNITS, DTK_MICROSEC}, /* "microsecond" relative */
{"useconds", UNITS, DTK_MICROSEC}, /* "microseconds" relative */
void
TrimTrailingZeros(char *str)
{
- int len = strlen(str);
+ int len = strlen(str);
#if 0
/* chop off trailing one to cope with interval rounding */
int fmask = 0,
tmask,
type;
- int ptype = 0; /* "prefix type" for ISO y2001m02d04 format */
+ int ptype = 0; /* "prefix type" for ISO y2001m02d04
+ * format */
int i;
int flen,
val;
int is2digits = FALSE;
int bc = FALSE;
- /* We'll insist on at least all of the date fields,
- * but initialize the remaining fields in case they are not
- * set later...
+ /*
+ * We'll insist on at least all of the date fields, but initialize the
+ * remaining fields in case they are not set later...
*/
*dtype = DTK_DATE;
tm->tm_hour = 0;
tm->tm_min = 0;
tm->tm_sec = 0;
*fsec = 0;
- tm->tm_isdst = -1; /* don't know daylight savings time status apriori */
+ tm->tm_isdst = -1; /* don't know daylight savings time status
+ * apriori */
if (tzp != NULL)
*tzp = 0;
switch (ftype[i])
{
case DTK_DATE:
- /* Previous field was a label for "julian date"?
- * then this should be a julian date with fractional day...
+
+ /*
+ * Previous field was a label for "julian date"? then this
+ * should be a julian date with fractional day...
*/
if (ptype == JULIAN)
{
- char *cp;
- double dt, date, time;
+ char *cp;
+ double dt,
+ date,
+ time;
dt = strtod(field[i], &cp);
if (*cp != '\0')
*dtype = DTK_DATE;
}
- /* Already have a date? Then this might be a POSIX time
- * zone with an embedded dash (e.g. "PST-3" == "EST")
- * - thomas 2000-03-15
+ /*
+ * Already have a date? Then this might be a POSIX time
+ * zone with an embedded dash (e.g. "PST-3" == "EST") -
+ * thomas 2000-03-15
*/
else if ((fmask & DTK_DATE_M) == DTK_DATE_M)
{
tmask = DTK_M(TZ);
}
else if (DecodeDate(field[i], fmask, &tmask, tm) != 0)
- {
return -1;
- }
break;
case DTK_TIME:
if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0)
return -1;
- /* Check upper limit on hours; other limits checked in
+ /*
+ * Check upper limit on hours; other limits checked in
* DecodeTime()
*/
if (tm->tm_hour > 23)
case DTK_NUMBER:
flen = strlen(field[i]);
- /* Was this an "ISO date" with embedded field labels?
- * An example is "y2001m02d04" - thomas 2001-02-04
+ /*
+ * Was this an "ISO date" with embedded field labels? An
+ * example is "y2001m02d04" - thomas 2001-02-04
*/
if (ptype != 0)
{
- char *cp;
- int val;
+ char *cp;
+ int val;
val = strtol(field[i], &cp, 10);
if (*cp != '\0')
return -1;
- switch (ptype) {
+ switch (ptype)
+ {
case YEAR:
tm->tm_year = val;
tmask = DTK_M(ptype);
break;
case JULIAN:
- /* previous field was a label for "julian date"?
- * then this is a julian day with no fractional part
- * (see DTK_DATE for cases involving fractional parts)
+
+ /*
+ * previous field was a label for "julian
+ * date"? then this is a julian day with no
+ * fractional part (see DTK_DATE for cases
+ * involving fractional parts)
*/
j2date(val, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
ptype = 0;
*dtype = DTK_DATE;
}
+
/*
* long numeric string and either no date or no time read
* yet? then interpret as a concatenated date or time...
}
/* otherwise it is a single date/time field... */
else if (DecodeNumber(flen, field[i], fmask, &tmask, tm, fsec, &is2digits) != 0)
- {
return -1;
- }
break;
case DTK_STRING:
case DTK_ISO_TIME:
tmask = 0;
- if ((i < 1) || (i >= (nf-1))
- || (ftype[i-1] != DTK_DATE)
- || (ftype[i+1] != DTK_TIME))
+ if ((i < 1) || (i >= (nf - 1))
+ || (ftype[i - 1] != DTK_DATE)
+ || (ftype[i + 1] != DTK_TIME))
return -1;
break;
if (((fmask & DTK_DATE_M) == DTK_DATE_M)
&& (tzp != NULL) && (!(fmask & DTK_M(TZ))))
{
-
/*
* daylight savings time modifier but no standard timezone?
* then error
int tz;
if (HasCTZSet)
- {
tz = CTimeZone;
- }
else if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
{
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
+
/*
- * Some buggy mktime() implementations may change the year/month/day
- * when given a time right at a DST boundary. To prevent corruption
- * of the caller's data, give mktime() a copy...
+ * Some buggy mktime() implementations may change the
+ * year/month/day when given a time right at a DST boundary. To
+ * prevent corruption of the caller's data, give mktime() a
+ * copy...
*/
struct tm tt,
*tmp = &tt;
/*
* Enough digits to be unequivocal year? Used to test for 4 digits or
* more, but we now test first for a three-digit doy so anything
- * bigger than two digits had better be an explicit year.
- * - thomas 1999-01-09
- * Back to requiring a 4 digit year. We accept a two digit
+ * bigger than two digits had better be an explicit year. - thomas
+ * 1999-01-09 Back to requiring a 4 digit year. We accept a two digit
* year farther down. - thomas 2000-03-28
*/
else if (flen >= 4)
tp = NULL;
if (Australian_timezones)
tp = datebsearch(lowtoken, australian_datetktbl,
- australian_szdatetktbl);
+ australian_szdatetktbl);
if (!tp)
tp = datebsearch(lowtoken, datetktbl, szdatetktbl);
}
{
if (*cp == '.')
{
-
/*
* Got a decimal point? Then assume some sort of
* seconds specification
}
else if (*cp == '\0')
{
-
/*
* Only a signed integer? Then must assume a
* timezone-like usage
&& (strncmp(lowtoken, deltacache[field]->token, TOKMAXLEN) == 0))
tp = deltacache[field];
else
- {
tp = datebsearch(lowtoken, deltatktbl, szdeltatktbl);
- }
deltacache[field] = tp;
if (tp == NULL)
{
sprintf(str, "%02d:%02d", tm->tm_hour, tm->tm_min);
- /* If we have fractional seconds, then include a decimal point
- * We will do up to 6 fractional digits, and we have rounded any inputs
- * to eliminate anything to the right of 6 digits anyway.
- * If there are no fractional seconds, then do not bother printing
- * a decimal point at all. - thomas 2001-09-29
+ /*
+ * If we have fractional seconds, then include a decimal point We will
+ * do up to 6 fractional digits, and we have rounded any inputs to
+ * eliminate anything to the right of 6 digits anyway. If there are no
+ * fractional seconds, then do not bother printing a decimal point at
+ * all. - thomas 2001-09-29
*/
- if (fsec != 0) {
+ if (fsec != 0)
+ {
sprintf((str + strlen(str)), ":%013.10f", sec);
/* chop off trailing pairs of zeros... */
while ((strcmp((str + strlen(str) - 2), "00") == 0)
&& (*(str + strlen(str) - 3) != '.'))
- {
*(str + strlen(str) - 2) = '\0';
- }
}
else
- {
sprintf((str + strlen(str)), ":%02.0f", sec);
- }
if (tzp != NULL)
{
sprintf(str, "%04d-%02d-%02d %02d:%02d",
tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min);
- /* If we have fractional seconds, then include a decimal point
- * We will do up to 6 fractional digits, and we have rounded any inputs
- * to eliminate anything to the right of 6 digits anyway.
- * If there are no fractional seconds, then do not bother printing
- * a decimal point at all. - thomas 2001-09-29
+ /*
+ * If we have fractional seconds, then include a decimal
+ * point We will do up to 6 fractional digits, and we have
+ * rounded any inputs to eliminate anything to the right
+ * of 6 digits anyway. If there are no fractional seconds,
+ * then do not bother printing a decimal point at all. -
+ * thomas 2001-09-29
*/
- if (fsec != 0) {
+ if (fsec != 0)
+ {
sprintf((str + strlen(str)), ":%013.10f", sec);
TrimTrailingZeros(str);
}
else
- {
sprintf((str + strlen(str)), ":%02.0f", sec);
- }
- /* tzp == NULL indicates that we don't want *any* time zone info in the output string.
- * *tzn != NULL indicates that we have alpha time zone info available.
- * tm_isdst != -1 indicates that we have a valid time zone translation.
+ /*
+ * tzp == NULL indicates that we don't want *any* time
+ * zone info in the output string. *tzn != NULL indicates
+ * that we have alpha time zone info available. tm_isdst
+ * != -1 indicates that we have a valid time zone
+ * translation.
*/
if ((tzp != NULL) && (tm->tm_isdst >= 0))
{
sprintf((str + 5), "/%04d %02d:%02d",
tm->tm_year, tm->tm_hour, tm->tm_min);
- /* If we have fractional seconds, then include a decimal point
- * We will do up to 6 fractional digits, and we have rounded any inputs
- * to eliminate anything to the right of 6 digits anyway.
- * If there are no fractional seconds, then do not bother printing
- * a decimal point at all. - thomas 2001-09-29
+ /*
+ * If we have fractional seconds, then include a decimal
+ * point We will do up to 6 fractional digits, and we have
+ * rounded any inputs to eliminate anything to the right
+ * of 6 digits anyway. If there are no fractional seconds,
+ * then do not bother printing a decimal point at all. -
+ * thomas 2001-09-29
*/
- if (fsec != 0) {
+ if (fsec != 0)
+ {
sprintf((str + strlen(str)), ":%013.10f", sec);
TrimTrailingZeros(str);
}
else
- {
sprintf((str + strlen(str)), ":%02.0f", sec);
- }
if ((tzp != NULL) && (tm->tm_isdst >= 0))
{
if (*tzn != NULL)
- {
sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn);
- }
else
{
hour = -(*tzp / 3600);
sprintf((str + 5), ".%04d %02d:%02d",
tm->tm_year, tm->tm_hour, tm->tm_min);
- /* If we have fractional seconds, then include a decimal point
- * We will do up to 6 fractional digits, and we have rounded any inputs
- * to eliminate anything to the right of 6 digits anyway.
- * If there are no fractional seconds, then do not bother printing
- * a decimal point at all. - thomas 2001-09-29
+ /*
+ * If we have fractional seconds, then include a decimal
+ * point We will do up to 6 fractional digits, and we have
+ * rounded any inputs to eliminate anything to the right
+ * of 6 digits anyway. If there are no fractional seconds,
+ * then do not bother printing a decimal point at all. -
+ * thomas 2001-09-29
*/
- if (fsec != 0) {
+ if (fsec != 0)
+ {
sprintf((str + strlen(str)), ":%013.10f", sec);
TrimTrailingZeros(str);
}
else
- {
sprintf((str + strlen(str)), ":%02.0f", sec);
- }
if ((tzp != NULL) && (tm->tm_isdst >= 0))
{
if (*tzn != NULL)
- {
sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn);
- }
else
{
hour = -(*tzp / 3600);
{
sprintf((str + 10), " %02d:%02d", tm->tm_hour, tm->tm_min);
- /* If we have fractional seconds, then include a decimal point
- * We will do up to 6 fractional digits, and we have rounded any inputs
- * to eliminate anything to the right of 6 digits anyway.
- * If there are no fractional seconds, then do not bother printing
- * a decimal point at all. - thomas 2001-09-29
+ /*
+ * If we have fractional seconds, then include a decimal
+ * point We will do up to 6 fractional digits, and we have
+ * rounded any inputs to eliminate anything to the right
+ * of 6 digits anyway. If there are no fractional seconds,
+ * then do not bother printing a decimal point at all. -
+ * thomas 2001-09-29
*/
- if (fsec != 0) {
+ if (fsec != 0)
+ {
sprintf((str + strlen(str)), ":%013.10f", sec);
TrimTrailingZeros(str);
}
else
- {
sprintf((str + strlen(str)), ":%02.0f", sec);
- }
sprintf((str + strlen(str)), " %04d", tm->tm_year);
if ((tzp != NULL) && (tm->tm_isdst >= 0))
{
if (*tzn != NULL)
- {
sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn);
- }
else
{
- /* We have a time zone, but no string version.
- * Use the numeric form, but be sure to include a leading space
- * to avoid formatting something which would be rejected by the
- * date/time parser later. - thomas 2001-10-19
+ /*
+ * We have a time zone, but no string version. Use
+ * the numeric form, but be sure to include a
+ * leading space to avoid formatting something
+ * which would be rejected by the date/time parser
+ * later. - thomas 2001-10-19
*/
hour = -(*tzp / 3600);
min = ((abs(*tzp) / 60) % 60);
} /* EncodeTimeSpan() */
-void ClearDateCache(bool dummy)
+void
+ClearDateCache(bool dummy)
{
- int i;
+ int i;
- for (i=0; i < MAXDATEFIELDS; i++)
+ for (i = 0; i < MAXDATEFIELDS; i++)
datecache[i] = NULL;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.21 2001/07/15 22:48:18 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.22 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
pfree(s);
}
}
-
#endif
/*-------------------------------------------------------------------------
if (typByVal)
{
-
/*
* just compare the two datums. NOTE: just comparing "len" bytes
* will not do the work, because we do not know how these bytes
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/encode.c,v 1.3 2001/09/30 22:03:41 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/encode.c,v 1.4 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
struct pg_encoding
{
- unsigned (*encode_len) (const uint8 *data, unsigned dlen);
- unsigned (*decode_len) (const uint8 *data, unsigned dlen);
- unsigned (*encode) (const uint8 *data, unsigned dlen, uint8 *res);
- unsigned (*decode) (const uint8 *data, unsigned dlen, uint8 *res);
+ unsigned (*encode_len) (const uint8 *data, unsigned dlen);
+ unsigned (*decode_len) (const uint8 *data, unsigned dlen);
+ unsigned (*encode) (const uint8 *data, unsigned dlen, uint8 *res);
+ unsigned (*decode) (const uint8 *data, unsigned dlen, uint8 *res);
};
-static struct pg_encoding * pg_find_encoding(const char *name);
+static struct pg_encoding *pg_find_encoding(const char *name);
/*
* SQL functions.
Datum name = PG_GETARG_DATUM(1);
text *result;
char *namebuf;
- int datalen, resultlen, res;
+ int datalen,
+ resultlen,
+ res;
struct pg_encoding *enc;
datalen = VARSIZE(data) - VARHDRSZ;
text *data = PG_GETARG_TEXT_P(0);
Datum name = PG_GETARG_DATUM(1);
bytea *result;
- char *namebuf;
- int datalen, resultlen, res;
+ char *namebuf;
+ int datalen,
+ resultlen,
+ res;
struct pg_encoding *enc;
datalen = VARSIZE(data) - VARHDRSZ;
};
static unsigned
-hex_encode(const uint8 * src, unsigned len, uint8 * dst)
+hex_encode(const uint8 *src, unsigned len, uint8 *dst)
{
- const uint8 *end = src + len;
+ const uint8 *end = src + len;
while (src < end)
{
static uint8
get_hex(unsigned c)
{
- int res = -1;
+ int res = -1;
if (c > 0 && c < 127)
res = hexlookup[c];
if (res < 0)
elog(ERROR, "Bad hex code: '%c'", c);
- return (uint8)res;
+ return (uint8) res;
}
static unsigned
-hex_decode(const uint8 * src, unsigned len, uint8 * dst)
+hex_decode(const uint8 *src, unsigned len, uint8 *dst)
{
const uint8 *s,
*srcend;
}
static unsigned
-hex_enc_len(const uint8 * src, unsigned srclen)
+hex_enc_len(const uint8 *src, unsigned srclen)
{
return srclen << 1;
}
static unsigned
-hex_dec_len(const uint8 * src, unsigned srclen)
+hex_dec_len(const uint8 *src, unsigned srclen)
{
return srclen >> 1;
}
};
static unsigned
-b64_encode(const uint8 * src, unsigned len, uint8 * dst)
+b64_encode(const uint8 *src, unsigned len, uint8 *dst)
{
uint8 *p,
*lend = dst + 76;
}
static unsigned
-b64_decode(const uint8 * src, unsigned len, uint8 * dst)
+b64_decode(const uint8 *src, unsigned len, uint8 *dst)
{
- const char *srcend = src + len,
+ const char *srcend = src + len,
*s = src;
uint8 *p = dst;
unsigned c;
}
b = 0;
}
- else {
+ else
+ {
b = -1;
if (c > 0 && c < 127)
b = b64lookup[c];
static unsigned
-b64_enc_len(const uint8 * src, unsigned srclen)
+b64_enc_len(const uint8 *src, unsigned srclen)
{
/* 3 bytes will be converted to 4, linefeed after 76 chars */
return (srclen + 2) * 4 / 3 + srclen / (76 * 3 / 4);
}
static unsigned
-b64_dec_len(const uint8 * src, unsigned srclen)
+b64_dec_len(const uint8 *src, unsigned srclen)
{
return (srclen * 3) >> 2;
}
* Escape
* Minimally escape bytea to text.
* De-escape text to bytea.
- *
+ *
* Only two characters are escaped:
* \0 (null) and \\ (backslash)
- *
+ *
* De-escapes \\ and any \### octal
*/
static unsigned
esc_encode(const uint8 *src, unsigned srclen, uint8 *dst)
{
- const uint8 *end = src + srclen;
- uint8 *rp = dst;
- int len = 0;
+ const uint8 *end = src + srclen;
+ uint8 *rp = dst;
+ int len = 0;
while (src < end)
{
static unsigned
esc_decode(const uint8 *src, unsigned srclen, uint8 *dst)
{
- const uint8 *end = src + srclen;
- uint8 *rp = dst;
- int len = 0;
+ const uint8 *end = src + srclen;
+ uint8 *rp = dst;
+ int len = 0;
while (src < end)
{
if (src[0] != '\\')
- {
*rp++ = *src++;
- }
- else if ( src+3 < end &&
- (src[1] >= '0' && src[1] <= '3') &&
- (src[2] >= '0' && src[2] <= '7') &&
- (src[3] >= '0' && src[3] <= '7') )
+ else if (src + 3 < end &&
+ (src[1] >= '0' && src[1] <= '3') &&
+ (src[2] >= '0' && src[2] <= '7') &&
+ (src[3] >= '0' && src[3] <= '7'))
{
- int val;
+ int val;
val = VAL(src[1]);
val <<= 3;
*rp++ = val + VAL(src[3]);
src += 4;
}
- else if ( src+1 < end &&
- (src[1] == '\\') )
+ else if (src + 1 < end &&
+ (src[1] == '\\'))
{
*rp++ = '\\';
src += 2;
else
{
/*
- * One backslash, not followed by ### valid octal.
- * Should never get here, since esc_dec_len does same check.
+ * One backslash, not followed by ### valid octal. Should
+ * never get here, since esc_dec_len does same check.
*/
elog(ERROR, "decode: Bad input string for type bytea");
}
static unsigned
esc_enc_len(const uint8 *src, unsigned srclen)
{
- const uint8 *end = src + srclen;
- int len = 0;
+ const uint8 *end = src + srclen;
+ int len = 0;
while (src < end)
{
static unsigned
esc_dec_len(const uint8 *src, unsigned srclen)
{
- const uint8 *end = src + srclen;
- int len = 0;
+ const uint8 *end = src + srclen;
+ int len = 0;
while (src < end)
{
if (src[0] != '\\')
- {
src++;
- }
- else if ( src+3 < end &&
- (src[1] >= '0' && src[1] <= '3') &&
- (src[2] >= '0' && src[2] <= '7') &&
- (src[3] >= '0' && src[3] <= '7') )
+ else if (src + 3 < end &&
+ (src[1] >= '0' && src[1] <= '3') &&
+ (src[2] >= '0' && src[2] <= '7') &&
+ (src[3] >= '0' && src[3] <= '7'))
{
/*
* backslash + valid octal
*/
src += 4;
}
- else if ( src+1 < end &&
- (src[1] == '\\') )
+ else if (src + 1 < end &&
+ (src[1] == '\\'))
{
/*
* two backslashes = backslash
* Common
*/
-static struct {
+static struct
+{
const char *name;
struct pg_encoding enc;
-} enclist[] = {
- {"hex", { hex_enc_len, hex_dec_len, hex_encode, hex_decode }},
- {"base64", { b64_enc_len, b64_dec_len, b64_encode, b64_decode }},
- {"escape", { esc_enc_len, esc_dec_len, esc_encode, esc_decode }},
- {NULL, { NULL, NULL, NULL, NULL } }
+} enclist[] =
+
+{
+ {
+ "hex",
+ {
+ hex_enc_len, hex_dec_len, hex_encode, hex_decode
+ }
+ },
+ {
+ "base64",
+ {
+ b64_enc_len, b64_dec_len, b64_encode, b64_decode
+ }
+ },
+ {
+ "escape",
+ {
+ esc_enc_len, esc_dec_len, esc_encode, esc_decode
+ }
+ },
+ {
+ NULL,
+ {
+ NULL, NULL, NULL, NULL
+ }
+ }
};
static struct pg_encoding *
pg_find_encoding(const char *name)
{
- int i;
+ int i;
for (i = 0; enclist[i].name; i++)
if (strcasecmp(enclist[i].name, name) == 0)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.74 2001/06/07 00:09:29 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.75 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef atof
extern double atof(const char *p);
-
#endif
#ifndef HAVE_CBRT
#else
#if !defined(nextstep)
extern double cbrt(double x);
-
#endif
#endif /* HAVE_CBRT */
#else
extern double rint(double x);
-
#endif /* HAVE_RINT */
-
#endif /* NeXT check */
static void
CheckFloat4Val(double val)
{
-
/*
* defining unsafe floats's will make float4 and float8 ops faster at
* the cost of safety, of course!
static void
CheckFloat8Val(double val)
{
-
/*
* defining unsafe floats's will make float4 and float8 ops faster at
* the cost of safety, of course!
float4up(PG_FUNCTION_ARGS)
{
float4 arg = PG_GETARG_FLOAT4(0);
+
PG_RETURN_FLOAT4(arg);
}
float8up(PG_FUNCTION_ARGS)
{
float8 arg = PG_GETARG_FLOAT8(0);
+
PG_RETURN_FLOAT8(arg);
}
float4_cmp_internal(float4 a, float4 b)
{
/*
- * We consider all NANs to be equal and larger than any non-NAN.
- * This is somewhat arbitrary; the important thing is to have a
- * consistent sort order.
+ * We consider all NANs to be equal and larger than any non-NAN. This
+ * is somewhat arbitrary; the important thing is to have a consistent
+ * sort order.
*/
if (isnan(a))
{
float8_cmp_internal(float8 a, float8 b)
{
/*
- * We consider all NANs to be equal and larger than any non-NAN.
- * This is somewhat arbitrary; the important thing is to have a
- * consistent sort order.
+ * We consider all NANs to be equal and larger than any non-NAN. This
+ * is somewhat arbitrary; the important thing is to have a consistent
+ * sort order.
*/
if (isnan(a))
{
static float8 *
check_float8_array(ArrayType *transarray, const char *caller)
{
-
/*
* We expect the input to be a 3-element float array; verify that. We
* don't need to use deconstruct_array() since the array data is just
w = TWO52[sx] + x;
return w - TWO52[sx];
}
-
#endif /* !HAVE_RINT */
#ifndef HAVE_CBRT
return isneg ? -tmpres : tmpres;
}
-
#endif /* !HAVE_CBRT */
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.20 2001/10/23 20:12:54 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.21 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
case INTERVALOID:
if (with_typemod)
{
- int fields = typemod >> 16;
- int precision = typemod & 0xFFFF;
+ int fields = typemod >> 16;
+ int precision = typemod & 0xFFFF;
const char *fieldstr;
switch (fields)
/* -----------------------------------------------------------------------
* formatting.c
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.41 2001/09/28 08:09:11 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.42 2001/10/25 05:49:44 momjian Exp $
*
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
*
* Karel Zak
*
- * TODO
- * - better number building (formatting) / parsing, now it isn't
- * ideal code
+ * TODO
+ * - better number building (formatting) / parsing, now it isn't
+ * ideal code
* - use Assert()
* - add support for abstime
* - add support for roman number to standard number conversion
yyyy,
yyy,
yy,
- y,
+ y,
bc,
iw,
ww,
- w,
+ w,
cc,
q,
j,
*/
typedef struct TmToChar
{
- struct tm tm; /* classic 'tm' struct */
- double fsec; /* milliseconds */
- char *tzn; /* timezone */
+ struct tm tm; /* classic 'tm' struct */
+ double fsec; /* milliseconds */
+ char *tzn; /* timezone */
} TmToChar;
#define tmtcTm(_X) (&(_X)->tm)
-#define tmtcTzn(_X) ((_X)->tzn)
+#define tmtcTzn(_X) ((_X)->tzn)
#define tmtcFsec(_X) ((_X)->fsec)
#define ZERO_tm( _X ) \
typedef enum
{
- DCH_A_D,
- DCH_A_M,
- DCH_AD,
- DCH_AM,
- DCH_B_C,
- DCH_BC,
- DCH_CC,
- DCH_DAY,
- DCH_DDD,
- DCH_DD,
- DCH_DY,
- DCH_Day,
- DCH_Dy,
- DCH_D,
- DCH_FX, /* global suffix */
- DCH_HH24,
- DCH_HH12,
- DCH_HH,
- DCH_IW,
- DCH_J,
- DCH_MI,
- DCH_MM,
- DCH_MONTH,
- DCH_MON,
- DCH_MS,
- DCH_Month,
- DCH_Mon,
- DCH_P_M,
- DCH_PM,
- DCH_Q,
- DCH_RM,
- DCH_SSSS,
- DCH_SS,
- DCH_TZ,
- DCH_US,
- DCH_WW,
- DCH_W,
- DCH_Y_YYY,
- DCH_YYYY,
- DCH_YYY,
- DCH_YY,
- DCH_Y,
- DCH_a_d,
- DCH_a_m,
- DCH_ad,
- DCH_am,
- DCH_b_c,
- DCH_bc,
- DCH_cc,
- DCH_day,
- DCH_ddd,
- DCH_dd,
- DCH_dy,
- DCH_d,
- DCH_fx,
- DCH_hh24,
- DCH_hh12,
- DCH_hh,
- DCH_iw,
- DCH_j,
- DCH_mi,
- DCH_mm,
- DCH_month,
- DCH_mon,
- DCH_ms,
- DCH_p_m,
- DCH_pm,
- DCH_q,
- DCH_rm,
- DCH_ssss,
- DCH_ss,
- DCH_tz,
- DCH_us,
- DCH_ww,
- DCH_w,
- DCH_y_yyy,
- DCH_yyyy,
- DCH_yyy,
- DCH_yy,
- DCH_y,
+ DCH_A_D,
+ DCH_A_M,
+ DCH_AD,
+ DCH_AM,
+ DCH_B_C,
+ DCH_BC,
+ DCH_CC,
+ DCH_DAY,
+ DCH_DDD,
+ DCH_DD,
+ DCH_DY,
+ DCH_Day,
+ DCH_Dy,
+ DCH_D,
+ DCH_FX, /* global suffix */
+ DCH_HH24,
+ DCH_HH12,
+ DCH_HH,
+ DCH_IW,
+ DCH_J,
+ DCH_MI,
+ DCH_MM,
+ DCH_MONTH,
+ DCH_MON,
+ DCH_MS,
+ DCH_Month,
+ DCH_Mon,
+ DCH_P_M,
+ DCH_PM,
+ DCH_Q,
+ DCH_RM,
+ DCH_SSSS,
+ DCH_SS,
+ DCH_TZ,
+ DCH_US,
+ DCH_WW,
+ DCH_W,
+ DCH_Y_YYY,
+ DCH_YYYY,
+ DCH_YYY,
+ DCH_YY,
+ DCH_Y,
+ DCH_a_d,
+ DCH_a_m,
+ DCH_ad,
+ DCH_am,
+ DCH_b_c,
+ DCH_bc,
+ DCH_cc,
+ DCH_day,
+ DCH_ddd,
+ DCH_dd,
+ DCH_dy,
+ DCH_d,
+ DCH_fx,
+ DCH_hh24,
+ DCH_hh12,
+ DCH_hh,
+ DCH_iw,
+ DCH_j,
+ DCH_mi,
+ DCH_mm,
+ DCH_month,
+ DCH_mon,
+ DCH_ms,
+ DCH_p_m,
+ DCH_pm,
+ DCH_q,
+ DCH_rm,
+ DCH_ssss,
+ DCH_ss,
+ DCH_tz,
+ DCH_us,
+ DCH_ww,
+ DCH_w,
+ DCH_y_yyy,
+ DCH_yyyy,
+ DCH_yyy,
+ DCH_yy,
+ DCH_y,
/* last */
- _DCH_last_
+ _DCH_last_
} DCH_poz;
typedef enum
{
- NUM_COMMA,
- NUM_DEC,
- NUM_0,
- NUM_9,
- NUM_B,
- NUM_C,
- NUM_D,
- NUM_E,
- NUM_FM,
- NUM_G,
- NUM_L,
- NUM_MI,
- NUM_PL,
- NUM_PR,
- NUM_RN,
- NUM_SG,
- NUM_SP,
- NUM_S,
- NUM_TH,
- NUM_V,
- NUM_b,
- NUM_c,
- NUM_d,
- NUM_e,
- NUM_fm,
- NUM_g,
- NUM_l,
- NUM_mi,
- NUM_pl,
- NUM_pr,
- NUM_rn,
- NUM_sg,
- NUM_sp,
- NUM_s,
- NUM_th,
- NUM_v,
+ NUM_COMMA,
+ NUM_DEC,
+ NUM_0,
+ NUM_9,
+ NUM_B,
+ NUM_C,
+ NUM_D,
+ NUM_E,
+ NUM_FM,
+ NUM_G,
+ NUM_L,
+ NUM_MI,
+ NUM_PL,
+ NUM_PR,
+ NUM_RN,
+ NUM_SG,
+ NUM_SP,
+ NUM_S,
+ NUM_TH,
+ NUM_V,
+ NUM_b,
+ NUM_c,
+ NUM_d,
+ NUM_e,
+ NUM_fm,
+ NUM_g,
+ NUM_l,
+ NUM_mi,
+ NUM_pl,
+ NUM_pr,
+ NUM_rn,
+ NUM_sg,
+ NUM_sp,
+ NUM_s,
+ NUM_th,
+ NUM_v,
/* last */
- _NUM_last_
+ _NUM_last_
} NUM_poz;
/* ----------
{"SSSS", 4, dch_time, DCH_SSSS, TRUE}, /* S */
{"SS", 2, dch_time, DCH_SS, TRUE},
{"TZ", 2, dch_time, DCH_TZ, FALSE}, /* T */
- {"US", 2, dch_time, DCH_US, TRUE}, /* U */
+ {"US", 2, dch_time, DCH_US, TRUE}, /* U */
{"WW", 2, dch_date, DCH_WW, TRUE}, /* W */
{"W", 1, dch_date, DCH_W, TRUE},
{"Y,YYY", 5, dch_date, DCH_Y_YYY, TRUE}, /* Y */
#ifdef DEBUG_TO_FROM_CHAR
static void dump_index(KeyWord *k, int *index);
static void dump_node(FormatNode *node, int max);
-
#endif
static char *get_th(char *num, int type);
static char *str_numth(char *dest, char *num, int type);
-static int strdigits_len(char *str);
+static int strdigits_len(char *str);
static char *str_toupper(char *buff);
static char *str_tolower(char *buff);
}
else if (*str)
{
-
/*
* Special characters '\' and '"'
*/
}
else
{
-
/*
* Remove to output char from input in TO_CHAR
*/
else
{
-
/*
* Skip blank space in FROM_CHAR's input
*/
}
}
-
-#endif /* DEBUG */
+#endif /* DEBUG */
/*****************************************************************************
* Private utils
elog(DEBUG_elog_output, "\n\t\tUsed positions: %d,\n\t\tFree positions: %d",
count, free_i);
}
-
-#endif /* DEBUG */
+#endif /* DEBUG */
/* ----------
* Skip TM / th in FROM_CHAR
static int
strdigits_len(char *str)
{
- char *p = str;
- int len = 0;
-
- while (*p && isdigit((unsigned char ) *p) && len <= DCH_MAX_ITEM_SIZ)
+ char *p = str;
+ int len = 0;
+
+ while (*p && isdigit((unsigned char) *p) && len <= DCH_MAX_ITEM_SIZ)
{
len++;
p++;
static int
dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
{
- char *p_inout = inout;
- struct tm *tm = NULL;
- TmFromChar *tmfc = NULL;
- TmToChar *tmtc = NULL;
+ char *p_inout = inout;
+ struct tm *tm = NULL;
+ TmFromChar *tmfc = NULL;
+ TmToChar *tmtc = NULL;
- if (flag==TO_CHAR)
+ if (flag == TO_CHAR)
{
tmtc = (TmToChar *) data;
tm = tmtcTm(tmtc);
}
}
break;
- case DCH_MS: /* millisecond */
+ case DCH_MS: /* millisecond */
if (flag == TO_CHAR)
{
sprintf(inout, "%03d", (int) rint(tmtc->fsec * 1000));
}
else if (flag == FROM_CHAR)
{
- int len, x;
-
+ int len,
+ x;
+
if (is_next_separator(node))
{
sscanf(inout, "%d", &tmfc->ms);
len = x = strdigits_len(inout);
}
- else
+ else
{
sscanf(inout, "%03d", &tmfc->ms);
x = strdigits_len(inout);
- len = x = x > 3 ? 3 : x;
- }
-
- /* 25 is 0.25 and 250 is 0.25 too;
- * 025 is 0.025 and not 0.25
+ len = x = x > 3 ? 3 : x;
+ }
+
+ /*
+ * 25 is 0.25 and 250 is 0.25 too; 025 is 0.025 and not
+ * 0.25
+ */
+ tmfc->ms *= x == 1 ? 100 :
+ x == 2 ? 10 : 1;
+
+ /*
+ * elog(NOTICE, "X: %d, MS: %d, LEN: %d", x, tmfc->ms,
+ * len);
*/
- tmfc->ms *= x==1 ? 100 :
- x==2 ? 10 : 1;
-
- /* elog(NOTICE, "X: %d, MS: %d, LEN: %d", x, tmfc->ms, len); */
return len - 1 + SKIP_THth(suf);
}
break;
- case DCH_US: /* microsecond */
+ case DCH_US: /* microsecond */
if (flag == TO_CHAR)
{
- sprintf(inout, "%06d", (int)rint(tmtc->fsec * 1000000));
+ sprintf(inout, "%06d", (int) rint(tmtc->fsec * 1000000));
if (S_THth(suf))
str_numth(p_inout, inout, S_TH_TYPE(suf));
if (S_THth(suf))
}
else if (flag == FROM_CHAR)
{
- int len, x;
-
+ int len,
+ x;
+
if (is_next_separator(node))
{
sscanf(inout, "%d", &tmfc->us);
len = x = strdigits_len(inout);
}
- else
+ else
{
sscanf(inout, "%06d", &tmfc->us);
x = strdigits_len(inout);
- len = x = x > 6 ? 6 : x;
- }
-
- tmfc->us *= x==1 ? 100000 :
- x==2 ? 10000 :
- x==3 ? 1000 :
- x==4 ? 100 :
- x==5 ? 10 : 1;
-
- /* elog(NOTICE, "X: %d, US: %d, LEN: %d", x, tmfc->us, len); */
+ len = x = x > 6 ? 6 : x;
+ }
+
+ tmfc->us *= x == 1 ? 100000 :
+ x == 2 ? 10000 :
+ x == 3 ? 1000 :
+ x == 4 ? 100 :
+ x == 5 ? 10 : 1;
+
+ /*
+ * elog(NOTICE, "X: %d, US: %d, LEN: %d", x, tmfc->us,
+ * len);
+ */
return len - 1 + SKIP_THth(suf);
}
break;
case DCH_TZ:
if (flag == TO_CHAR && tmtcTzn(tmtc))
{
- int siz = strlen(tmtcTzn(tmtc));
+ int siz = strlen(tmtcTzn(tmtc));
if (arg == DCH_TZ)
strcpy(inout, tmtcTzn(tmtc));
static int
dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
{
- char buff[DCH_CACHE_SIZE], *p_inout;
- int i, len;
- struct tm *tm = NULL;
- TmFromChar *tmfc = NULL;
- TmToChar *tmtc = NULL;
+ char buff[DCH_CACHE_SIZE],
+ *p_inout;
+ int i,
+ len;
+ struct tm *tm = NULL;
+ TmFromChar *tmfc = NULL;
+ TmToChar *tmtc = NULL;
- if (flag==TO_CHAR)
+ if (flag == TO_CHAR)
{
tmtc = (TmToChar *) data;
tm = tmtcTm(tmtc);
sscanf(inout, "%d,%03d", &cc, &tmfc->yyyy);
tmfc->yyyy += (cc * 1000);
- return strdigits_len(inout) + 3 + SKIP_THth(suf);
+ return strdigits_len(inout) + 3 + SKIP_THth(suf);
}
break;
case DCH_YYYY:
datetime_to_char_body(TmToChar *tmtc, text *fmt)
{
FormatNode *format;
- struct tm *tm = NULL;
- char *str_fmt, *result;
- bool incache;
- int len = VARSIZE(fmt) - VARHDRSZ;
+ struct tm *tm = NULL;
+ char *str_fmt,
+ *result;
+ bool incache;
+ int len = VARSIZE(fmt) - VARHDRSZ;
tm = tmtcTm(tmtc);
tm->tm_wday = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + 1) % 7;
/*
* Allocate new memory if format picture is bigger than static cache
- * and not use cache (call parser always) - incache=FALSE show this variant
+ * and not use cache (call parser always) - incache=FALSE show this
+ * variant
*/
if (len > DCH_CACHE_SIZE)
{
}
else
{
-
/*
* Use cache buffers
*/
DCHCacheEntry *ent;
+
incache = TRUE;
if ((ent = DCH_cache_search(str_fmt)) == NULL)
pfree(result);
else
{
- text *res = (text *) palloc(len + 1 + VARHDRSZ);
+ text *res = (text *) palloc(len + 1 + VARHDRSZ);
memcpy(VARDATA(res), result, len);
VARATT_SIZEP(res) = len + VARHDRSZ;
Datum
timestamp_to_char(PG_FUNCTION_ARGS)
{
- Timestamp dt = PG_GETARG_TIMESTAMP(0);
- text *fmt = PG_GETARG_TEXT_P(1), *res;
- TmToChar tmtc;
- int r = 0;
+ Timestamp dt = PG_GETARG_TIMESTAMP(0);
+ text *fmt = PG_GETARG_TEXT_P(1),
+ *res;
+ TmToChar tmtc;
+ int r = 0;
- if ((VARSIZE(fmt) - VARHDRSZ) <=0 || TIMESTAMP_NOT_FINITE(dt))
+ if ((VARSIZE(fmt) - VARHDRSZ) <= 0 || TIMESTAMP_NOT_FINITE(dt))
PG_RETURN_NULL();
ZERO_tmtc(&tmtc);
if (r != 0)
elog(ERROR, "to_char(): Unable to convert timestamp to tm");
- if (!(res=datetime_to_char_body(&tmtc, fmt)))
+ if (!(res = datetime_to_char_body(&tmtc, fmt)))
PG_RETURN_NULL();
PG_RETURN_TEXT_P(res);
timestamptz_to_char(PG_FUNCTION_ARGS)
{
TimestampTz dt = PG_GETARG_TIMESTAMP(0);
- text *fmt = PG_GETARG_TEXT_P(1), *res;
- TmToChar tmtc;
- int tz, r = 0;
+ text *fmt = PG_GETARG_TEXT_P(1),
+ *res;
+ TmToChar tmtc;
+ int tz,
+ r = 0;
- if ((VARSIZE(fmt) - VARHDRSZ) <=0 || TIMESTAMP_NOT_FINITE(dt))
+ if ((VARSIZE(fmt) - VARHDRSZ) <= 0 || TIMESTAMP_NOT_FINITE(dt))
PG_RETURN_NULL();
ZERO_tmtc(&tmtc);
if (r != 0)
elog(ERROR, "to_char(): Unable to convert timestamp to tm");
- if (!(res=datetime_to_char_body(&tmtc, fmt)))
+ if (!(res = datetime_to_char_body(&tmtc, fmt)))
PG_RETURN_NULL();
PG_RETURN_TEXT_P(res);
Datum
interval_to_char(PG_FUNCTION_ARGS)
{
- Interval *it = PG_GETARG_INTERVAL_P(0);
- text *fmt = PG_GETARG_TEXT_P(1), *res;
- TmToChar tmtc;
+ Interval *it = PG_GETARG_INTERVAL_P(0);
+ text *fmt = PG_GETARG_TEXT_P(1),
+ *res;
+ TmToChar tmtc;
if ((VARSIZE(fmt) - VARHDRSZ) <= 0)
PG_RETURN_NULL();
if (interval2tm(*it, tmtcTm(&tmtc), &tmtcFsec(&tmtc)) != 0)
PG_RETURN_NULL();
- if (!(res=datetime_to_char_body(&tmtc, fmt)))
+ if (!(res = datetime_to_char_body(&tmtc, fmt)))
PG_RETURN_NULL();
PG_RETURN_TEXT_P(res);
Datum
to_timestamp(PG_FUNCTION_ARGS)
{
- text *date_txt = PG_GETARG_TEXT_P(0);
- text *fmt = PG_GETARG_TEXT_P(1);
-
- Timestamp result;
+ text *date_txt = PG_GETARG_TEXT_P(0);
+ text *fmt = PG_GETARG_TEXT_P(1);
+
+ Timestamp result;
FormatNode *format;
- TmFromChar tmfc;
-
- bool incache;
- char *str;
- char *date_str;
- int len, date_len, tz = 0;
- struct tm tm;
- double fsec = 0;
+ TmFromChar tmfc;
+
+ bool incache;
+ char *str;
+ char *date_str;
+ int len,
+ date_len,
+ tz = 0;
+ struct tm tm;
+ double fsec = 0;
ZERO_tm(&tm);
ZERO_tmfc(&tmfc);
/*
* Allocate new memory if format picture is bigger than static
- * cache and not use cache (call parser always) - incache=FALSE
+ * cache and not use cache (call parser always) - incache=FALSE
* show this variant
*/
if (len > DCH_CACHE_SIZE)
}
else
{
-
/*
* Use cache buffers
*/
DCHCacheEntry *ent;
+
incache = 0;
if ((ent = DCH_cache_search(str)) == NULL)
pfree(format);
}
- DEBUG_TMFC(&tmfc);
+ DEBUG_TMFC(&tmfc);
/*
* Convert values that user define for FROM_CHAR
*/
if (tmfc.ssss)
{
- int x = tmfc.ssss;
+ int x = tmfc.ssss;
tm.tm_hour = x / 3600;
x %= 3600;
else if (tmfc.y)
{
-
/*
* 1-digit year: always +2000
*/
DEBUG_TM(&tm);
tz = DetermineLocalTimeZone(&tm);
-
+
if (tm2timestamp(&tm, fsec, &tz, &result) != 0)
elog(ERROR, "to_timestamp(): can't convert 'tm' to timestamp.");
Datum
to_date(PG_FUNCTION_ARGS)
{
-
/*
* Quick hack: since our inputs are just like to_timestamp, hand over
* the whole input info struct...
for (ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++)
{
-
/*
* entry removed via NUM_cache_remove() can be used here
*/
}
else
{
-
/*
* Use cache buffers
*/
}
else
{
-
#endif
/*
#endif
if (IS_LSIGN(Np->Num))
{
-
/*
* Write locale SIGN
*/
(Np->num_curr == Np->num_count + (Np->num_pre ? 1 : 0)
+ (IS_DECIMAL(Np->Num) ? 1 : 0)))
{
-
/*
* Write close BRACKET
*/
if (Np->num_curr < Np->num_pre &&
(Np->Num->zero_start > Np->num_curr || !IS_ZERO(Np->Num)))
{
-
/*
* Write blank space
*/
Np->num_curr < Np->num_pre &&
Np->Num->zero_start <= Np->num_curr)
{
-
/*
* Write ZERO
*/
}
else
{
-
/*
* Write Decinal point
*/
}
else
{
-
/*
* Write Digits
*/
if (!Np->sign_wrote)
{
-
/*
* Set SING position
*/
if (Np->type == FROM_CHAR)
{
-
/*
* Check non-string inout end
*/
*/
if (n->type == NODE_TYPE_ACTION)
{
-
/*
* Create/reading digit/zero/blank/sing
*/
else
Np->inout_p += sprintf(Np->inout_p, "%15s", Np->number_p) - 1;
break;
-
+
case NUM_rn:
if (IS_FILLMODE(Np->Num))
{
}
else
{
-
/*
* Remove to output char from input in TO_CHAR
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.59 2001/10/13 17:40:24 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.60 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
FPle(box1->low.x, box2->high.x)) ||
(FPge(box2->high.x, box1->high.x) &&
FPle(box2->low.x, box1->high.x)))
- &&
- ((FPge(box1->high.y, box2->high.y) &&
- FPle(box1->low.y, box2->high.y)) ||
- (FPge(box2->high.y, box1->high.y) &&
- FPle(box2->low.y, box1->high.y)));
+ &&
+ ((FPge(box1->high.y, box2->high.y) &&
+ FPle(box1->low.y, box2->high.y)) ||
+ (FPge(box2->high.y, box1->high.y) &&
+ FPle(box2->low.y, box1->high.y)));
}
/* box_overleft - is the right edge of box1 to the left of
{
#ifdef ENABLE_LINE_TYPE
char *str = PG_GETARG_CSTRING(0);
-
#endif
LINE *line;
{
#ifdef ENABLE_LINE_TYPE
LINE *line = PG_GETARG_LINE_P(0);
-
#endif
char *result;
/* pairwise check lseg intersections */
for (i = 0; i < p1->npts; i++)
{
- int iprev;
+ int iprev;
if (i > 0)
- iprev = i-1;
+ iprev = i - 1;
else
{
if (!p1->closed)
continue;
- iprev = p1->npts-1; /* include the closure segment */
+ iprev = p1->npts - 1; /* include the closure segment */
}
for (j = 0; j < p2->npts; j++)
{
- int jprev;
+ int jprev;
if (j > 0)
- jprev = j-1;
+ jprev = j - 1;
else
{
if (!p2->closed)
continue;
- jprev = p2->npts-1; /* include the closure segment */
+ jprev = p2->npts - 1; /* include the closure segment */
}
statlseg_construct(&seg1, &p1->p[iprev], &p1->p[i]);
for (i = 0; i < p1->npts; i++)
{
- int iprev;
+ int iprev;
if (i > 0)
- iprev = i-1;
+ iprev = i - 1;
else
{
if (!p1->closed)
continue;
- iprev = p1->npts-1; /* include the closure segment */
+ iprev = p1->npts - 1; /* include the closure segment */
}
for (j = 0; j < p2->npts; j++)
{
- int jprev;
+ int jprev;
if (j > 0)
- jprev = j-1;
+ jprev = j - 1;
else
{
if (!p2->closed)
continue;
- jprev = p2->npts-1; /* include the closure segment */
+ jprev = p2->npts - 1; /* include the closure segment */
}
statlseg_construct(&seg1, &p1->p[iprev], &p1->p[i]);
for (i = 0; i < path->npts; i++)
{
- int iprev;
+ int iprev;
if (i > 0)
- iprev = i-1;
+ iprev = i - 1;
else
{
if (!path->closed)
continue;
- iprev = path->npts-1; /* include the closure segment */
+ iprev = path->npts - 1; /* include the closure segment */
}
result += point_dt(&path->p[iprev], &path->p[i]);
dist_pl_internal(Point *pt, LINE *line)
{
return (line->A * pt->x + line->B * pt->y + line->C) /
- HYPOT(line->A, line->B);
+ HYPOT(line->A, line->B);
}
Datum
*/
for (i = 0; i < path->npts; i++)
{
- int iprev;
+ int iprev;
if (i > 0)
- iprev = i-1;
+ iprev = i - 1;
else
{
if (!path->closed)
continue;
- iprev = path->npts-1; /* include the closure segment */
+ iprev = path->npts - 1; /* include the closure
+ * segment */
}
statlseg_construct(&lseg, &path->p[iprev], &path->p[i]);
#ifdef NOT_USED
LINE *line = PG_GETARG_LINE_P(0);
BOX *box = PG_GETARG_BOX_P(1);
-
#endif
/* think about this one for a while */
#ifdef NOT_USED
LINE *line = PG_GETARG_LINE_P(0);
BOX *box = PG_GETARG_BOX_P(1);
-
#endif
/* think about this one for a while */
#ifdef NOT_USED
POLYGON *polya = PG_GETARG_POLYGON_P(0);
POLYGON *polyb = PG_GETARG_POLYGON_P(1);
-
#endif
elog(ERROR, "poly_distance not implemented");
{
#ifdef NOT_USED
PATH *path = PG_GETARG_PATH_P(0);
-
#endif
elog(ERROR, "path_center not implemented");
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.10 2001/03/22 03:59:51 momjian Exp $";
-
+static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.11 2001/10/25 05:49:44 momjian Exp $";
#endif
#include
{
switch (af)
{
- case AF_INET:
+ case AF_INET:
return (inet_cidr_ntop_ipv4(src, bits, dst, size));
default:
errno = EAFNOSUPPORT;
{
switch (af)
{
- case AF_INET:
+ case AF_INET:
return (inet_net_ntop_ipv4(src, bits, dst, size));
default:
errno = EAFNOSUPPORT;
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_net_pton.c,v 1.12 2000/12/03 20:45:36 tgl Exp $";
-
+static const char rcsid[] = "$Id: inet_net_pton.c,v 1.13 2001/10/25 05:49:44 momjian Exp $";
#endif
#include
{
switch (af)
{
- case AF_INET:
+ case AF_INET:
return size == -1 ?
- inet_net_pton_ipv4(src, dst) :
- inet_cidr_pton_ipv4(src, dst, size);
+ inet_net_pton_ipv4(src, dst) :
+ inet_cidr_pton_ipv4(src, dst, size);
default:
errno = EAFNOSUPPORT;
return (-1);
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.33 2001/09/07 01:33:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.34 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* Do our own scan, rather than relying on sscanf which might be
* broken for long long.
*/
- while (*ptr && isspace((unsigned char) *ptr)) /* skip leading spaces */
+ while (*ptr && isspace((unsigned char) *ptr)) /* skip leading spaces */
ptr++;
if (*ptr == '-') /* handle sign */
sign = -1, ptr++;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.47 2001/10/04 02:15:47 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.48 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static int MatchTextIC(unsigned char *t, int tlen,
unsigned char *p, int plen);
static int MatchBytea(unsigned char *t, int tlen,
- unsigned char *p, int plen);
+ unsigned char *p, int plen);
static text *do_like_escape(text *, text *);
#ifdef MULTIBYTE
static int MBMatchText(unsigned char *t, int tlen,
- unsigned char *p, int plen);
-static int MBMatchTextIC(unsigned char *t, int tlen,
unsigned char *p, int plen);
+static int MBMatchTextIC(unsigned char *t, int tlen,
+ unsigned char *p, int plen);
static text *MB_do_like_escape(text *, text *);
/*--------------------
c2[0] = tolower(c2[0]);
return (c1[0] == c2[0]);
}
-
#endif
#ifdef MULTIBYTE
} while (0)
#define MatchText MBMatchText
-#define MatchTextIC MBMatchTextIC
+#define MatchTextIC MBMatchTextIC
#define do_like_escape MB_do_like_escape
#include "like_match.c"
#undef CHAREQ
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
- result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
+ result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
else
- result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
+ result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
#else
- result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
+ result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
- result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
+ result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
else
- result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
+ result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
#else
- result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
+ result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
*p;
int slen,
plen;
+
s = VARDATA(str);
slen = (VARSIZE(str) - VARHDRSZ);
p = VARDATA(pat);
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
- result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
+ result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
else
- result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
+ result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
#else
- result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
+ result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
- result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
+ result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
else
- result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
+ result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
#else
- result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
+ result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
- result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
+ result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
else
- result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
+ result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
#else
- result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
+ result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
- result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
+ result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
else
- result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE);
+ result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE);
#else
- result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
+ result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
- result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
+ result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
else
- result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
+ result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
#else
- result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
+ result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
- result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
+ result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
else
- result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE);
+ result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE);
#else
- result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
+ result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
- result = do_like_escape(pat, esc);
+ result = do_like_escape(pat, esc);
else
- result = MB_do_like_escape(pat, esc);
+ result = MB_do_like_escape(pat, esc);
#else
result = do_like_escape(pat, esc);
#endif
if (elen == 0)
{
-
/*
* No escape character is wanted. Double any backslashes in the
* pattern to make them act like ordinary characters.
}
else
{
-
/*
* The specified escape must be only a single character.
*/
*/
while (tlen > 0)
{
-
/*
* Optimization to prevent most recursion: don't recurse
* unless first pattern char might match this text char.
}
else if ((*p != '_') && !BYTEA_CHAREQ(t, p))
{
-
/*
* Not the single-character wildcard and no explicit match?
* Then time to quit...
* Copyright (c) 1996-2001, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/like_match.c,v 1.1 2001/10/04 02:15:47 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/like_match.c,v 1.2 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
while (tlen > 0)
{
-
/*
* Optimization to prevent most recursion: don't recurse
* unless first pattern char might match this text char.
}
else if ((*p != '_') && !CHAREQ(t, p))
{
-
/*
* Not the single-character wildcard and no explicit match?
* Then time to quit...
*/
while (tlen > 0)
{
-
/*
* Optimization to prevent most recursion: don't recurse
* unless first pattern char might match this text char.
}
else if ((*p != '_') && !ICHAREQ(t, p))
{
-
/*
* Not the single-character wildcard and no explicit match?
* Then time to quit...
if (elen == 0)
{
-
/*
* No escape character is wanted. Double any backslashes in the
* pattern to make them act like ordinary characters.
}
else
{
-
/*
* The specified escape must be only a single character.
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.22 2001/03/22 03:59:51 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.23 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
#ifdef NOT_USED
Oid o = PG_GETARG_OID(0);
-
#endif
int32 X = PG_GETARG_INT32(1);
bool result;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.90 2001/10/20 01:02:18 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.91 2001/10/25 05:49:44 momjian Exp $
*
* NOTES
*
1, 1, 60, 60,
3600, 3600, 86400, 86400, 604800, 604800,
2592000, 2592000, 31536000, 31536000};
-
#endif
/*
#ifdef NOT_USED
static int correct_unit(char *unit, int *unptr);
static int correct_dir(char *direction, int *signptr);
-
#endif
static int istinterval(char *i_string,
AbsoluteTime
GetCurrentAbsoluteTimeUsec(int *usec)
{
- time_t now;
+ time_t now;
struct timeval tp;
+
#ifdef NOT_USED
struct timezone tpz;
#endif
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
struct tm *tm;
+
#else
struct timeb tb; /* the old V7-ism */
#endif
void
-GetCurrentTimeUsec(struct tm *tm, double *fsec)
+GetCurrentTimeUsec(struct tm * tm, double *fsec)
{
int tz;
int usec;
ftime(&tb);
#endif
- /* If HasCTZSet is true then we have a brute force time zone specified.
- * Go ahead and rotate to the local time zone since we will later bypass
- * any calls which adjust the tm fields.
+ /*
+ * If HasCTZSet is true then we have a brute force time zone
+ * specified. Go ahead and rotate to the local time zone since we will
+ * later bypass any calls which adjust the tm fields.
*/
if (HasCTZSet && (tzp != NULL))
time -= CTimeZone;
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
- if ((! HasCTZSet) && (tzp != NULL))
+ if ((!HasCTZSet) && (tzp != NULL))
{
tx = localtime((time_t *) &time);
#ifdef NO_MKTIME_BEFORE_1970
if (tzp != NULL)
{
- /* We have a brute force time zone per SQL99?
- * Then use it without change
- * since we have already rotated to the time zone.
+ /*
+ * We have a brute force time zone per SQL99? Then use it without
+ * change since we have already rotated to the time zone.
*/
if (HasCTZSet)
{
}
else
{
- *tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
+ *tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
- /* XXX FreeBSD man pages indicate that this should work - tgl 97/04/23 */
+ /*
+ * XXX FreeBSD man pages indicate that this should work - tgl
+ * 97/04/23
+ */
if (tzn != NULL)
{
/*
- * Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
- * contains an error message, which doesn't fit in the buffer
+ * Copy no more than MAXTZLEN bytes of timezone to tzn, in
+ * case it contains an error message, which doesn't fit in
+ * the buffer
*/
StrNCpy(*tzn, tm->tm_zone, MAXTZLEN + 1);
if (strlen(tm->tm_zone) > MAXTZLEN)
}
}
else
- {
tm->tm_isdst = -1;
- }
#elif defined(HAVE_INT_TIMEZONE)
if (tzp != NULL)
{
- /* We have a brute force time zone per SQL99?
- * Then use it without change
- * since we have already rotated to the time zone.
+ /*
+ * We have a brute force time zone per SQL99? Then use it without
+ * change since we have already rotated to the time zone.
*/
if (HasCTZSet)
{
if (tzn != NULL)
{
-
/*
- * Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
- * contains an error message, which doesn't fit in the buffer
+ * Copy no more than MAXTZLEN bytes of timezone to tzn, in
+ * case it contains an error message, which doesn't fit in
+ * the buffer
*/
StrNCpy(*tzn, tzname[tm->tm_isdst], MAXTZLEN + 1);
if (strlen(tzname[tm->tm_isdst]) > MAXTZLEN)
}
}
else
- {
tm->tm_isdst = -1;
- }
#endif
#else /* not (HAVE_TM_ZONE || HAVE_INT_TIMEZONE) */
if (tzp != NULL)
{
- /* We have a brute force time zone per SQL99?
- * Then use it without change
- * since we have already rotated to the time zone.
+ /*
+ * We have a brute force time zone per SQL99? Then use it without
+ * change since we have already rotated to the time zone.
*/
if (HasCTZSet)
{
*tzp = tb.timezone * 60;
/*
- * XXX does this work to get the local timezone string in V7? - tgl
- * 97/03/18
+ * XXX does this work to get the local timezone string in V7?
+ * - tgl 97/03/18
*/
if (tzn != NULL)
{
strftime(*tzn, MAXTZLEN, "%Z", localtime(&now));
- tzn[MAXTZLEN] = '\0'; /* let's just be sure it's null-terminated */
+ tzn[MAXTZLEN] = '\0'; /* let's just be sure it's
+ * null-terminated */
}
}
}
else
- {
tm->tm_isdst = -1;
- }
#endif
return;
break;
case DTK_EPOCH:
- /* Don't bother retaining this as a reserved value,
- * but instead just set to the actual epoch time (1970-01-01) */
+
+ /*
+ * Don't bother retaining this as a reserved value, but
+ * instead just set to the actual epoch time (1970-01-01)
+ */
result = 0;
break;
switch (time)
{
- /* Note that timestamp no longer supports 'invalid'.
- * Retain 'invalid' for abstime for now, but dump it someday.
- */
+ /*
+ * Note that timestamp no longer supports 'invalid'. Retain
+ * 'invalid' for abstime for now, but dump it someday.
+ */
case INVALID_ABSTIME:
strcpy(buf, INVALID);
break;
*/
if (a == INVALID_ABSTIME)
{
- if (b == INVALID_ABSTIME)
- return 0; /* INVALID = INVALID */
- else
- return 1; /* INVALID > non-INVALID */
+ if (b == INVALID_ABSTIME)
+ return 0; /* INVALID = INVALID */
+ else
+ return 1; /* INVALID > non-INVALID */
}
if (b == INVALID_ABSTIME)
- return -1; /* non-INVALID < INVALID */
+ return -1; /* non-INVALID < INVALID */
#if 0
/* CURRENT is no longer stored internally... */
Datum
timestamptz_abstime(PG_FUNCTION_ARGS)
{
- TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
+ TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
AbsoluteTime result;
double fsec;
struct tm tt,
abstime_timestamptz(PG_FUNCTION_ARGS)
{
AbsoluteTime abstime = PG_GETARG_ABSOLUTETIME(0);
- TimestampTz result;
+ TimestampTz result;
switch (abstime)
{
elog(ERROR, "Unable to decode tinterval '%s'", intervalstr);
if (t1 == INVALID_ABSTIME || t2 == INVALID_ABSTIME)
- interval->status = T_INTERVAL_INVAL; /* undefined */
+ interval->status = T_INTERVAL_INVAL; /* undefined */
else
interval->status = T_INTERVAL_VALID;
PG_RETURN_BOOL(false);
if (DatumGetBool(DirectFunctionCall2(abstimeeq,
- AbsoluteTimeGetDatum(i1->data[0]),
- AbsoluteTimeGetDatum(i2->data[0]))) &&
+ AbsoluteTimeGetDatum(i1->data[0]),
+ AbsoluteTimeGetDatum(i2->data[0]))) &&
DatumGetBool(DirectFunctionCall2(abstimeeq,
- AbsoluteTimeGetDatum(i1->data[1]),
- AbsoluteTimeGetDatum(i2->data[1]))))
+ AbsoluteTimeGetDatum(i1->data[1]),
+ AbsoluteTimeGetDatum(i2->data[1]))))
PG_RETURN_BOOL(true);
PG_RETURN_BOOL(false);
}
TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
AbsoluteTime t10,
- t11,
- t20,
- t21;
+ t11,
+ t20,
+ t21;
if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
PG_RETURN_BOOL(false);
TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
AbsoluteTime t10,
- t11,
- t20,
- t21;
+ t11,
+ t20,
+ t21;
if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
PG_RETURN_BOOL(false);
TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
AbsoluteTime t10,
- t11,
- t20,
- t21;
+ t11,
+ t20,
+ t21;
if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
PG_RETURN_BOOL(false);
TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
AbsoluteTime t10,
- t11,
- t20,
- t21;
+ t11,
+ t20,
+ t21;
if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
PG_RETURN_BOOL(false);
if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME)
PG_RETURN_BOOL(false);
rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel,
- TimeIntervalGetDatum(i)));
+ TimeIntervalGetDatum(i)));
PG_RETURN_BOOL((rt != INVALID_RELTIME) && (rt == t));
}
if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
PG_RETURN_BOOL(false);
if (DatumGetBool(DirectFunctionCall2(abstimelt,
- AbsoluteTimeGetDatum(i1->data[1]),
- AbsoluteTimeGetDatum(i2->data[0]))) ||
+ AbsoluteTimeGetDatum(i1->data[1]),
+ AbsoluteTimeGetDatum(i2->data[0]))) ||
DatumGetBool(DirectFunctionCall2(abstimegt,
- AbsoluteTimeGetDatum(i1->data[0]),
- AbsoluteTimeGetDatum(i2->data[1]))))
+ AbsoluteTimeGetDatum(i1->data[0]),
+ AbsoluteTimeGetDatum(i2->data[1]))))
PG_RETURN_BOOL(false);
PG_RETURN_BOOL(true);
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.31 2001/01/24 19:43:14 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.32 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
return namestrcat(n1, NameStr(*n2)); /* n2 can't be any longer
* than n1 */
}
-
#endif
#ifdef NOT_USED
{
return strncmp(NameStr(*n1), NameStr(*n2), NAMEDATALEN);
}
-
#endif
int
}
return 0;
}
-
#endif
int
;
return (uint32) length;
}
-
#endif
* is for IP V4 CIDR notation, but prepared for V6: just
* add the necessary bits where the comments indicate.
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.33 2001/08/27 20:03:38 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.34 2001/10/25 05:49:45 momjian Exp $
*
* Jon Postel RIP 16 Oct 1998
*/
static Datum
text_network(text *src, int type)
{
- int len = VARSIZE(src) - VARHDRSZ;
+ int len = VARSIZE(src) - VARHDRSZ;
- char *str = palloc(len + 1);
- memcpy(str, VARDATA(src), len);
- *(str + len) = '\0';
+ char *str = palloc(len + 1);
- PG_RETURN_INET_P(network_in( str, type));
+ memcpy(str, VARDATA(src), len);
+ *(str + len) = '\0';
+
+ PG_RETURN_INET_P(network_in(str, type));
}
Datum
text_cidr(PG_FUNCTION_ARGS)
{
- return text_network( PG_GETARG_TEXT_P(0), 1);
+ return text_network(PG_GETARG_TEXT_P(0), 1);
}
Datum
text_inet(PG_FUNCTION_ARGS)
{
- return text_network( PG_GETARG_TEXT_P(0), 0);
+ return text_network(PG_GETARG_TEXT_P(0), 0);
}
Datum
inet_set_masklen(PG_FUNCTION_ARGS)
{
- inet *src = PG_GETARG_INET_P(0);
- int bits = PG_GETARG_INT32(1);
- inet *dst;
+ inet *src = PG_GETARG_INET_P(0);
+ int bits = PG_GETARG_INT32(1);
+ inet *dst;
- if ((bits < 0) || (bits > 32)) /* no support for v6 yet */
- {
- elog(ERROR, "set_masklen - invalid value '%d'", bits);
- }
+ if ((bits < 0) || (bits > 32)) /* no support for v6 yet */
+ elog(ERROR, "set_masklen - invalid value '%d'", bits);
/* clone the original data */
- dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct));
+ dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct));
memcpy(dst, src, VARHDRSZ + sizeof(inet_struct));
- ip_bits(dst) = bits;
+ ip_bits(dst) = bits;
PG_RETURN_INET_P(dst);
}
* involving network types.
*
* Currently, inet/cidr values are simply converted to the IPv4 address;
- * this will need more thought when IPv6 is supported too. MAC addresses
+ * this will need more thought when IPv6 is supported too. MAC addresses
* are converted to their numeric equivalent as well (OK since we have a
* double to play in).
*/
{
case INETOID:
case CIDROID:
- {
- inet *ip = DatumGetInetP(value);
-
- if (ip_family(ip) == AF_INET)
- return (double) ip_v4addr(ip);
- else
- /* Go for an IPV6 address here, before faulting out: */
- elog(ERROR, "unknown address family (%d)", ip_family(ip));
- break;
- }
+ {
+ inet *ip = DatumGetInetP(value);
+
+ if (ip_family(ip) == AF_INET)
+ return (double) ip_v4addr(ip);
+ else
+ /* Go for an IPV6 address here, before faulting out: */
+ elog(ERROR, "unknown address family (%d)", ip_family(ip));
+ break;
+ }
case MACADDROID:
- {
- macaddr *mac = DatumGetMacaddrP(value);
- double res;
-
- res = (mac->a << 16) | (mac->b << 8) | (mac->c);
- res *= 256*256*256;
- res += (mac->d << 16) | (mac->e << 8) | (mac->f);
- return res;
- }
+ {
+ macaddr *mac = DatumGetMacaddrP(value);
+ double res;
+
+ res = (mac->a << 16) | (mac->b << 8) | (mac->c);
+ res *= 256 * 256 * 256;
+ res += (mac->d << 16) | (mac->e << 8) | (mac->f);
+ return res;
+ }
}
/*
}
/*
- * return "last" IP on a given network. It's the broadcast address,
+ * return "last" IP on a given network. It's the broadcast address,
* however, masklen has to be set to 32, since
* 192.168.0.255/24 is considered less than 192.168.0.255/32
*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.26 2001/03/22 03:59:52 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.27 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifdef NOT_USED
text *relation_and_attr = PG_GETARG_TEXT_P(1);
-
#endif
if (the_oid == InvalidOid)
*
* 1998 Jan Wieck
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.45 2001/10/13 23:32:33 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.46 2001/10/25 05:49:45 momjian Exp $
*
* ----------
*/
numeric_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
+
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
set_var_from_var(&const_zero, &result);
else
{
-
/*
* And if there are some, we return a copy of ONE with the sign of
* our argument
if (i < arg.ndigits)
{
-
/*
* If i = 0, the value loses all digits, but could round up if its
* first digit is more than 4. If i < 0 the result must be 0.
if (i < 0)
{
- Assert(i == -1);/* better not have added more than 1 digit */
+ Assert(i == -1); /* better not have added more than 1 digit */
Assert(arg.digits > arg.buf);
arg.digits--;
arg.ndigits++;
int result;
/*
- * We consider all NANs to be equal and larger than any non-NAN.
- * This is somewhat arbitrary; the important thing is to have a
- * consistent sort order.
+ * We consider all NANs to be equal and larger than any non-NAN. This
+ * is somewhat arbitrary; the important thing is to have a consistent
+ * sort order.
*/
if (NUMERIC_IS_NAN(num1))
{
/*
* Integer data types all use Numeric accumulators to share code and
- * avoid risk of overflow. For int2 and int4 inputs, Numeric accumulation
+ * avoid risk of overflow. For int2 and int4 inputs, Numeric accumulation
* is overkill for the N and sum(X) values, but definitely not overkill
- * for the sum(X*X) value. Hence, we use int2_accum and int4_accum only
+ * for the sum(X*X) value. Hence, we use int2_accum and int4_accum only
* for stddev/variance --- there are faster special-purpose accumulator
* routines for SUM and AVG of these datatypes.
*/
* the initial condition of the transition data value needs to be NULL. This
* means we can't rely on ExecAgg to automatically insert the first non-null
* data value into the transition data: it doesn't know how to do the type
- * conversion. The upshot is that these routines have to be marked non-strict
+ * conversion. The upshot is that these routines have to be marked non-strict
* and handle substitution of the first non-null input themselves.
*/
printf("\n");
}
-
#endif /* NUMERIC_DEBUG */
static void
add_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
{
-
/*
* Decide on the signs of the two variables what to do
*/
{
if (var2->sign == NUMERIC_POS)
{
-
/*
* Both are positive result = +(ABS(var1) + ABS(var2))
*/
}
else
{
-
/*
* var1 is positive, var2 is negative Must compare absolute
* values
static void
sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
{
-
/*
* Decide on the signs of the two variables what to do
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.45 2001/03/22 03:59:52 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.46 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
return avail;
#endif
}
-
#endif
/*
*val = v;
return 0;
}
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.35 2001/09/23 11:02:01 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.36 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int m,
s1len,
s2len;
+
#ifdef MULTIBYTE
- int bytelen;
+ int bytelen;
#endif
/* Negative len is silently taken as zero */
s2len = 0; /* shouldn't happen */
#ifdef MULTIBYTE
- s1len = pg_mbstrlen_with_len(VARDATA(string1),s1len);
+ s1len = pg_mbstrlen_with_len(VARDATA(string1), s1len);
#endif
if (s1len > len)
s1len = len; /* truncate string1 to len chars */
#ifdef MULTIBYTE
while (m--)
{
- int mlen = pg_mblen(ptr2);
- memcpy(ptr_ret, ptr2, mlen);
- ptr_ret += mlen;
- ptr2 += mlen;
- if (ptr2 == ptr2end) /* wrap around at end of s2 */
- ptr2 = VARDATA(string2);
+ int mlen = pg_mblen(ptr2);
+
+ memcpy(ptr_ret, ptr2, mlen);
+ ptr_ret += mlen;
+ ptr2 += mlen;
+ if (ptr2 == ptr2end) /* wrap around at end of s2 */
+ ptr2 = VARDATA(string2);
}
#else
while (m--)
#ifdef MULTIBYTE
while (s1len--)
{
- int mlen = pg_mblen(ptr1);
- memcpy(ptr_ret, ptr1, mlen);
- ptr_ret += mlen;
- ptr1 += mlen;
+ int mlen = pg_mblen(ptr1);
+
+ memcpy(ptr_ret, ptr1, mlen);
+ ptr_ret += mlen;
+ ptr1 += mlen;
}
#else
while (s1len--)
int m,
s1len,
s2len;
+
#ifdef MULTIBYTE
- int bytelen;
+ int bytelen;
#endif
/* Negative len is silently taken as zero */
s2len = 0; /* shouldn't happen */
#ifdef MULTIBYTE
- s1len = pg_mbstrlen_with_len(VARDATA(string1),s1len);
+ s1len = pg_mbstrlen_with_len(VARDATA(string1), s1len);
#endif
if (s1len > len)
#ifdef MULTIBYTE
while (s1len--)
{
- int mlen = pg_mblen(ptr1);
- memcpy(ptr_ret, ptr1, mlen);
- ptr_ret += mlen;
- ptr1 += mlen;
+ int mlen = pg_mblen(ptr1);
+
+ memcpy(ptr_ret, ptr1, mlen);
+ ptr_ret += mlen;
+ ptr1 += mlen;
}
#else
while (s1len--)
#ifdef MULTIBYTE
while (m--)
{
- int mlen = pg_mblen(ptr2);
- memcpy(ptr_ret, ptr2, mlen);
- ptr_ret += mlen;
- ptr2 += mlen;
- if (ptr2 == ptr2end) /* wrap around at end of s2 */
- ptr2 = VARDATA(string2);
+ int mlen = pg_mblen(ptr2);
+
+ memcpy(ptr_ret, ptr2, mlen);
+ ptr_ret += mlen;
+ ptr2 += mlen;
+ if (ptr2 == ptr2end) /* wrap around at end of s2 */
+ ptr2 = VARDATA(string2);
}
#else
while (m--)
int m;
#ifdef MULTIBYTE
- char **mp;
- int mplen;
- char *p;
- int mblen;
- int len;
+ char **mp;
+ int mplen;
+ char *p;
+ int mblen;
+ int len;
#endif
if ((m = VARSIZE(string) - VARHDRSZ) <= 0 ||
ptr = VARDATA(string);
#ifdef MULTIBYTE
- len = m;
- mp = (char **)palloc(len*sizeof(char *));
+ len = m;
+ mp = (char **) palloc(len * sizeof(char *));
p = ptr;
mplen = 0;
/* build the mb pointer array */
while (len > 0)
{
- mp[mplen++] = p;
- mblen = pg_mblen(p);
- p += mblen;
- len -= mblen;
+ mp[mplen++] = p;
+ mblen = pg_mblen(p);
+ p += mblen;
+ len -= mblen;
}
mplen--;
#else
#ifdef MULTIBYTE
while (m > 0)
{
- int str_len = pg_mblen(ptr);
+ int str_len = pg_mblen(ptr);
+
ptr2 = VARDATA(set);
while (ptr2 <= end2)
{
- int set_len = pg_mblen(ptr2);
+ int set_len = pg_mblen(ptr2);
- if (str_len == set_len &&
- memcmp(ptr,ptr2,str_len) == 0)
+ if (str_len == set_len &&
+ memcmp(ptr, ptr2, str_len) == 0)
break;
- ptr2 += set_len;
+ ptr2 += set_len;
}
if (ptr2 > end2)
break;
while (m > 0)
{
- int str_len;
+ int str_len;
+
end = mp[mplen--];
str_len = pg_mblen(end);
ptr2 = VARDATA(set);
while (ptr2 <= end2)
{
- int set_len = pg_mblen(ptr2);
+ int set_len = pg_mblen(ptr2);
- if (str_len == set_len &&
- memcmp(end,ptr2,str_len) == 0)
+ if (str_len == set_len &&
+ memcmp(end, ptr2, str_len) == 0)
break;
- ptr2 += set_len;
+ ptr2 += set_len;
}
if (ptr2 > end2)
break;
#ifdef MULTIBYTE
while (m > 0)
{
- int str_len = pg_mblen(ptr);
+ int str_len = pg_mblen(ptr);
+
ptr2 = VARDATA(set);
while (ptr2 <= end2)
{
- int set_len = pg_mblen(ptr2);
+ int set_len = pg_mblen(ptr2);
- if (str_len == set_len &&
- memcmp(ptr,ptr2,str_len) == 0)
+ if (str_len == set_len &&
+ memcmp(ptr, ptr2, str_len) == 0)
break;
- ptr2 += set_len;
+ ptr2 += set_len;
}
if (ptr2 > end2)
break;
int m;
#ifdef MULTIBYTE
- char **mp;
- int mplen;
- char *p;
- int mblen;
- int len;
+ char **mp;
+ int mplen;
+ char *p;
+ int mblen;
+ int len;
#endif
if ((m = VARSIZE(string) - VARHDRSZ) <= 0 ||
ptr = VARDATA(string);
#ifdef MULTIBYTE
- len = m;
- mp = (char **)palloc(len*sizeof(char *));
+ len = m;
+ mp = (char **) palloc(len * sizeof(char *));
p = ptr;
mplen = 0;
/* build the mb pointer array */
while (len > 0)
{
- mp[mplen++] = p;
- mblen = pg_mblen(p);
- p += mblen;
- len -= mblen;
+ mp[mplen++] = p;
+ mblen = pg_mblen(p);
+ p += mblen;
+ len -= mblen;
}
mplen--;
#else
#ifdef MULTIBYTE
while (m > 0)
{
- int str_len;
+ int str_len;
+
end = mp[mplen--];
str_len = pg_mblen(end);
ptr2 = VARDATA(set);
while (ptr2 <= end2)
{
- int set_len = pg_mblen(ptr2);
+ int set_len = pg_mblen(ptr2);
- if (str_len == set_len &&
- memcmp(end,ptr2,str_len) == 0)
+ if (str_len == set_len &&
+ memcmp(end, ptr2, str_len) == 0)
break;
- ptr2 += set_len;
+ ptr2 += set_len;
}
if (ptr2 > end2)
break;
tolen,
retlen,
i;
+
#ifdef MULTIBYTE
- int str_len;
- int estimate_len;
- int len;
- int source_len;
- int from_index;
+ int str_len;
+ int estimate_len;
+ int len;
+ int source_len;
+ int from_index;
#endif
if ((m = VARSIZE(string) - VARHDRSZ) <= 0)
#ifdef MULTIBYTE
str_len = VARSIZE(string);
- estimate_len = (tolen*1.0/fromlen + 0.5)*str_len;
- estimate_len = estimate_len>str_len?estimate_len:str_len;
+ estimate_len = (tolen * 1.0 / fromlen + 0.5) * str_len;
+ estimate_len = estimate_len > str_len ? estimate_len : str_len;
result = (text *) palloc(estimate_len);
#else
result = (text *) palloc(VARSIZE(string));
for (i = 0; i < fromlen; i += len)
{
- len = pg_mblen(&from_ptr[i]);
- if (len == source_len &&
- memcmp(source, &from_ptr[i], len) == 0)
- break;
+ len = pg_mblen(&from_ptr[i]);
+ if (len == source_len &&
+ memcmp(source, &from_ptr[i], len) == 0)
+ break;
- from_index++;
+ from_index++;
}
if (i < fromlen)
{
- /* substitute */
- char *p = to_ptr;
- for (i=0;i
- {
- p += pg_mblen(p);
- if (p >= (to_ptr + tolen))
- break;
- }
- if (p < (to_ptr + tolen))
- {
- len = pg_mblen(p);
- memcpy(target, p, len);
- target += len;
- retlen += len;
- }
+ /* substitute */
+ char *p = to_ptr;
+
+ for (i = 0; i < from_index; i++)
+ {
+ p += pg_mblen(p);
+ if (p >= (to_ptr + tolen))
+ break;
+ }
+ if (p < (to_ptr + tolen))
+ {
+ len = pg_mblen(p);
+ memcpy(target, p, len);
+ target += len;
+ retlen += len;
+ }
}
else
{
/* no match, so copy */
- memcpy(target, source, source_len);
- target += source_len;
- retlen += source_len;
+ memcpy(target, source, source_len);
+ target += source_len;
+ retlen += source_len;
}
source += source_len;
* The PostgreSQL locale utils.
*
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.10 2001/09/29 21:16:30 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.11 2001/10/25 05:49:45 momjian Exp $
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
*
static struct lconv CurrentLocaleConv;
-static void PGLC_setlocale(PG_LocaleCategories * lc);
+static void PGLC_setlocale(PG_LocaleCategories *lc);
/*------
- * Frees memory used in PG_LocaleCategories -- this memory is
+ * Frees memory used in PG_LocaleCategories -- this memory is
* allocated in PGLC_current().
*------
*/
void
-PGLC_free_categories(PG_LocaleCategories * lc)
+PGLC_free_categories(PG_LocaleCategories *lc)
{
if (lc->lc_ctype)
pfree(lc->lc_ctype);
if (lc->lc_collate)
pfree(lc->lc_collate);
if (lc->lc_monetary);
- pfree(lc->lc_monetary);
+ pfree(lc->lc_monetary);
#ifdef LC_MESSAGES
if (lc->lc_messages)
pfree(lc->lc_messages);
*------
*/
void
-PGLC_current(PG_LocaleCategories * lc)
+PGLC_current(PG_LocaleCategories *lc)
{
lc->lang = getenv("LANG");
- lc->lc_ctype = pstrdup( setlocale(LC_CTYPE, NULL) );
- lc->lc_numeric = pstrdup( setlocale(LC_NUMERIC, NULL) );
- lc->lc_time = pstrdup( setlocale(LC_TIME, NULL) );
- lc->lc_collate = pstrdup( setlocale(LC_COLLATE, NULL) );
- lc->lc_monetary = pstrdup( setlocale(LC_MONETARY, NULL) );
+ lc->lc_ctype = pstrdup(setlocale(LC_CTYPE, NULL));
+ lc->lc_numeric = pstrdup(setlocale(LC_NUMERIC, NULL));
+ lc->lc_time = pstrdup(setlocale(LC_TIME, NULL));
+ lc->lc_collate = pstrdup(setlocale(LC_COLLATE, NULL));
+ lc->lc_monetary = pstrdup(setlocale(LC_MONETARY, NULL));
#ifdef LC_MESSAGES
- lc->lc_messages = pstrdup( setlocale(LC_MESSAGES, NULL) );
+ lc->lc_messages = pstrdup(setlocale(LC_MESSAGES, NULL));
#endif
}
*------
*/
static void
-PGLC_debug_lc(PG_LocaleCategories * lc)
+PGLC_debug_lc(PG_LocaleCategories *lc)
{
#ifdef LC_MESSAGES
elog(DEBUG, "CURRENT LOCALE ENVIRONMENT:\n\nLANG: \t%s\nLC_CTYPE:\t%s\nLC_NUMERIC:\t%s\nLC_TIME:\t%s\nLC_COLLATE:\t%s\nLC_MONETARY:\t%s\nLC_MESSAGES:\t%s\n",
lc->lc_monetary);
#endif
}
-
#endif
/*------
*------
*/
static void
-PGLC_setlocale(PG_LocaleCategories * lc)
+PGLC_setlocale(PG_LocaleCategories *lc)
{
if (!setlocale(LC_COLLATE, lc->lc_collate))
elog(NOTICE, "pg_setlocale(): 'LC_COLLATE=%s' cannot be honored.",
/* Get formatting information for the external environment */
extlconv = localeconv();
- /* Must copy all values since restoring internal settings may overwrite */
+ /*
+ * Must copy all values since restoring internal settings may
+ * overwrite
+ */
CurrentLocaleConv = *extlconv;
CurrentLocaleConv.currency_symbol = strdup(extlconv->currency_symbol);
CurrentLocaleConv.decimal_point = strdup(extlconv->decimal_point);
CurrentLocaleConvValid = true;
return &CurrentLocaleConv;
}
-
#endif /* USE_LOCALE */
/* ----------
* pg_lzcompress.c -
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.12 2001/10/25 01:29:37 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.13 2001/10/25 05:49:45 momjian Exp $
*
* This is an implementation of LZ compression for PostgreSQL.
* It uses a simple history table and generates 2-3 byte tags
hent = hstart[pglz_hist_idx(input, end)];
while (hent && len < good_match)
{
-
/*
* Be happy with lesser good matches the more entries we visited.
*/
*/
while (dp < dend)
{
-
/*
* If we already exceeded the maximum result size, set no
* compression flag and stop this. But don't check too often.
if (pglz_find_match(hist_start, dp, dend, &match_len,
&match_off, good_match, good_drop))
{
-
/*
* Create the tag and add history entries for all matched
* characters.
}
else
{
-
/*
* No match found. Copy one literal byte.
*/
while (dp < dend)
{
-
/*
* Read one control byte and process the next 8 items.
*/
{
if (ctrl & 1)
{
-
/*
* Otherwise it contains the match length minus 3 and the
* upper 4 bits of the offset. The next following byte
}
else
{
-
/*
* An unset control bit means LITERAL BYTE. So we just
* copy one from INPUT to OUTPUT.
if (dstate->tocopy > 0)
{
-
/*
* Copy one byte from output to output until we did it for the
* length specified by the last tag. Return that byte.
if (dstate->ctrl_count == 0)
{
-
/*
* Get the next control byte if we need to, but check for EOF
* before.
dstate->ctrl_count--;
if (dstate->ctrl & 0x01)
{
-
/*
* Bit is set, so tag is following. Setup copy information and do
* the copy for the first byte as above.
}
else
{
-
/*
* Bit is unset, so literal byte follows.
*/
#include "pgstat.h"
-extern Datum pg_stat_get_numscans(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_tuples_returned(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_tuples_fetched(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_tuples_updated(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_blocks_hit(PG_FUNCTION_ARGS);
-
-extern Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_backend_activity(PG_FUNCTION_ARGS);
-
-extern Datum pg_stat_get_db_numbackends(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_db_xact_rollback(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_db_blocks_fetched(PG_FUNCTION_ARGS);
-extern Datum pg_stat_get_db_blocks_hit(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_numscans(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_tuples_returned(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_tuples_fetched(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_tuples_updated(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_blocks_hit(PG_FUNCTION_ARGS);
+
+extern Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_backend_activity(PG_FUNCTION_ARGS);
+
+extern Datum pg_stat_get_db_numbackends(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_db_xact_rollback(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_db_blocks_fetched(PG_FUNCTION_ARGS);
+extern Datum pg_stat_get_db_blocks_hit(PG_FUNCTION_ARGS);
Datum
pg_stat_get_numscans(PG_FUNCTION_ARGS)
{
- PgStat_StatTabEntry *tabentry;
- Oid relid;
- int64 result;
+ PgStat_StatTabEntry *tabentry;
+ Oid relid;
+ int64 result;
- relid = PG_GETARG_OID(0);
+ relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
- result = (int64)(tabentry->numscans);
+ result = (int64) (tabentry->numscans);
PG_RETURN_INT64(result);
}
Datum
pg_stat_get_tuples_returned(PG_FUNCTION_ARGS)
{
- PgStat_StatTabEntry *tabentry;
- Oid relid;
- int64 result;
+ PgStat_StatTabEntry *tabentry;
+ Oid relid;
+ int64 result;
- relid = PG_GETARG_OID(0);
+ relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
- result = (int64)(tabentry->tuples_returned);
+ result = (int64) (tabentry->tuples_returned);
PG_RETURN_INT64(result);
}
Datum
pg_stat_get_tuples_fetched(PG_FUNCTION_ARGS)
{
- PgStat_StatTabEntry *tabentry;
- Oid relid;
- int64 result;
+ PgStat_StatTabEntry *tabentry;
+ Oid relid;
+ int64 result;
- relid = PG_GETARG_OID(0);
+ relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
- result = (int64)(tabentry->tuples_fetched);
+ result = (int64) (tabentry->tuples_fetched);
PG_RETURN_INT64(result);
}
Datum
pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS)
{
- PgStat_StatTabEntry *tabentry;
- Oid relid;
- int64 result;
+ PgStat_StatTabEntry *tabentry;
+ Oid relid;
+ int64 result;
- relid = PG_GETARG_OID(0);
+ relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
- result = (int64)(tabentry->tuples_inserted);
+ result = (int64) (tabentry->tuples_inserted);
PG_RETURN_INT64(result);
}
Datum
pg_stat_get_tuples_updated(PG_FUNCTION_ARGS)
{
- PgStat_StatTabEntry *tabentry;
- Oid relid;
- int64 result;
+ PgStat_StatTabEntry *tabentry;
+ Oid relid;
+ int64 result;
- relid = PG_GETARG_OID(0);
+ relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
- result = (int64)(tabentry->tuples_updated);
+ result = (int64) (tabentry->tuples_updated);
PG_RETURN_INT64(result);
}
Datum
pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS)
{
- PgStat_StatTabEntry *tabentry;
- Oid relid;
- int64 result;
+ PgStat_StatTabEntry *tabentry;
+ Oid relid;
+ int64 result;
- relid = PG_GETARG_OID(0);
+ relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
- result = (int64)(tabentry->tuples_deleted);
+ result = (int64) (tabentry->tuples_deleted);
PG_RETURN_INT64(result);
}
Datum
pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS)
{
- PgStat_StatTabEntry *tabentry;
- Oid relid;
- int64 result;
+ PgStat_StatTabEntry *tabentry;
+ Oid relid;
+ int64 result;
- relid = PG_GETARG_OID(0);
+ relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
- result = (int64)(tabentry->blocks_fetched);
+ result = (int64) (tabentry->blocks_fetched);
PG_RETURN_INT64(result);
}
Datum
pg_stat_get_blocks_hit(PG_FUNCTION_ARGS)
{
- PgStat_StatTabEntry *tabentry;
- Oid relid;
- int64 result;
+ PgStat_StatTabEntry *tabentry;
+ Oid relid;
+ int64 result;
- relid = PG_GETARG_OID(0);
+ relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
- result = (int64)(tabentry->blocks_hit);
+ result = (int64) (tabentry->blocks_hit);
PG_RETURN_INT64(result);
}
Datum
pg_stat_get_backend_idset(PG_FUNCTION_ARGS)
{
- FmgrInfo *fmgr_info = fcinfo->flinfo;
- int32 result;
+ FmgrInfo *fmgr_info = fcinfo->flinfo;
+ int32 result;
if (fcinfo->resultinfo == NULL ||
!IsA(fcinfo->resultinfo, ReturnSetInfo))
elog(ERROR, "No function memory context in set-function");
fmgr_info->fn_extra = MemoryContextAlloc(fmgr_info->fn_mcxt,
2 * sizeof(int));
- ((int *)(fmgr_info->fn_extra))[0] = 0;
- ((int *)(fmgr_info->fn_extra))[1] = pgstat_fetch_stat_numbackends();
+ ((int *) (fmgr_info->fn_extra))[0] = 0;
+ ((int *) (fmgr_info->fn_extra))[1] = pgstat_fetch_stat_numbackends();
}
- ((int *)(fmgr_info->fn_extra))[0] += 1;
- result = ((int *)(fmgr_info->fn_extra))[0];
+ ((int *) (fmgr_info->fn_extra))[0] += 1;
+ result = ((int *) (fmgr_info->fn_extra))[0];
- if (result > ((int *)(fmgr_info->fn_extra))[1])
+ if (result > ((int *) (fmgr_info->fn_extra))[1])
{
pfree(fmgr_info->fn_extra);
fmgr_info->fn_extra = NULL;
- ((ReturnSetInfo *)(fcinfo->resultinfo))->isDone = ExprEndResult;
+ ((ReturnSetInfo *) (fcinfo->resultinfo))->isDone = ExprEndResult;
PG_RETURN_NULL();
}
- ((ReturnSetInfo *)(fcinfo->resultinfo))->isDone = ExprMultipleResult;
+ ((ReturnSetInfo *) (fcinfo->resultinfo))->isDone = ExprMultipleResult;
PG_RETURN_INT32(result);
}
Datum
pg_stat_get_backend_pid(PG_FUNCTION_ARGS)
{
- PgStat_StatBeEntry *beentry;
- int32 beid;
+ PgStat_StatBeEntry *beentry;
+ int32 beid;
- beid = PG_GETARG_INT32(0);
+ beid = PG_GETARG_INT32(0);
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
PG_RETURN_NULL();
Datum
pg_stat_get_backend_dbid(PG_FUNCTION_ARGS)
{
- PgStat_StatBeEntry *beentry;
- int32 beid;
+ PgStat_StatBeEntry *beentry;
+ int32 beid;
- beid = PG_GETARG_INT32(0);
+ beid = PG_GETARG_INT32(0);
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
PG_RETURN_NULL();
Datum
pg_stat_get_backend_userid(PG_FUNCTION_ARGS)
{
- PgStat_StatBeEntry *beentry;
- int32 beid;
+ PgStat_StatBeEntry *beentry;
+ int32 beid;
- beid = PG_GETARG_INT32(0);
+ beid = PG_GETARG_INT32(0);
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
PG_RETURN_NULL();
Datum
pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
{
- PgStat_StatBeEntry *beentry;
- int32 beid;
- int len;
- text *result;
+ PgStat_StatBeEntry *beentry;
+ int32 beid;
+ int len;
+ text *result;
if (!superuser())
PG_RETURN_NULL();
- beid = PG_GETARG_INT32(0);
+ beid = PG_GETARG_INT32(0);
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
PG_RETURN_NULL();
Datum
pg_stat_get_db_numbackends(PG_FUNCTION_ARGS)
{
- PgStat_StatDBEntry *dbentry;
- Oid dbid;
- int32 result;
+ PgStat_StatDBEntry *dbentry;
+ Oid dbid;
+ int32 result;
- dbid = PG_GETARG_OID(0);
+ dbid = PG_GETARG_OID(0);
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0;
else
- result = (int32)(dbentry->n_backends);
+ result = (int32) (dbentry->n_backends);
PG_RETURN_INT32(result);
}
Datum
pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS)
{
- PgStat_StatDBEntry *dbentry;
- Oid dbid;
- int64 result;
+ PgStat_StatDBEntry *dbentry;
+ Oid dbid;
+ int64 result;
- dbid = PG_GETARG_OID(0);
+ dbid = PG_GETARG_OID(0);
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0;
else
- result = (int64)(dbentry->n_xact_commit);
+ result = (int64) (dbentry->n_xact_commit);
PG_RETURN_INT64(result);
}
Datum
pg_stat_get_db_xact_rollback(PG_FUNCTION_ARGS)
{
- PgStat_StatDBEntry *dbentry;
- Oid dbid;
- int64 result;
+ PgStat_StatDBEntry *dbentry;
+ Oid dbid;
+ int64 result;
- dbid = PG_GETARG_OID(0);
+ dbid = PG_GETARG_OID(0);
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0;
else
- result = (int64)(dbentry->n_xact_rollback);
+ result = (int64) (dbentry->n_xact_rollback);
PG_RETURN_INT64(result);
}
Datum
pg_stat_get_db_blocks_fetched(PG_FUNCTION_ARGS)
{
- PgStat_StatDBEntry *dbentry;
- Oid dbid;
- int64 result;
+ PgStat_StatDBEntry *dbentry;
+ Oid dbid;
+ int64 result;
- dbid = PG_GETARG_OID(0);
+ dbid = PG_GETARG_OID(0);
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0;
else
- result = (int64)(dbentry->n_blocks_fetched);
+ result = (int64) (dbentry->n_blocks_fetched);
PG_RETURN_INT64(result);
}
Datum
pg_stat_get_db_blocks_hit(PG_FUNCTION_ARGS)
{
- PgStat_StatDBEntry *dbentry;
- Oid dbid;
- int64 result;
+ PgStat_StatDBEntry *dbentry;
+ Oid dbid;
+ int64 result;
- dbid = PG_GETARG_OID(0);
+ dbid = PG_GETARG_OID(0);
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0;
else
- result = (int64)(dbentry->n_blocks_hit);
+ result = (int64) (dbentry->n_blocks_hit);
PG_RETURN_INT64(result);
}
-
-
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/quote.c,v 1.4 2001/03/22 03:59:53 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/quote.c,v 1.5 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
return result;
}
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.36 2001/03/22 03:59:53 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.37 2001/10/25 05:49:45 momjian Exp $
*
* Alistair Crooks added the code for the regex caching
* agc - cached the regular expressions used - there's a good chance
regcomp_result = pg95_regcomp(&rev[oldest].cre_re, re, cflags);
if (regcomp_result == 0)
{
-
/*
* use malloc/free for the cre_s field because the storage has to
* persist across transactions
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.63 2001/08/21 16:36:04 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.64 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Oid searchOid;
searchOid = DatumGetObjectId(DirectFunctionCall1(oidin,
- CStringGetDatum(pro_name_or_oid)));
+ CStringGetDatum(pro_name_or_oid)));
result = (RegProcedure) GetSysCacheOid(PROCOID,
- ObjectIdGetDatum(searchOid),
+ ObjectIdGetDatum(searchOid),
0, 0, 0);
if (!RegProcedureIsValid(result))
elog(ERROR, "No procedure with oid %s", pro_name_or_oid);
* Portions Copyright (c) 2000-2001, PostgreSQL Global Development Group
* Copyright 1999 Jan Wieck
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.28 2001/10/06 23:21:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.29 2001/10/25 05:49:45 momjian Exp $
*
* ----------
*/
*/
for (i = 0; i < qkey.nkeypairs; i++)
{
-
/*
* We can implement MATCH PARTIAL by excluding this column from
* the query if it is null. Simple! Unfortunately, the
qualsep = "WHERE";
for (i = 0; i < qkey.nkeypairs; i++)
{
-
/*
* MATCH - only change columns
* corresponding to changed columns in pk_rel's key
defval = NULL;
for (i = 0; i < qkey.nkeypairs && defval != NULL; i++)
{
-
/*
* For each key attribute lookup the tuple constructor
* for a corresponding default value
if (defval[j].adnum ==
qkey.keypair[i][RI_KEYPAIR_FK_IDX])
{
-
/*
* That's the one - push the expression from
* defval.adbin into the plan's targetlist
qualsep = "WHERE";
for (i = 0; i < qkey.nkeypairs; i++)
{
-
/*
* MATCH - only change columns
* corresponding to changed columns in pk_rel's key
defval = NULL;
for (i = 0; i < qkey.nkeypairs && defval != NULL; i++)
{
-
/*
* MATCH - only change columns
* corresponding to changed columns in pk_rel's key.
!ri_OneKeyEqual(pk_rel, i, old_row,
new_row, &qkey, RI_KEYPAIR_PK_IDX))
{
-
/*
* For each key attribute lookup the tuple
* constructor for a corresponding default value
if (defval[j].adnum ==
qkey.keypair[i][RI_KEYPAIR_FK_IDX])
{
-
/*
* That's the one - push the expression
* from defval.adbin into the plan's
switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]))
{
-
/*
* MATCH
*/
for (i = 0; i < key->nkeypairs; i++)
{
-
/*
* Get one attributes oldvalue. If it is NULL - they're not equal.
*/
keys_unequal = true;
for (i = 0; keys_unequal && i < key->nkeypairs; i++)
{
-
/*
* Get one attributes oldvalue. If it is NULL - they're not equal.
*/
CharGetDatum('b'));
if (!HeapTupleIsValid(opr_tup))
elog(ERROR,
- "ri_AttributesEqual(): cannot find '=' operator for type %u",
+ "ri_AttributesEqual(): cannot find '=' operator for type %u",
typeid);
opr_proc = ((Form_pg_operator) GETSTRUCT(opr_tup))->oprcode;
ReleaseSysCache(opr_tup);
/*
* Since fmgr_info could fail, call it *before* creating the
- * hashtable entry --- otherwise we could elog leaving an incomplete
- * entry in the hashtable. Also, because this will be a permanent
- * table entry, we must make sure any subsidiary structures of the
- * fmgr record are kept in TopMemoryContext.
+ * hashtable entry --- otherwise we could elog leaving an
+ * incomplete entry in the hashtable. Also, because this will be
+ * a permanent table entry, we must make sure any subsidiary
+ * structures of the fmgr record are kept in TopMemoryContext.
*/
fmgr_info_cxt(opr_proc, &finfo, TopMemoryContext);
* back to source text
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.85 2001/10/08 19:55:07 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.86 2001/10/25 05:49:45 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
List *rtable; /* List of RangeTblEntry nodes */
List *namespace; /* List of joinlist items (RangeTblRef and
* JoinExpr nodes) */
-} deparse_namespace;
+} deparse_namespace;
/* ----------
static void get_setop_query(Node *setOp, Query *query,
deparse_context *context, bool toplevel);
static void get_rule_sortgroupclause(SortClause *srt, List *tlist,
- bool force_colno,
- deparse_context *context);
+ bool force_colno,
+ deparse_context *context);
static void get_names_for_var(Var *var, deparse_context *context,
char **refname, char **attname);
static bool get_alias_for_case(CaseExpr *caseexpr, deparse_context *context,
static void get_from_clause_item(Node *jtnode, Query *query,
deparse_context *context);
static void get_opclass_name(Oid opclass, Oid actual_datatype,
- StringInfo buf);
+ StringInfo buf);
static bool tleIsArrayAssign(TargetEntry *tle);
static char *quote_identifier(char *ident);
static char *get_relation_name(Oid relid);
appendStringInfo(&buf, "Not a view");
else
{
-
/*
* Get the rules definition and put it into executors memory
*/
sep = "";
for (keyno = 0; keyno < INDEX_MAX_KEYS; keyno++)
{
- AttrNumber attnum = idxrec->indkey[keyno];
+ AttrNumber attnum = idxrec->indkey[keyno];
if (attnum == InvalidAttrNumber)
break;
*/
if (VARSIZE(&idxrec->indpred) > VARHDRSZ)
{
- Node *node;
- List *context;
- char *exprstr;
- char *str;
+ Node *node;
+ List *context;
+ char *exprstr;
+ char *str;
/* Convert TEXT object to C string */
exprstr = DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(&idxrec->indpred)));
+ PointerGetDatum(&idxrec->indpred)));
/* Convert expression to node tree */
node = (Node *) stringToNode(exprstr);
+
/*
* If top level is a List, assume it is an implicit-AND structure,
* and convert to explicit AND. This is needed for partial index
Datum
pg_get_expr(PG_FUNCTION_ARGS)
{
- text *expr = PG_GETARG_TEXT_P(0);
- Oid relid = PG_GETARG_OID(1);
- text *result;
- Node *node;
- List *context;
- char *exprstr;
- char *relname;
- char *str;
+ text *expr = PG_GETARG_TEXT_P(0);
+ Oid relid = PG_GETARG_OID(1);
+ text *result;
+ Node *node;
+ List *context;
+ char *exprstr;
+ char *relname;
+ char *str;
/* Get the name for the relation */
relname = get_rel_name(relid);
node = (Node *) stringToNode(exprstr);
/*
- * If top level is a List, assume it is an implicit-AND structure,
- * and convert to explicit AND. This is needed for partial index
+ * If top level is a List, assume it is an implicit-AND structure, and
+ * convert to explicit AND. This is needed for partial index
* predicates.
*/
if (node && IsA(node, List))
- {
node = (Node *) make_ands_explicit((List *) node);
- }
/* Deparse */
context = deparse_context_for(relname, relid);
str = deparse_expression(node, context, false);
-
+
/* Pass the result back as TEXT */
result = DatumGetTextP(DirectFunctionCall1(textin,
CStringGetDatum(str)));
tle = get_sortgroupclause_tle(srt, tlist);
expr = tle->expr;
+
/*
* Use column-number form if requested by caller or if expression is a
- * constant --- a constant is ambiguous (and will be misinterpreted
- * by findTargetlistEntry()) if we dump it explicitly.
+ * constant --- a constant is ambiguous (and will be misinterpreted by
+ * findTargetlistEntry()) if we dump it explicitly.
*/
if (force_colno || (expr && IsA(expr, Const)))
{
case T_NullTest:
{
- NullTest *ntest = (NullTest *) node;
+ NullTest *ntest = (NullTest *) node;
appendStringInfo(buf, "(");
get_rule_expr(ntest->arg, context);
- switch (ntest->nulltesttype)
- {
- case IS_NULL:
+ switch (ntest->nulltesttype)
+ {
+ case IS_NULL:
appendStringInfo(buf, " IS NULL)");
break;
- case IS_NOT_NULL:
+ case IS_NOT_NULL:
appendStringInfo(buf, " IS NOT NULL)");
break;
- default:
- elog(ERROR, "get_rule_expr: unexpected nulltesttype %d",
- (int) ntest->nulltesttype);
+ default:
+ elog(ERROR, "get_rule_expr: unexpected nulltesttype %d",
+ (int) ntest->nulltesttype);
}
}
break;
case T_BooleanTest:
{
- BooleanTest *btest = (BooleanTest *) node;
+ BooleanTest *btest = (BooleanTest *) node;
appendStringInfo(buf, "(");
get_rule_expr(btest->arg, context);
- switch (btest->booltesttype)
- {
- case IS_TRUE:
+ switch (btest->booltesttype)
+ {
+ case IS_TRUE:
appendStringInfo(buf, " IS TRUE)");
break;
- case IS_NOT_TRUE:
+ case IS_NOT_TRUE:
appendStringInfo(buf, " IS NOT TRUE)");
break;
- case IS_FALSE:
+ case IS_FALSE:
appendStringInfo(buf, " IS FALSE)");
break;
- case IS_NOT_FALSE:
+ case IS_NOT_FALSE:
appendStringInfo(buf, " IS NOT FALSE)");
break;
- case IS_UNKNOWN:
+ case IS_UNKNOWN:
appendStringInfo(buf, " IS UNKNOWN)");
break;
- case IS_NOT_UNKNOWN:
+ case IS_NOT_UNKNOWN:
appendStringInfo(buf, " IS NOT UNKNOWN)");
break;
- default:
- elog(ERROR, "get_rule_expr: unexpected booltesttype %d",
- (int) btest->booltesttype);
+ default:
+ elog(ERROR, "get_rule_expr: unexpected booltesttype %d",
+ (int) btest->booltesttype);
}
}
break;
appendStringInfoChar(buf, '(');
get_rule_expr(arg, context);
+
/*
* Show typename with appropriate length decoration. Note that
* since exprIsLengthCoercion succeeded, the function's output
* type is the right thing to use.
*
* XXX In general it is incorrect to quote the result of
- * format_type_with_typemod, but are there any special cases
- * where we should do so?
+ * format_type_with_typemod, but are there any special cases where
+ * we should do so?
*/
typdesc = format_type_with_typemod(procStruct->prorettype,
coercedTypmod);
if (IsA(expr, RelabelType))
return strip_type_coercion(((RelabelType *) expr)->arg, resultType);
- if (IsA(expr, Expr) && ((Expr *) expr)->opType == FUNC_EXPR)
+ if (IsA(expr, Expr) &&((Expr *) expr)->opType == FUNC_EXPR)
{
Func *func;
HeapTuple procTuple;
}
/* See if function has same name as its result type */
typeTuple = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(procStruct->prorettype),
+ ObjectIdGetDatum(procStruct->prorettype),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup for type %u failed",
if (constval->constisnull)
{
-
/*
* Always label the type of a NULL constant. This not only
* prevents misdecisions about the type, but it ensures that our
static char *
quote_identifier(char *ident)
{
-
/*
* Can avoid quoting if ident starts with a lowercase letter and
* contains only lowercase letters, digits, and underscores, *and* is
if (safe)
{
-
/*
* Check for keyword. This test is overly strong, since many of
* the "keywords" known to the parser are usable as column names,
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.99 2001/10/13 23:32:33 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.100 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
* Note: the default selectivity estimates are not chosen entirely at random.
* We want them to be small enough to ensure that indexscans will be used if
- * available, for typical table densities of ~100 tuples/page. Thus, for
+ * available, for typical table densities of ~100 tuples/page. Thus, for
* example, 0.01 is not quite small enough, since that makes it appear that
* nearly all pages will be hit anyway. Also, since we sometimes estimate
* eqsel as 1/num_distinct, we probably want DEFAULT_NUM_DISTINCT to equal
unsigned char *hibound,
double *scaledhibound);
static void convert_bytea_to_scalar(Datum value,
- double *scaledvalue,
- Datum lobound,
- double *scaledlobound,
- Datum hibound,
- double *scaledhibound);
+ double *scaledvalue,
+ Datum lobound,
+ double *scaledlobound,
+ Datum hibound,
+ double *scaledhibound);
static double convert_one_string_to_scalar(unsigned char *value,
int rangelo, int rangehi);
static double convert_one_bytea_to_scalar(unsigned char *value, int valuelen,
- int rangelo, int rangehi);
+ int rangelo, int rangehi);
static unsigned char *convert_string_datum(Datum value, Oid typid);
static double convert_timevalue_to_scalar(Datum value, Oid typid);
static double get_att_numdistinct(Query *root, Var *var,
- Form_pg_statistic stats);
+ Form_pg_statistic stats);
static bool get_restriction_var(List *args, int varRelid,
- Var **var, Node **other,
- bool *varonleft);
+ Var **var, Node **other,
+ bool *varonleft);
static void get_join_vars(List *args, Var **var1, Var **var2);
static Selectivity prefix_selectivity(Query *root, Var *var, char *prefix);
static Selectivity pattern_selectivity(char *patt, Pattern_Type ptype);
double selec;
/*
- * If expression is not var = something or something = var for
- * a simple var of a real relation (no subqueries, for now),
- * then punt and return a default estimate.
+ * If expression is not var = something or something = var for a
+ * simple var of a real relation (no subqueries, for now), then punt
+ * and return a default estimate.
*/
if (!get_restriction_var(args, varRelid,
&var, &other, &varonleft))
PG_RETURN_FLOAT8(DEFAULT_EQ_SEL);
/*
- * If the something is a NULL constant, assume operator is strict
- * and return zero, ie, operator will never return TRUE.
+ * If the something is a NULL constant, assume operator is strict and
+ * return zero, ie, operator will never return TRUE.
*/
- if (IsA(other, Const) && ((Const *) other)->constisnull)
+ if (IsA(other, Const) &&((Const *) other)->constisnull)
PG_RETURN_FLOAT8(0.0);
/* get stats for the attribute, if available */
if (IsA(other, Const))
{
/* Var is being compared to a known non-null constant */
- Datum constval = ((Const *) other)->constvalue;
- bool match = false;
- int i;
+ Datum constval = ((Const *) other)->constvalue;
+ bool match = false;
+ int i;
/*
* Is the constant "=" to any of the column's most common
- * values? (Although the given operator may not really be
- * "=", we will assume that seeing whether it returns TRUE
- * is an appropriate test. If you don't like this, maybe you
+ * values? (Although the given operator may not really be
+ * "=", we will assume that seeing whether it returns TRUE is
+ * an appropriate test. If you don't like this, maybe you
* shouldn't be using eqsel for your operator...)
*/
if (get_attstatsslot(statsTuple, var->vartype, var->vartypmod,
{
/*
* Constant is "=" to this common value. We know
- * selectivity exactly (or as exactly as VACUUM
- * could calculate it, anyway).
+ * selectivity exactly (or as exactly as VACUUM could
+ * calculate it, anyway).
*/
selec = numbers[i];
}
else
{
/*
- * Comparison is against a constant that is neither
- * NULL nor any of the common values. Its selectivity
- * cannot be more than this:
+ * Comparison is against a constant that is neither NULL
+ * nor any of the common values. Its selectivity cannot
+ * be more than this:
*/
- double sumcommon = 0.0;
- double otherdistinct;
+ double sumcommon = 0.0;
+ double otherdistinct;
for (i = 0; i < nnumbers; i++)
sumcommon += numbers[i];
selec = 1.0 - sumcommon - stats->stanullfrac;
+
/*
- * and in fact it's probably a good deal less.
- * We approximate that all the not-common values
- * share this remaining fraction equally, so we
- * divide by the number of other distinct values.
+ * and in fact it's probably a good deal less. We
+ * approximate that all the not-common values share this
+ * remaining fraction equally, so we divide by the number
+ * of other distinct values.
*/
otherdistinct = get_att_numdistinct(root, var, stats)
- nnumbers;
if (otherdistinct > 1)
selec /= otherdistinct;
+
/*
- * Another cross-check: selectivity shouldn't be
- * estimated as more than the least common
- * "most common value".
+ * Another cross-check: selectivity shouldn't be estimated
+ * as more than the least common "most common value".
*/
- if (nnumbers > 0 && selec > numbers[nnumbers-1])
- selec = numbers[nnumbers-1];
+ if (nnumbers > 0 && selec > numbers[nnumbers - 1])
+ selec = numbers[nnumbers - 1];
}
free_attstatsslot(var->vartype, values, nvalues,
double ndistinct;
/*
- * Search is for a value that we do not know a priori, but
- * we will assume it is not NULL. Estimate the selectivity
- * as non-null fraction divided by number of distinct values,
- * so that we get a result averaged over all possible values
- * whether common or uncommon. (Essentially, we are assuming
+ * Search is for a value that we do not know a priori, but we
+ * will assume it is not NULL. Estimate the selectivity as
+ * non-null fraction divided by number of distinct values, so
+ * that we get a result averaged over all possible values
+ * whether common or uncommon. (Essentially, we are assuming
* that the not-yet-known comparison value is equally likely
* to be any of the possible values, regardless of their
- * frequency in the table. Is that a good idea?)
+ * frequency in the table. Is that a good idea?)
*/
selec = 1.0 - stats->stanullfrac;
ndistinct = get_att_numdistinct(root, var, stats);
if (ndistinct > 1)
selec /= ndistinct;
+
/*
- * Cross-check: selectivity should never be
- * estimated as more than the most common value's.
+ * Cross-check: selectivity should never be estimated as more
+ * than the most common value's.
*/
if (get_attstatsslot(statsTuple, var->vartype, var->vartypmod,
STATISTIC_KIND_MCV, InvalidOid,
/*
* No VACUUM ANALYZE stats available, so make a guess using
* estimated number of distinct values and assuming they are
- * equally common. (The guess is unlikely to be very good,
- * but we do know a few special cases.)
+ * equally common. (The guess is unlikely to be very good, but we
+ * do know a few special cases.)
*/
selec = 1.0 / get_att_numdistinct(root, var, NULL);
}
if (eqop)
{
result = DatumGetFloat8(DirectFunctionCall4(eqsel,
- PointerGetDatum(root),
- ObjectIdGetDatum(eqop),
- PointerGetDatum(args),
- Int32GetDatum(varRelid)));
+ PointerGetDatum(root),
+ ObjectIdGetDatum(eqop),
+ PointerGetDatum(args),
+ Int32GetDatum(varRelid)));
}
else
{
int i;
/*
- * If expression is not var op something or something op var for
- * a simple var of a real relation (no subqueries, for now),
- * then punt and return a default estimate.
+ * If expression is not var op something or something op var for a
+ * simple var of a real relation (no subqueries, for now), then punt
+ * and return a default estimate.
*/
relid = getrelid(var->varno, root->rtable);
if (relid == InvalidOid)
return DEFAULT_INEQ_SEL;
/*
- * Can't do anything useful if the something is not a constant, either.
+ * Can't do anything useful if the something is not a constant,
+ * either.
*/
- if (! IsA(other, Const))
+ if (!IsA(other, Const))
return DEFAULT_INEQ_SEL;
/*
- * If the constant is NULL, assume operator is strict
- * and return zero, ie, operator will never return TRUE.
+ * If the constant is NULL, assume operator is strict and return zero,
+ * ie, operator will never return TRUE.
*/
if (((Const *) other)->constisnull)
return 0.0;
fmgr_info(get_opcode(operator), &opproc);
/*
- * If we have most-common-values info, add up the fractions of the
- * MCV entries that satisfy MCV OP CONST. These fractions contribute
- * directly to the result selectivity. Also add up the total fraction
+ * If we have most-common-values info, add up the fractions of the MCV
+ * entries that satisfy MCV OP CONST. These fractions contribute
+ * directly to the result selectivity. Also add up the total fraction
* represented by MCV entries.
*/
mcv_selec = 0.0;
{
if (nvalues > 1)
{
- double histfrac;
- bool ltcmp;
+ double histfrac;
+ bool ltcmp;
ltcmp = DatumGetBool(FunctionCall2(&opproc,
values[0],
else
{
/*
- * Scan to find proper location. This could be made faster
- * by using a binary-search method, but it's probably not
- * worth the trouble for typical histogram sizes.
+ * Scan to find proper location. This could be made
+ * faster by using a binary-search method, but it's
+ * probably not worth the trouble for typical histogram
+ * sizes.
*/
for (i = 1; i < nvalues; i++)
{
* We have values[i-1] < constant < values[i].
*
* Convert the constant and the two nearest bin boundary
- * values to a uniform comparison scale, and do a linear
- * interpolation within this bin.
+ * values to a uniform comparison scale, and do a
+ * linear interpolation within this bin.
*/
if (convert_to_scalar(constval, consttype, &val,
- values[i-1], values[i],
+ values[i - 1], values[i],
var->vartype,
&low, &high))
{
else
{
binfrac = (val - low) / (high - low);
+
/*
- * Watch out for the possibility that we got a NaN
- * or Infinity from the division. This can happen
- * despite the previous checks, if for example
- * "low" is -Infinity.
+ * Watch out for the possibility that we got a
+ * NaN or Infinity from the division. This
+ * can happen despite the previous checks, if
+ * for example "low" is -Infinity.
*/
if (isnan(binfrac) ||
binfrac < 0.0 || binfrac > 1.0)
else
{
/*
- * Ideally we'd produce an error here, on the grounds
- * that the given operator shouldn't have scalarXXsel
- * registered as its selectivity func unless we can
- * deal with its operand types. But currently, all
- * manner of stuff is invoking scalarXXsel, so give a
- * default estimate until that can be fixed.
+ * Ideally we'd produce an error here, on the
+ * grounds that the given operator shouldn't have
+ * scalarXXsel registered as its selectivity func
+ * unless we can deal with its operand types. But
+ * currently, all manner of stuff is invoking
+ * scalarXXsel, so give a default estimate until
+ * that can be fixed.
*/
binfrac = 0.5;
}
+
/*
- * Now, compute the overall selectivity across the values
- * represented by the histogram. We have i-1 full bins
- * and binfrac partial bin below the constant.
+ * Now, compute the overall selectivity across the
+ * values represented by the histogram. We have i-1
+ * full bins and binfrac partial bin below the
+ * constant.
*/
- histfrac = (double) (i-1) + binfrac;
+ histfrac = (double) (i - 1) + binfrac;
histfrac /= (double) (nvalues - 1);
}
}
+
/*
- * Now histfrac = fraction of histogram entries below the constant.
+ * Now histfrac = fraction of histogram entries below the
+ * constant.
*
* Account for "<" vs ">"
*/
hist_selec = isgt ? (1.0 - histfrac) : histfrac;
+
/*
* The histogram boundaries are only approximate to begin
- * with, and may well be out of date anyway. Therefore,
- * don't believe extremely small or large selectivity
- * estimates.
+ * with, and may well be out of date anyway. Therefore, don't
+ * believe extremely small or large selectivity estimates.
*/
if (hist_selec < 0.0001)
hist_selec = 0.0001;
double selec;
/*
- * If expression is not var op something or something op var for
- * a simple var of a real relation (no subqueries, for now),
- * then punt and return a default estimate.
+ * If expression is not var op something or something op var for a
+ * simple var of a real relation (no subqueries, for now), then punt
+ * and return a default estimate.
*/
if (!get_restriction_var(args, varRelid,
&var, &other, &varonleft))
double selec;
/*
- * If expression is not var op something or something op var for
- * a simple var of a real relation (no subqueries, for now),
- * then punt and return a default estimate.
+ * If expression is not var op something or something op var for a
+ * simple var of a real relation (no subqueries, for now), then punt
+ * and return a default estimate.
*/
if (!get_restriction_var(args, varRelid,
&var, &other, &varonleft))
patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
{
Query *root = (Query *) PG_GETARG_POINTER(0);
+
#ifdef NOT_USED
Oid operator = PG_GETARG_OID(1);
#endif
double result;
/*
- * If expression is not var op constant for
- * a simple var of a real relation (no subqueries, for now),
- * then punt and return a default estimate.
+ * If expression is not var op constant for a simple var of a real
+ * relation (no subqueries, for now), then punt and return a default
+ * estimate.
*/
if (!get_restriction_var(args, varRelid,
&var, &other, &varonleft))
return DEFAULT_MATCH_SEL;
/*
- * If the constant is NULL, assume operator is strict
- * and return zero, ie, operator will never return TRUE.
+ * If the constant is NULL, assume operator is strict and return zero,
+ * ie, operator will never return TRUE.
*/
if (((Const *) other)->constisnull)
return 0.0;
eqargs = makeList2(var, eqcon);
result = DatumGetFloat8(DirectFunctionCall4(eqsel,
PointerGetDatum(root),
- ObjectIdGetDatum(eqopr),
- PointerGetDatum(eqargs),
- Int32GetDatum(varRelid)));
+ ObjectIdGetDatum(eqopr),
+ PointerGetDatum(eqargs),
+ Int32GetDatum(varRelid)));
}
else
{
/*
- * Not exact-match pattern. We estimate selectivity of the
- * fixed prefix and remainder of pattern separately, then
- * combine the two.
+ * Not exact-match pattern. We estimate selectivity of the fixed
+ * prefix and remainder of pattern separately, then combine the
+ * two.
*/
Selectivity prefixsel;
Selectivity restsel;
Selectivity
booltestsel(Query *root, BooleanTest *clause, int varRelid)
{
- Var *var;
- Node *arg;
- Oid relid;
- HeapTuple statsTuple;
- Datum *values;
- int nvalues;
- float4 *numbers;
- int nnumbers;
- double selec;
+ Var *var;
+ Node *arg;
+ Oid relid;
+ HeapTuple statsTuple;
+ Datum *values;
+ int nvalues;
+ float4 *numbers;
+ int nnumbers;
+ double selec;
Assert(clause && IsA(clause, BooleanTest));
arg = (Node *) clause->arg;
/*
- * Ignore any binary-compatible relabeling (probably unnecessary,
- * but can't hurt)
+ * Ignore any binary-compatible relabeling (probably unnecessary, but
+ * can't hurt)
*/
if (IsA(arg, RelabelType))
arg = ((RelabelType *) arg)->arg;
- if (IsA(arg, Var) && (varRelid == 0 || varRelid == ((Var *) arg)->varno))
+ if (IsA(arg, Var) &&(varRelid == 0 || varRelid == ((Var *) arg)->varno))
var = (Var *) arg;
else
{
* and just assume the value is either TRUE or FALSE.
*/
switch (clause->booltesttype)
- {
+ {
case IS_UNKNOWN:
selec = DEFAULT_UNK_SEL;
break;
case IS_NOT_UNKNOWN:
selec = DEFAULT_NOT_UNK_SEL;
break;
- case IS_TRUE:
- case IS_NOT_FALSE:
+ case IS_TRUE:
+ case IS_NOT_FALSE:
selec = (double) clause_selectivity(root, arg, varRelid);
break;
- case IS_FALSE:
- case IS_NOT_TRUE:
+ case IS_FALSE:
+ case IS_NOT_TRUE:
selec = 1.0 - (double) clause_selectivity(root, arg, varRelid);
break;
- default:
- elog(ERROR, "booltestsel: unexpected booltesttype %d",
- (int) clause->booltesttype);
+ default:
+ elog(ERROR, "booltestsel: unexpected booltesttype %d",
+ (int) clause->booltesttype);
selec = 0.0; /* Keep compiler quiet */
break;
}
if (HeapTupleIsValid(statsTuple))
{
Form_pg_statistic stats;
- double freq_null;
+ double freq_null;
stats = (Form_pg_statistic) GETSTRUCT(statsTuple);
&numbers, &nnumbers)
&& nnumbers > 0)
{
- double freq_true;
- double freq_false;
+ double freq_true;
+ double freq_false;
/*
* Get first MCV frequency and derive frequency for true.
freq_true = 1.0 - numbers[0] - freq_null;
/*
- * Next derive freqency for false.
- * Then use these as appropriate to derive frequency for each case.
+ * Next derive freqency for false. Then use these as
+ * appropriate to derive frequency for each case.
*/
freq_false = 1.0 - freq_true - freq_null;
switch (clause->booltesttype)
- {
- case IS_UNKNOWN:
+ {
+ case IS_UNKNOWN:
/* select only NULL values */
selec = freq_null;
break;
- case IS_NOT_UNKNOWN:
+ case IS_NOT_UNKNOWN:
/* select non-NULL values */
selec = 1.0 - freq_null;
break;
- case IS_TRUE:
+ case IS_TRUE:
/* select only TRUE values */
selec = freq_true;
break;
- case IS_NOT_TRUE:
+ case IS_NOT_TRUE:
/* select non-TRUE values */
selec = 1.0 - freq_true;
break;
- case IS_FALSE:
+ case IS_FALSE:
/* select only FALSE values */
selec = freq_false;
break;
- case IS_NOT_FALSE:
+ case IS_NOT_FALSE:
/* select non-FALSE values */
selec = 1.0 - freq_false;
break;
- default:
- elog(ERROR, "booltestsel: unexpected booltesttype %d",
- (int) clause->booltesttype);
- selec = 0.0; /* Keep compiler quiet */
+ default:
+ elog(ERROR, "booltestsel: unexpected booltesttype %d",
+ (int) clause->booltesttype);
+ selec = 0.0; /* Keep compiler quiet */
break;
}
else
{
/*
- * No most-common-value info available.
- * Still have null fraction information,
- * so use it for IS [NOT] UNKNOWN.
- * Otherwise adjust for null fraction and
- * assume an even split for boolean tests.
+ * No most-common-value info available. Still have null
+ * fraction information, so use it for IS [NOT] UNKNOWN.
+ * Otherwise adjust for null fraction and assume an even split
+ * for boolean tests.
*/
switch (clause->booltesttype)
- {
- case IS_UNKNOWN:
+ {
+ case IS_UNKNOWN:
+
/*
* Use freq_null directly.
*/
selec = freq_null;
break;
- case IS_NOT_UNKNOWN:
+ case IS_NOT_UNKNOWN:
+
/*
- * Select not unknown (not null) values.
- * Calculate from freq_null.
+ * Select not unknown (not null) values. Calculate
+ * from freq_null.
*/
selec = 1.0 - freq_null;
break;
- case IS_TRUE:
- case IS_NOT_TRUE:
- case IS_FALSE:
- case IS_NOT_FALSE:
+ case IS_TRUE:
+ case IS_NOT_TRUE:
+ case IS_FALSE:
+ case IS_NOT_FALSE:
selec = (1.0 - freq_null) / 2.0;
break;
- default:
- elog(ERROR, "booltestsel: unexpected booltesttype %d",
- (int) clause->booltesttype);
- selec = 0.0; /* Keep compiler quiet */
+ default:
+ elog(ERROR, "booltestsel: unexpected booltesttype %d",
+ (int) clause->booltesttype);
+ selec = 0.0; /* Keep compiler quiet */
break;
}
}
default:
elog(ERROR, "booltestsel: unexpected booltesttype %d",
(int) clause->booltesttype);
- selec = 0.0; /* Keep compiler quiet */
+ selec = 0.0; /* Keep compiler quiet */
break;
}
}
Selectivity
nulltestsel(Query *root, NullTest *clause, int varRelid)
{
- Var *var;
- Node *arg;
- Oid relid;
- HeapTuple statsTuple;
- double selec;
- double defselec;
- double freq_null;
+ Var *var;
+ Node *arg;
+ Oid relid;
+ HeapTuple statsTuple;
+ double selec;
+ double defselec;
+ double freq_null;
Assert(clause && IsA(clause, NullTest));
switch (clause->nulltesttype)
- {
- case IS_NULL:
+ {
+ case IS_NULL:
defselec = DEFAULT_UNK_SEL;
break;
- case IS_NOT_NULL:
+ case IS_NOT_NULL:
defselec = DEFAULT_NOT_UNK_SEL;
break;
- default:
- elog(ERROR, "nulltestsel: unexpected nulltesttype %d",
- (int) clause->nulltesttype);
- return (Selectivity) 0; /* keep compiler quiet */
+ default:
+ elog(ERROR, "nulltestsel: unexpected nulltesttype %d",
+ (int) clause->nulltesttype);
+ return (Selectivity) 0; /* keep compiler quiet */
}
arg = (Node *) clause->arg;
if (IsA(arg, RelabelType))
arg = ((RelabelType *) arg)->arg;
- if (IsA(arg, Var) && (varRelid == 0 || varRelid == ((Var *) arg)->varno))
+ if (IsA(arg, Var) &&(varRelid == 0 || varRelid == ((Var *) arg)->varno))
var = (Var *) arg;
else
{
relid = getrelid(var->varno, root->rtable);
if (relid == InvalidOid)
- return (Selectivity) defselec;
+ return (Selectivity) defselec;
/* get stats for the attribute, if available */
statsTuple = SearchSysCache(STATRELATT,
freq_null = stats->stanullfrac;
switch (clause->nulltesttype)
- {
- case IS_NULL:
+ {
+ case IS_NULL:
+
/*
* Use freq_null directly.
*/
selec = freq_null;
break;
- case IS_NOT_NULL:
+ case IS_NOT_NULL:
+
/*
- * Select not unknown (not null) values.
- * Calculate from freq_null.
+ * Select not unknown (not null) values. Calculate from
+ * freq_null.
*/
selec = 1.0 - freq_null;
break;
- default:
- elog(ERROR, "nulltestsel: unexpected nulltesttype %d",
- (int) clause->nulltesttype);
- return (Selectivity) 0; /* keep compiler quiet */
+ default:
+ elog(ERROR, "nulltestsel: unexpected nulltesttype %d",
+ (int) clause->nulltesttype);
+ return (Selectivity) 0; /* keep compiler quiet */
}
ReleaseSysCache(statsTuple);
if (var1 != NULL)
{
/* get stats for the attribute, if available */
- Oid relid1 = getrelid(var1->varno, root->rtable);
+ Oid relid1 = getrelid(var1->varno, root->rtable);
if (relid1 != InvalidOid)
{
statsTuple1 = SearchSysCache(STATRELATT,
ObjectIdGetDatum(relid1),
- Int16GetDatum(var1->varattno),
+ Int16GetDatum(var1->varattno),
0, 0);
if (HeapTupleIsValid(statsTuple1))
{
if (var2 != NULL)
{
/* get stats for the attribute, if available */
- Oid relid2 = getrelid(var2->varno, root->rtable);
+ Oid relid2 = getrelid(var2->varno, root->rtable);
if (relid2 != InvalidOid)
{
statsTuple2 = SearchSysCache(STATRELATT,
ObjectIdGetDatum(relid2),
- Int16GetDatum(var2->varattno),
+ Int16GetDatum(var2->varattno),
0, 0);
if (HeapTupleIsValid(statsTuple2))
{
if (have_mcvs1 && have_mcvs2)
{
/*
- * We have most-common-value lists for both relations. Run
+ * We have most-common-value lists for both relations. Run
* through the lists to see which MCVs actually join to each
* other with the given operator. This allows us to determine
* the exact join selectivity for the portion of the relations
- * represented by the MCV lists. We still have to estimate for
- * the remaining population, but in a skewed distribution this
- * gives us a big leg up in accuracy. For motivation see the
- * analysis in Y. Ioannidis and S. Christodoulakis, "On the
- * propagation of errors in the size of join results", Technical
- * Report 1018, Computer Science Dept., University of Wisconsin,
- * Madison, March 1991 (available from ftp.cs.wisc.edu).
+ * represented by the MCV lists. We still have to estimate
+ * for the remaining population, but in a skewed distribution
+ * this gives us a big leg up in accuracy. For motivation see
+ * the analysis in Y. Ioannidis and S. Christodoulakis, "On
+ * the propagation of errors in the size of join results",
+ * Technical Report 1018, Computer Science Dept., University
+ * of Wisconsin, Madison, March 1991 (available from
+ * ftp.cs.wisc.edu).
*/
FmgrInfo eqproc;
bool *hasmatch1;
memset(hasmatch1, 0, nvalues1 * sizeof(bool));
hasmatch2 = (bool *) palloc(nvalues2 * sizeof(bool));
memset(hasmatch2, 0, nvalues2 * sizeof(bool));
+
/*
- * Note we assume that each MCV will match at most one member of
- * the other MCV list. If the operator isn't really equality,
- * there could be multiple matches --- but we don't look for them,
- * both for speed and because the math wouldn't add up...
+ * Note we assume that each MCV will match at most one member
+ * of the other MCV list. If the operator isn't really
+ * equality, there could be multiple matches --- but we don't
+ * look for them, both for speed and because the math wouldn't
+ * add up...
*/
matchprodfreq = 0.0;
nmatches = 0;
for (i = 0; i < nvalues1; i++)
{
- int j;
+ int j;
for (j = 0; j < nvalues2; j++)
{
}
pfree(hasmatch1);
pfree(hasmatch2);
+
/*
* Compute total frequency of non-null values that are not in
* the MCV lists.
*/
otherfreq1 = 1.0 - stats1->stanullfrac - matchfreq1 - unmatchfreq1;
otherfreq2 = 1.0 - stats2->stanullfrac - matchfreq2 - unmatchfreq2;
+
/*
- * We can estimate the total selectivity from the point of view
- * of relation 1 as: the known selectivity for matched MCVs, plus
- * unmatched MCVs that are assumed to match against random members
- * of relation 2's non-MCV population, plus non-MCV values that
- * are assumed to match against random members of relation 2's
- * unmatched MCVs plus non-MCV values.
+ * We can estimate the total selectivity from the point of
+ * view of relation 1 as: the known selectivity for matched
+ * MCVs, plus unmatched MCVs that are assumed to match against
+ * random members of relation 2's non-MCV population, plus
+ * non-MCV values that are assumed to match against random
+ * members of relation 2's unmatched MCVs plus non-MCV values.
*/
totalsel1 = matchprodfreq;
if (nd2 > nvalues2)
if (nd1 > nmatches)
totalsel2 += otherfreq2 * (otherfreq1 + unmatchfreq1) /
(nd1 - nmatches);
+
/*
- * Use the smaller of the two estimates. This can be justified
- * in essentially the same terms as given below for the no-stats
- * case: to a first approximation, we are estimating from the
- * point of view of the relation with smaller nd.
+ * Use the smaller of the two estimates. This can be
+ * justified in essentially the same terms as given below for
+ * the no-stats case: to a first approximation, we are
+ * estimating from the point of view of the relation with
+ * smaller nd.
*/
selec = (totalsel1 < totalsel2) ? totalsel1 : totalsel2;
}
else
{
/*
- * We do not have MCV lists for both sides. Estimate the
- * join selectivity as MIN(1/nd1, 1/nd2). This is plausible
- * if we assume that the values are about equally distributed:
- * a given tuple of rel1 will join to either 0 or N2/nd2 rows
- * of rel2, so total join rows are at most N1*N2/nd2 giving
- * a join selectivity of not more than 1/nd2. By the same logic
+ * We do not have MCV lists for both sides. Estimate the join
+ * selectivity as MIN(1/nd1, 1/nd2). This is plausible if we
+ * assume that the values are about equally distributed: a
+ * given tuple of rel1 will join to either 0 or N2/nd2 rows of
+ * rel2, so total join rows are at most N1*N2/nd2 giving a
+ * join selectivity of not more than 1/nd2. By the same logic
* it is not more than 1/nd1, so MIN(1/nd1, 1/nd2) is an upper
* bound. Using the MIN() means we estimate from the point of
- * view of the relation with smaller nd (since the larger nd is
- * determining the MIN). It is reasonable to assume that most
- * tuples in this rel will have join partners, so the bound is
- * probably reasonably tight and should be taken as-is.
+ * view of the relation with smaller nd (since the larger nd
+ * is determining the MIN). It is reasonable to assume that
+ * most tuples in this rel will have join partners, so the
+ * bound is probably reasonably tight and should be taken
+ * as-is.
*
- * XXX Can we be smarter if we have an MCV list for just one side?
- * It seems that if we assume equal distribution for the other
- * side, we end up with the same answer anyway.
+ * XXX Can we be smarter if we have an MCV list for just one
+ * side? It seems that if we assume equal distribution for the
+ * other side, we end up with the same answer anyway.
*/
if (nd1 > nd2)
selec = 1.0 / nd1;
if (eqop)
{
result = DatumGetFloat8(DirectFunctionCall3(eqjoinsel,
- PointerGetDatum(root),
- ObjectIdGetDatum(eqop),
- PointerGetDatum(args)));
+ PointerGetDatum(root),
+ ObjectIdGetDatum(eqop),
+ PointerGetDatum(args)));
}
else
{
switch (valuetypid)
{
- /*
- * Built-in numeric types
- */
+ /*
+ * Built-in numeric types
+ */
case BOOLOID:
case INT2OID:
case INT4OID:
*scaledhibound = convert_numeric_to_scalar(hibound, boundstypid);
return true;
- /*
- * Built-in string types
- */
+ /*
+ * Built-in string types
+ */
case CHAROID:
case BPCHAROID:
case VARCHAROID:
return true;
}
- /*
- * Built-in bytea type
- */
+ /*
+ * Built-in bytea type
+ */
case BYTEAOID:
{
convert_bytea_to_scalar(value, scaledvalue,
return true;
}
- /*
- * Built-in time types
- */
+ /*
+ * Built-in time types
+ */
case TIMESTAMPOID:
case TIMESTAMPTZOID:
case ABSTIMEOID:
*scaledhibound = convert_timevalue_to_scalar(hibound, boundstypid);
return true;
- /*
- * Built-in network types
- */
+ /*
+ * Built-in network types
+ */
case INETOID:
case CIDROID:
case MACADDROID:
char *xfrmstr;
size_t xfrmsize;
size_t xfrmlen;
-
#endif
switch (typid)
#ifdef USE_LOCALE
/* Guess that transformed string is not much bigger than original */
- xfrmsize = strlen(val) + 32;/* arbitrary pad value here... */
+ xfrmsize = strlen(val) + 32; /* arbitrary pad value here... */
xfrmstr = (char *) palloc(xfrmsize);
xfrmlen = strxfrm(xfrmstr, val, xfrmsize);
if (xfrmlen >= xfrmsize)
i,
minlen;
unsigned char *valstr = (unsigned char *) VARDATA(DatumGetPointer(value)),
- *lostr = (unsigned char *) VARDATA(DatumGetPointer(lobound)),
- *histr = (unsigned char *) VARDATA(DatumGetPointer(hibound));
+ *lostr = (unsigned char *) VARDATA(DatumGetPointer(lobound)),
+ *histr = (unsigned char *) VARDATA(DatumGetPointer(hibound));
/*
* Assume bytea data is uniformly distributed across all byte values.
return 0.0; /* empty string has scalar value 0 */
/*
- * Since base is 256, need not consider more than about 10
- * chars (even this many seems like overkill)
+ * Since base is 256, need not consider more than about 10 chars (even
+ * this many seems like overkill)
*/
if (valuelen > 10)
valuelen = 10;
ntuples = rel->tuples;
if (ntuples <= 0.0)
- return DEFAULT_NUM_DISTINCT; /* no data available; return a default */
+ return DEFAULT_NUM_DISTINCT; /* no data available; return a
+ * default */
/*
- * Look to see if there is a unique index on the attribute.
- * If so, we assume it's distinct, ignoring pg_statistic info
- * which could be out of date.
+ * Look to see if there is a unique index on the attribute. If so, we
+ * assume it's distinct, ignoring pg_statistic info which could be out
+ * of date.
*/
if (has_unique_index(rel, var->varattno))
return ntuples;
if (stats->stadistinct > 0.0)
return stats->stadistinct;
if (stats->stadistinct < 0.0)
- return - stats->stadistinct * ntuples;
+ return -stats->stadistinct * ntuples;
}
/*
- * ANALYZE does not compute stats for system attributes,
- * but some of them can reasonably be assumed unique anyway.
+ * ANALYZE does not compute stats for system attributes, but some of
+ * them can reasonably be assumed unique anyway.
*/
switch (var->varattno)
{
}
/*
- * Estimate ndistinct = ntuples if the table is small, else use default.
+ * Estimate ndistinct = ntuples if the table is small, else use
+ * default.
*/
if (ntuples < DEFAULT_NUM_DISTINCT)
return ntuples;
/*
* get_restriction_var
* Examine the args of a restriction clause to see if it's of the
- * form (var op something) or (something op var). If so, extract
+ * form (var op something) or (something op var). If so, extract
* and return the var and the other argument.
*
* Inputs:
/* note start at pos 1 to skip leading ^ */
for (pos = 1; patt[pos]; pos++)
{
-
/*
* Check for characters that indicate multiple possible matches
* here. XXX I suspect isalpha() is not an adequately
/* Assume scalargtsel is appropriate for all supported types */
prefixsel = DatumGetFloat8(DirectFunctionCall4(scalargtsel,
PointerGetDatum(root),
- ObjectIdGetDatum(cmpopr),
- PointerGetDatum(cmpargs),
+ ObjectIdGetDatum(cmpopr),
+ PointerGetDatum(cmpargs),
Int32GetDatum(0)));
/*-------
/* Assume scalarltsel is appropriate for all supported types */
topsel = DatumGetFloat8(DirectFunctionCall4(scalarltsel,
PointerGetDatum(root),
- ObjectIdGetDatum(cmpopr),
- PointerGetDatum(cmpargs),
+ ObjectIdGetDatum(cmpopr),
+ PointerGetDatum(cmpargs),
Int32GetDatum(0)));
/*
{
if (prefixsel < -0.01)
{
-
/*
* No data available --- use a default estimate that is
* small, but not real small.
}
else
{
-
/*
* It's just roundoff error; use a small positive value
*/
if (patt[pos] == '(')
{
if (paren_depth == 0)
- paren_pos = pos;/* remember start of parenthesized item */
+ paren_pos = pos; /* remember start of parenthesized item */
paren_depth++;
}
else if (patt[pos] == ')' && paren_depth > 0)
}
else if (patt[pos] == '|' && paren_depth == 0)
{
-
/*
* If unquoted | is present at paren level 0 in pattern, we
* have multiple alternatives; sum their probabilities.
List *selectivityQuals = indexQuals;
/*
- * If the index is partial, AND the index predicate with the explicitly
- * given indexquals to produce a more accurate idea of the index
- * restriction. This may produce redundant clauses, which we hope that
- * cnfify and clauselist_selectivity will deal with intelligently.
+ * If the index is partial, AND the index predicate with the
+ * explicitly given indexquals to produce a more accurate idea of the
+ * index restriction. This may produce redundant clauses, which we
+ * hope that cnfify and clauselist_selectivity will deal with
+ * intelligently.
*
- * Note that index->indpred and indexQuals are both in implicit-AND
- * form to start with, which we have to make explicit to hand to
+ * Note that index->indpred and indexQuals are both in implicit-AND form
+ * to start with, which we have to make explicit to hand to
* canonicalize_qual, and then we get back implicit-AND form again.
*/
if (index->indpred != NIL)
{
- Expr *andedQuals;
+ Expr *andedQuals;
andedQuals = make_ands_explicit(nconc(listCopy(index->indpred),
indexQuals));
selectivityQuals = canonicalize_qual(andedQuals, true);
}
- /* Estimate the fraction of main-table tuples that will be visited */
- *indexSelectivity = clauselist_selectivity(root, selectivityQuals,
- lfirsti(rel->relids));
+ /* Estimate the fraction of main-table tuples that will be visited */
+ *indexSelectivity = clauselist_selectivity(root, selectivityQuals,
+ lfirsti(rel->relids));
/*
- * Estimate the number of tuples that will be visited. We do it in
+ * Estimate the number of tuples that will be visited. We do it in
* this rather peculiar-looking way in order to get the right answer
* for partial indexes. We can bound the number of tuples by the
* index size, in any case.
if (numIndexTuples > index->tuples)
numIndexTuples = index->tuples;
- /*
+ /*
* Always estimate at least one tuple is touched, even when
* indexSelectivity estimate is tiny.
*/
if (numIndexTuples < 1.0)
numIndexTuples = 1.0;
- /*
+ /*
* Estimate the number of index pages that will be retrieved.
*
* For all currently-supported index types, the first page of the index
/*
* If it's a functional index, leave the default zero-correlation
- * estimate in place. If not, and if we can get an estimate for
- * the first variable's ordering correlation C from pg_statistic,
- * estimate the index correlation as C / number-of-columns.
- * (The idea here is that multiple columns dilute the importance
- * of the first column's ordering, but don't negate it entirely.)
+ * estimate in place. If not, and if we can get an estimate for the
+ * first variable's ordering correlation C from pg_statistic, estimate
+ * the index correlation as C / number-of-columns. (The idea here is
+ * that multiple columns dilute the importance of the first column's
+ * ordering, but don't negate it entirely.)
*/
if (index->indproc == InvalidOid)
{
0, 0);
if (HeapTupleIsValid(tuple))
{
- Oid typid;
- int32 typmod;
- float4 *numbers;
- int nnumbers;
+ Oid typid;
+ int32 typmod;
+ float4 *numbers;
+ int nnumbers;
get_atttypetypmod(relid, index->indexkeys[0],
&typid, &typmod);
index->ordering[0],
NULL, NULL, &numbers, &nnumbers))
{
- double varCorrelation;
- int nKeys;
+ double varCorrelation;
+ int nKeys;
Assert(nnumbers == 1);
varCorrelation = numbers[0];
for (nKeys = 1; index->indexkeys[nKeys] != 0; nKeys++)
- /*skip*/;
+ /* skip */ ;
*indexCorrelation = varCorrelation / nKeys;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.27 2001/09/17 00:29:10 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.28 2001/10/25 05:49:45 momjian Exp $
*
* NOTES
* input routine largely stolen from boxin().
BlockIdGetBlockNumber(&(arg2->ip_blkid)) ||
arg1->ip_posid != arg2->ip_posid);
}
-
#endif
/*
* Maybe these implementations should be moved to another place
*/
-static ItemPointerData Current_last_tid = { {0, 0}, 0};
+static ItemPointerData Current_last_tid = {{0, 0}, 0};
void
setLastTid(const ItemPointer tid)
Relation rel;
result = (ItemPointer) palloc(sizeof(ItemPointerData));
- if (!reloid)
- {
- *result = Current_last_tid;
- PG_RETURN_ITEMPOINTER(result);
- }
+ if (!reloid)
+ {
+ *result = Current_last_tid;
+ PG_RETURN_ITEMPOINTER(result);
+ }
ItemPointerCopy(tid, result);
if ((rel = heap_open(reloid, AccessShareLock)) != NULL)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.58 2001/10/20 01:02:18 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.59 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
timestamp_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
+
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
static void
AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
{
- if (! TIMESTAMP_NOT_FINITE(*time) &&
+ if (!TIMESTAMP_NOT_FINITE(*time) &&
(typmod >= 0) && (typmod <= 13))
{
static double TimestampScale = 1;
TimestampTypmod = typmod;
}
- *time = (rint(((double) *time) * TimestampScale)/TimestampScale);
+ *time = (rint(((double) *time) * TimestampScale) / TimestampScale);
}
}
timestamptz_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
+
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 typmod = PG_GETARG_INT32(2);
- TimestampTz result;
+ TimestampTz result;
double fsec;
struct tm tt,
*tm = &tt;
Datum
timestamptz_out(PG_FUNCTION_ARGS)
{
- TimestampTz dt = PG_GETARG_TIMESTAMP(0);
+ TimestampTz dt = PG_GETARG_TIMESTAMP(0);
char *result;
int tz;
struct tm tt,
Datum
timestamptz_scale(PG_FUNCTION_ARGS)
{
- TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
+ TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
int32 typmod = PG_GETARG_INT32(1);
- TimestampTz result;
+ TimestampTz result;
result = timestamp;
interval_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
+
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
{
if (typmod != -1)
{
- int range = ((typmod >> 16) & 0x7FFF);
- int precision = (typmod & 0xFFFF);
+ int range = ((typmod >> 16) & 0x7FFF);
+ int precision = (typmod & 0xFFFF);
if (range == 0x7FFF)
{
interval->time = 0;
}
/* YEAR TO MONTH */
- else if (range == (MASK(YEAR) | MASK(MONTH)))
- {
+ else if (range == (MASK(YEAR) | MASK(MONTH)))
interval->time = 0;
- }
else if (range == MASK(DAY))
{
interval->month = 0;
- interval->time = (((int)(interval->time / 86400)) * 86400);
+ interval->time = (((int) (interval->time / 86400)) * 86400);
}
else if (range == MASK(HOUR))
{
- double day;
+ double day;
interval->month = 0;
TMODULO(interval->time, day, 86400.0);
- interval->time = (((int)(interval->time / 3600)) * 3600.0);
+ interval->time = (((int) (interval->time / 3600)) * 3600.0);
}
else if (range == MASK(MINUTE))
{
- double hour;
+ double hour;
interval->month = 0;
TMODULO(interval->time, hour, 3600.0);
- interval->time = (((int)(interval->time / 60)) * 60);
+ interval->time = (((int) (interval->time / 60)) * 60);
}
else if (range == MASK(SECOND))
{
- double hour;
+ double hour;
interval->month = 0;
TMODULO(interval->time, hour, 60.0);
-// interval->time = (int)(interval->time);
+/* interval->time = (int)(interval->time); */
}
/* DAY TO HOUR */
else if (range == (MASK(DAY) | MASK(HOUR)))
{
interval->month = 0;
- interval->time = (((int)(interval->time / 3600)) * 3600);
+ interval->time = (((int) (interval->time / 3600)) * 3600);
}
/* DAY TO MINUTE */
else if (range == (MASK(DAY) | MASK(HOUR) | MASK(MINUTE)))
{
interval->month = 0;
- interval->time = (((int)(interval->time / 60)) * 60);
+ interval->time = (((int) (interval->time / 60)) * 60);
}
/* DAY TO SECOND */
else if (range == (MASK(DAY) | MASK(HOUR) | MASK(MINUTE) | MASK(SECOND)))
- {
interval->month = 0;
- }
/* HOUR TO MINUTE */
else if (range == (MASK(HOUR) | MASK(MINUTE)))
{
- double day;
+ double day;
interval->month = 0;
TMODULO(interval->time, day, 86400.0);
- interval->time = (((int)(interval->time / 60)) * 60);
+ interval->time = (((int) (interval->time / 60)) * 60);
}
/* HOUR TO SECOND */
else if (range == (MASK(HOUR) | MASK(MINUTE) | MASK(SECOND)))
{
- double day;
+ double day;
interval->month = 0;
TMODULO(interval->time, day, 86400.0);
/* MINUTE TO SECOND */
else if (range == (MASK(MINUTE) | MASK(SECOND)))
{
- double hour;
+ double hour;
interval->month = 0;
TMODULO(interval->time, hour, 3600.0);
}
else
- {
elog(ERROR, "AdjustIntervalForTypmod(): internal coding error");
- }
if (precision != 0xFFFF)
{
static double IntervalScale = 1;
- static int IntervalTypmod = 0;
+ static int IntervalTypmod = 0;
if (precision != IntervalTypmod)
{
IntervalScale = pow(10.0, IntervalTypmod);
}
- /* Hmm. For the time field, we can get to a large value
- * since we store everything related to an absolute interval
- * (e.g. years worth of days) in this one field. So we have
+ /*
+ * Hmm. For the time field, we can get to a large value since
+ * we store everything related to an absolute interval (e.g.
+ * years worth of days) in this one field. So we have
* precision problems doing rint() on this field if the field
- * is too large. This resulted in an annoying "...0001" appended
- * to the printed result on my Linux box.
- * I hate doing an expensive math operation like log10()
- * to avoid this, but what else can we do??
- * - thomas 2001-10-19
+ * is too large. This resulted in an annoying "...0001"
+ * appended to the printed result on my Linux box. I hate
+ * doing an expensive math operation like log10() to avoid
+ * this, but what else can we do?? - thomas 2001-10-19
*/
if ((log10(interval->time) + IntervalTypmod) <= 13)
interval->time = (rint(interval->time * IntervalScale) / IntervalScale);
Datum
now(PG_FUNCTION_ARGS)
{
- TimestampTz result;
+ TimestampTz result;
AbsoluteTime sec;
int usec;
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
struct tm *tx;
-
#endif
date0 = date2j(2000, 1, 1);
- /* If HasCTZSet is true then we have a brute force time zone specified.
- * Go ahead and rotate to the local time zone since we will later bypass
- * any calls which adjust the tm fields.
+ /*
+ * If HasCTZSet is true then we have a brute force time zone
+ * specified. Go ahead and rotate to the local time zone since we will
+ * later bypass any calls which adjust the tm fields.
*/
if (HasCTZSet && (tzp != NULL))
dt -= CTimeZone;
if (tzp != NULL)
{
- /* We have a brute force time zone per SQL99?
- * Then use it without change
- * since we have already rotated to the time zone.
+ /*
+ * We have a brute force time zone per SQL99? Then use it without
+ * change since we have already rotated to the time zone.
*/
if (HasCTZSet)
{
*tzn = NULL;
}
- /* Does this fall within the capabilities of the localtime() interface?
- * Then use this to rotate to the local time zone.
+ /*
+ * Does this fall within the capabilities of the localtime()
+ * interface? Then use this to rotate to the local time zone.
*/
else if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
{
Datum
overlaps_timestamp(PG_FUNCTION_ARGS)
{
-
/*
* The arguments are Timestamps, but we leave them as generic Datums
* to avoid unnecessary conversions between value and reference forms
*/
if (TIMESTAMP_GT(ts1, ts2))
{
-
/*
* This case is ts1 < te2 OR te1 < te2, which may look redundant
* but in the presence of nulls it's not quite completely so.
}
else
{
-
/*
* For ts1 = ts2 the spec says te1 <> te2 OR te1 = te2, which is a
* rather silly way of saying "true if both are nonnull, else
Timestamp result;
if (TIMESTAMP_NOT_FINITE(timestamp))
- {
result = timestamp;
- }
else
{
if (span->month != 0)
Datum
timestamptz_pl_span(PG_FUNCTION_ARGS)
{
- TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
+ TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
Interval *span = PG_GETARG_INTERVAL_P(1);
- TimestampTz result;
+ TimestampTz result;
int tz;
char *tzn;
if (TIMESTAMP_NOT_FINITE(timestamp))
- {
result = timestamp;
- }
else
{
if (span->month != 0)
if (tm2timestamp(tm, fsec, &tz, ×tamp) != 0)
elog(ERROR, "Unable to add TIMESTAMP and INTERVAL"
- "\n\ttimestamptz_pl_span() internal error encoding timestamp");
+ "\n\ttimestamptz_pl_span() internal error encoding timestamp");
}
else
{
Datum
timestamptz_mi_span(PG_FUNCTION_ARGS)
{
- TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
+ TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
Interval *span = PG_GETARG_INTERVAL_P(1);
Interval tspan;
memcpy(&N, DatumGetIntervalP(transdatums[1]), sizeof(Interval));
newsum = DatumGetIntervalP(DirectFunctionCall2(interval_pl,
- IntervalPGetDatum(&sumX),
- IntervalPGetDatum(newval)));
+ IntervalPGetDatum(&sumX),
+ IntervalPGetDatum(newval)));
N.time += 1;
transdatums[0] = IntervalPGetDatum(newsum);
Datum
timestamptz_age(PG_FUNCTION_ARGS)
{
- TimestampTz dt1 = PG_GETARG_TIMESTAMP(0);
- TimestampTz dt2 = PG_GETARG_TIMESTAMP(1);
+ TimestampTz dt1 = PG_GETARG_TIMESTAMP(0);
+ TimestampTz dt2 = PG_GETARG_TIMESTAMP(1);
Interval *result;
double fsec,
fsec1,
int len;
str = DatumGetCString(DirectFunctionCall1(interval_out,
- IntervalPGetDatum(interval)));
+ IntervalPGetDatum(interval)));
len = (strlen(str) + VARHDRSZ);
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
elog(ERROR, "TIMESTAMP units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(units))));
+ PointerGetDatum(units))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
timestamptz_trunc(PG_FUNCTION_ARGS)
{
text *units = PG_GETARG_TEXT_P(0);
- TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
- TimestampTz result;
+ TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
+ TimestampTz result;
int tz;
int type,
val;
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
elog(ERROR, "TIMESTAMP WITH TIME ZONE units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(units))));
+ PointerGetDatum(units))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
elog(ERROR, "INTERVAL units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(units))));
+ PointerGetDatum(units))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
{
elog(ERROR, "INTERVAL units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(units))));
+ PointerGetDatum(units))));
*result = *interval;
}
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
elog(ERROR, "TIMESTAMP units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(units))));
+ PointerGetDatum(units))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
timestamptz_part(PG_FUNCTION_ARGS)
{
text *units = PG_GETARG_TEXT_P(0);
- TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
+ TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
float8 result;
int tz;
int type,
default:
elog(ERROR, "INTERVAL units '%s' not supported",
DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(units))));
+ PointerGetDatum(units))));
result = 0;
}
{
elog(ERROR, "INTERVAL units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(units))));
+ PointerGetDatum(units))));
result = 0;
}
{
text *zone = PG_GETARG_TEXT_P(0);
Timestamp timestamp = PG_GETARG_TIMESTAMP(1);
- TimestampTz result;
+ TimestampTz result;
int tz;
int type,
val;
{
Interval *zone = PG_GETARG_INTERVAL_P(0);
Timestamp timestamp = PG_GETARG_TIMESTAMP(1);
- TimestampTz result;
+ TimestampTz result;
int tz;
if (TIMESTAMP_NOT_FINITE(timestamp))
timestamp_timestamptz(PG_FUNCTION_ARGS)
{
Timestamp timestamp = PG_GETARG_TIMESTAMP(0);
- TimestampTz result;
+ TimestampTz result;
struct tm tt,
*tm = &tt;
double fsec;
int tz;
if (TIMESTAMP_NOT_FINITE(timestamp))
- {
result = timestamp;
- }
else
{
if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0)
Datum
timestamptz_timestamp(PG_FUNCTION_ARGS)
{
- TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
+ TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
Timestamp result;
struct tm tt,
*tm = &tt;
int tz;
if (TIMESTAMP_NOT_FINITE(timestamp))
- {
result = timestamp;
- }
else
{
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
timestamptz_zone(PG_FUNCTION_ARGS)
{
text *zone = PG_GETARG_TEXT_P(0);
- TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
+ TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
text *result;
- TimestampTz dt;
+ TimestampTz dt;
int tz;
int type,
val;
timestamptz_izone(PG_FUNCTION_ARGS)
{
Interval *zone = PG_GETARG_INTERVAL_P(0);
- TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
+ TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
text *result;
- TimestampTz dt;
+ TimestampTz dt;
int tz;
char *tzn = "";
double fsec;
if (timestamp2tm(dt, NULL, tm, &fsec, NULL) != 0)
elog(ERROR, "Unable to decode TIMESTAMP WITH TIME ZONE"
- "\n\ttimestamptz_izone() internal coding error");
+ "\n\ttimestamptz_izone() internal coding error");
EncodeDateTime(tm, fsec, &tz, &tzn, USE_ISO_DATES, buf);
len = (strlen(buf) + VARHDRSZ);
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.19 2001/10/06 23:21:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.20 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
-
#endif
int32 atttypmod = PG_GETARG_INT32(2);
VarBit *result; /* The resulting bit string */
}
else
{
-
/*
* Otherwise it's binary. This allows things like cast('1001' as
* bit) to work transparently.
FunctionCallInfoData locfcinfo;
/*
- * Since bit() is a built-in function, we should only need to look
- * it up once per run.
+ * Since bit() is a built-in function, we should only need to look it
+ * up once per run.
*/
static FmgrInfo bit_finfo;
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
-
#endif
int32 atttypmod = PG_GETARG_INT32(2);
VarBit *result; /* The resulting bit string */
}
else
{
-
/*
* OK, we've got a true substring starting at position s1-1 and
* ending at position e1-1
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.84 2001/10/06 23:21:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.85 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bpcharin(PG_FUNCTION_ARGS)
{
char *s = PG_GETARG_CSTRING(0);
+
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 atttypmod = PG_GETARG_INT32(2);
BpChar *result;
char *r;
- size_t len, maxlen;
+ size_t len,
+ maxlen;
int i;
+
#ifdef MULTIBYTE
- int charlen; /* number of charcters in the input string */
- char *ermsg;
+ int charlen; /* number of charcters in the input string */
+ char *ermsg;
#endif
len = strlen(s);
#ifdef MULTIBYTE
if ((ermsg = pg_verifymbstr(s, len)))
- elog(ERROR,"%s",ermsg);
+ elog(ERROR, "%s", ermsg);
charlen = pg_mbstrlen(s);
#endif
{
/* Verify that extra characters are spaces, and clip them off */
#ifdef MULTIBYTE
- size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen);
+ size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen);
+
/*
- * at this point, len is the actual BYTE length of the
- * input string, maxlen is the max number of
- * CHARACTERS allowed for this bpchar type.
+ * at this point, len is the actual BYTE length of the input
+ * string, maxlen is the max number of CHARACTERS allowed for this
+ * bpchar type.
*/
if (strspn(s + mbmaxlen, " ") == len - mbmaxlen)
len = mbmaxlen;
else
elog(ERROR, "value too long for type character(%d)", maxlen);
+
/*
- * XXX: at this point, maxlen is the necessary byte
- * length, not the number of CHARACTERS!
+ * XXX: at this point, maxlen is the necessary byte length, not
+ * the number of CHARACTERS!
*/
maxlen = len;
#else
else
{
/*
- * XXX: at this point, maxlen is the necessary byte
- * length, not the number of CHARACTERS!
+ * XXX: at this point, maxlen is the necessary byte length, not
+ * the number of CHARACTERS!
*/
maxlen = len + (maxlen - charlen);
}
char *r;
char *s;
int i;
+
#ifdef MULTIBYTE
- int charlen; /* number of charcters in the input string
- + VARHDRSZ*/
+ int charlen; /* number of charcters in the input string
+ * + VARHDRSZ */
#endif
len = VARSIZE(source);
size_t maxmblen;
maxmblen = pg_mbcharcliplen(VARDATA(source), len - VARHDRSZ,
- maxlen - VARHDRSZ) + VARHDRSZ;
+ maxlen - VARHDRSZ) + VARHDRSZ;
for (i = maxmblen - VARHDRSZ; i < len - VARHDRSZ; i++)
if (*(VARDATA(source) + i) != ' ')
maxlen - VARHDRSZ);
len = maxmblen;
+
/*
* XXX: at this point, maxlen is the necessary byte
* length+VARHDRSZ, not the number of CHARACTERS!
varcharin(PG_FUNCTION_ARGS)
{
char *s = PG_GETARG_CSTRING(0);
+
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 atttypmod = PG_GETARG_INT32(2);
VarChar *result;
- size_t len, maxlen;
+ size_t len,
+ maxlen;
+
#ifdef MULTIBYTE
- char *ermsg;
+ char *ermsg;
#endif
len = strlen(s);
#ifdef MULTIBYTE
if ((ermsg = pg_verifymbstr(s, len)))
- elog(ERROR,"%s",ermsg);
+ elog(ERROR, "%s", ermsg);
#endif
maxlen = atttypmod - VARHDRSZ;
{
/* Verify that extra characters are spaces, and clip them off */
#ifdef MULTIBYTE
- size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen);
+ size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen);
if (strspn(s + mbmaxlen, " ") == len - mbmaxlen)
len = mbmaxlen;
/* truncate multi-byte string preserving multi-byte boundary */
maxmblen = pg_mbcharcliplen(VARDATA(source), len - VARHDRSZ,
- maxlen - VARHDRSZ) + VARHDRSZ;
+ maxlen - VARHDRSZ) + VARHDRSZ;
for (i = maxmblen - VARHDRSZ; i < len - VARHDRSZ; i++)
if (*(VARDATA(source) + i) != ' ')
#ifdef MULTIBYTE
PG_RETURN_INT32(
- pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ)
- );
+ pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ)
+ );
#else
PG_RETURN_INT32(VARSIZE(arg) - VARHDRSZ);
#endif
#ifdef MULTIBYTE
PG_RETURN_INT32(
- pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ)
- );
+ pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ)
+ );
#else
PG_RETURN_INT32(VARSIZE(arg) - VARHDRSZ);
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.73 2001/09/14 17:46:40 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.74 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
for (byte = 0, tp = inputText; *tp != '\0'; byte++)
{
if (tp[0] != '\\')
- {
tp++;
- }
- else if ( (tp[0] == '\\') &&
- (tp[1] >= '0' && tp[1] <= '3') &&
- (tp[2] >= '0' && tp[2] <= '7') &&
- (tp[3] >= '0' && tp[3] <= '7') )
- {
+ else if ((tp[0] == '\\') &&
+ (tp[1] >= '0' && tp[1] <= '3') &&
+ (tp[2] >= '0' && tp[2] <= '7') &&
+ (tp[3] >= '0' && tp[3] <= '7'))
tp += 4;
- }
- else if ( (tp[0] == '\\') &&
- (tp[1] == '\\') )
- {
+ else if ((tp[0] == '\\') &&
+ (tp[1] == '\\'))
tp += 2;
- }
else
{
/*
while (*tp != '\0')
{
if (tp[0] != '\\')
- {
*rp++ = *tp++;
- }
- else if ( (tp[0] == '\\') &&
- (tp[1] >= '0' && tp[1] <= '3') &&
- (tp[2] >= '0' && tp[2] <= '7') &&
- (tp[3] >= '0' && tp[3] <= '7') )
+ else if ((tp[0] == '\\') &&
+ (tp[1] >= '0' && tp[1] <= '3') &&
+ (tp[2] >= '0' && tp[2] <= '7') &&
+ (tp[3] >= '0' && tp[3] <= '7'))
{
byte = VAL(tp[1]);
byte <<= 3;
*rp++ = byte + VAL(tp[3]);
tp += 4;
}
- else if ( (tp[0] == '\\') &&
- (tp[1] == '\\') )
+ else if ((tp[0] == '\\') &&
+ (tp[1] == '\\'))
{
*rp++ = '\\';
tp += 2;
else
{
/*
- * We should never get here. The first pass should
- * not allow it.
+ * We should never get here. The first pass should not allow
+ * it.
*/
elog(ERROR, "Bad input string for type bytea");
}
char *inputText = PG_GETARG_CSTRING(0);
text *result;
int len;
+
#ifdef MULTIBYTE
- char *ermsg;
+ char *ermsg;
#endif
len = strlen(inputText) + VARHDRSZ;
#ifdef MULTIBYTE
if ((ermsg = pg_verifymbstr(inputText, len - VARHDRSZ)))
- elog(ERROR,"%s",ermsg);
+ elog(ERROR, "%s", ermsg);
#endif
result = (text *) palloc(len);
#ifdef MULTIBYTE
int i;
char *p;
-
#endif
len = VARSIZE(string) - VARHDRSZ;
#ifdef MULTIBYTE
pg_wchar *ps1,
*ps2;
-
#endif
if (VARSIZE(t2) <= VARHDRSZ)
p;
int len1,
len2;
- char *p1,
- *p2;
+ char *p1,
+ *p2;
if (VARSIZE(t2) <= VARHDRSZ)
PG_RETURN_INT32(1); /* result for empty pattern */
Datum
byteaeq(PG_FUNCTION_ARGS)
{
- bytea *arg1 = PG_GETARG_BYTEA_P(0);
- bytea *arg2 = PG_GETARG_BYTEA_P(1);
+ bytea *arg1 = PG_GETARG_BYTEA_P(0);
+ bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
bool result;
Datum
byteane(PG_FUNCTION_ARGS)
{
- bytea *arg1 = PG_GETARG_BYTEA_P(0);
- bytea *arg2 = PG_GETARG_BYTEA_P(1);
+ bytea *arg1 = PG_GETARG_BYTEA_P(0);
+ bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
bool result;
Datum
bytealt(PG_FUNCTION_ARGS)
{
- bytea *arg1 = PG_GETARG_BYTEA_P(0);
- bytea *arg2 = PG_GETARG_BYTEA_P(1);
+ bytea *arg1 = PG_GETARG_BYTEA_P(0);
+ bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
int cmp;
Datum
byteale(PG_FUNCTION_ARGS)
{
- bytea *arg1 = PG_GETARG_BYTEA_P(0);
- bytea *arg2 = PG_GETARG_BYTEA_P(1);
+ bytea *arg1 = PG_GETARG_BYTEA_P(0);
+ bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
int cmp;
Datum
byteagt(PG_FUNCTION_ARGS)
{
- bytea *arg1 = PG_GETARG_BYTEA_P(0);
- bytea *arg2 = PG_GETARG_BYTEA_P(1);
+ bytea *arg1 = PG_GETARG_BYTEA_P(0);
+ bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
int cmp;
Datum
byteage(PG_FUNCTION_ARGS)
{
- bytea *arg1 = PG_GETARG_BYTEA_P(0);
- bytea *arg2 = PG_GETARG_BYTEA_P(1);
+ bytea *arg1 = PG_GETARG_BYTEA_P(0);
+ bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
int cmp;
Datum
byteacmp(PG_FUNCTION_ARGS)
{
- bytea *arg1 = PG_GETARG_BYTEA_P(0);
- bytea *arg2 = PG_GETARG_BYTEA_P(1);
+ bytea *arg1 = PG_GETARG_BYTEA_P(0);
+ bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
int cmp;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.83 2001/10/06 23:21:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.84 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "utils/syscache.h"
-/* #define CACHEDEBUG */ /* turns DEBUG elogs on */
+ /* #define CACHEDEBUG *//* turns DEBUG elogs on */
/*
* Constants related to size of the catcache.
*
* NCCBUCKETS should be prime and must be less than 64K (because
- * SharedInvalCatcacheMsg crams hash indexes into a uint16 field). In
+ * SharedInvalCatcacheMsg crams hash indexes into a uint16 field). In
* practice it should be a lot less, anyway, to avoid chewing up too much
* space on hash bucket headers.
*
tupRelid = ct->tuple.t_data->t_oid;
else
{
- bool isNull;
+ bool isNull;
tupRelid = DatumGetObjectId(
- fastgetattr(&ct->tuple,
- cache->cc_reloidattr,
- cache->cc_tupdesc,
- &isNull));
+ fastgetattr(&ct->tuple,
+ cache->cc_reloidattr,
+ cache->cc_tupdesc,
+ &isNull));
Assert(!isNull);
}
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
/*
- * if first time through, initialize the cache group header,
- * including global LRU list header
+ * if first time through, initialize the cache group header, including
+ * global LRU list header
*/
if (CacheHdr == NULL)
{
cp->cc_relname = relname;
cp->cc_indname = indname;
cp->cc_reloidattr = reloidattr;
- cp->cc_relisshared = false; /* temporary */
+ cp->cc_relisshared = false; /* temporary */
cp->cc_tupdesc = (TupleDesc) NULL;
cp->cc_ntup = 0;
cp->cc_size = NCCBUCKETS;
cp->cc_key[i] = key[i];
/*
- * new cache is initialized as far as we can go for now.
- * print some debugging information, if appropriate.
+ * new cache is initialized as far as we can go for now. print some
+ * debugging information, if appropriate.
*/
InitCatCache_DEBUG1;
&& ct->dead
#endif
)
- {
CatCacheRemoveCTup(ct->my_cache, ct);
- }
}
/*
void
PrepareToInvalidateCacheTuple(Relation relation,
HeapTuple tuple,
- void (*function) (int, Index, ItemPointer, Oid))
+ void (*function) (int, Index, ItemPointer, Oid))
{
CatCache *ccp;
* second lives till end of transaction. Finally, we need a third list of
* all tuples outdated in the current transaction; if we commit, we send
* those invalidation events to all other backends (via the SI message queue)
- * so that they can flush obsolete entries from their caches. This list
+ * so that they can flush obsolete entries from their caches. This list
* definitely can't be processed until after we commit, otherwise the other
* backends won't see our updated tuples as good.
*
* We do not need to register EVERY tuple operation in this way, just those
- * on tuples in relations that have associated catcaches. We do, however,
+ * on tuples in relations that have associated catcaches. We do, however,
* have to register every operation on every tuple that *could* be in a
- * catcache, whether or not it currently is in our cache. Also, if the
+ * catcache, whether or not it currently is in our cache. Also, if the
* tuple is in a relation that has multiple catcaches, we need to register
* an invalidation message for each such catcache. catcache.c's
* PrepareToInvalidateCacheTuple() routine provides the knowledge of which
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.45 2001/06/19 19:42:16 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.46 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
* To minimize palloc traffic, we keep pending requests in successively-
* larger chunks (a slightly more sophisticated version of an expansible
- * array). All request types can be stored as SharedInvalidationMessage
+ * array). All request types can be stored as SharedInvalidationMessage
* records.
*/
typedef struct InvalidationChunk
{
- struct InvalidationChunk *next; /* list link */
+ struct InvalidationChunk *next; /* list link */
int nitems; /* # items currently stored in chunk */
int maxitems; /* size of allocated array in this chunk */
- SharedInvalidationMessage msgs[1]; /* VARIABLE LENGTH ARRAY */
+ SharedInvalidationMessage msgs[1]; /* VARIABLE LENGTH ARRAY */
} InvalidationChunk; /* VARIABLE LENGTH STRUCTURE */
typedef struct InvalidationListHeader
chunk = (InvalidationChunk *)
MemoryContextAlloc(TopTransactionContext,
sizeof(InvalidationChunk) +
- (FIRSTCHUNKSIZE-1) * sizeof(SharedInvalidationMessage));
+ (FIRSTCHUNKSIZE - 1) *sizeof(SharedInvalidationMessage));
chunk->nitems = 0;
chunk->maxitems = FIRSTCHUNKSIZE;
chunk->next = *listHdr;
else if (chunk->nitems >= chunk->maxitems)
{
/* Need another chunk; double size of last chunk */
- int chunksize = 2 * chunk->maxitems;
+ int chunksize = 2 * chunk->maxitems;
chunk = (InvalidationChunk *)
MemoryContextAlloc(TopTransactionContext,
sizeof(InvalidationChunk) +
- (chunksize-1) * sizeof(SharedInvalidationMessage));
+ (chunksize - 1) *sizeof(SharedInvalidationMessage));
chunk->nitems = 0;
chunk->maxitems = chunksize;
chunk->next = *listHdr;
}
else
{
- /* Assume the storage will go away at xact end, just reset pointers */
+ /*
+ * Assume the storage will go away at xact end, just reset
+ * pointers
+ */
hdr->cclist = NULL;
hdr->rclist = NULL;
}
static void
PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
void (*CacheIdRegisterFunc) (int, Index,
- ItemPointer, Oid),
+ ItemPointer, Oid),
void (*RelationIdRegisterFunc) (Oid, Oid))
{
Oid tupleRelId;
* Yes. We need to register a relcache invalidation event for the
* relation identified by relationId.
*
- * KLUGE ALERT: we always send the relcache event with MyDatabaseId,
- * even if the rel in question is shared. This essentially means that
- * only backends in this same database will react to the relcache flush
- * request. This is in fact appropriate, since only those backends could
- * see our pg_class or pg_attribute change anyway. It looks a bit ugly
- * though.
+ * KLUGE ALERT: we always send the relcache event with MyDatabaseId, even
+ * if the rel in question is shared. This essentially means that only
+ * backends in this same database will react to the relcache flush
+ * request. This is in fact appropriate, since only those backends
+ * could see our pg_class or pg_attribute change anyway. It looks a
+ * bit ugly though.
*/
(*RelationIdRegisterFunc) (MyDatabaseId, relationId);
}
* If isCommit, we must send out the messages in our GlobalInvalidMsgs list
* to the shared invalidation message queue. Note that these will be read
* not only by other backends, but also by our own backend at the next
- * transaction start (via AcceptInvalidationMessages). Therefore, it's okay
+ * transaction start (via AcceptInvalidationMessages). Therefore, it's okay
* to discard any pending LocalInvalidMsgs, since these will be redundant
* with the global list.
*
* in a transaction.
*
* Here, we send no messages to the shared queue, since we don't know yet if
- * we will commit. But we do need to locally process the LocalInvalidMsgs
+ * we will commit. But we do need to locally process the LocalInvalidMsgs
* list, so as to flush our caches of any tuples we have outdated in the
* current command.
*
ProcessInvalidationMessages(&RollbackMsgs,
LocalExecuteInvalidationMessage);
}
+
/*
- * LocalInvalidMsgs list is not interesting anymore, so flush it
- * (for real). Do *not* clear GlobalInvalidMsgs or RollbackMsgs.
+ * LocalInvalidMsgs list is not interesting anymore, so flush it (for
+ * real). Do *not* clear GlobalInvalidMsgs or RollbackMsgs.
*/
DiscardInvalidationMessages(&LocalInvalidMsgs, true);
}
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.58 2001/09/06 02:07:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.59 2001/10/25 05:49:46 momjian Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
else
return InvalidAttrNumber;
}
-
#endif
/*
else
return 'i';
}
-
#endif
char
typelem = type->typelem;
/*
- * typdefault is potentially null, so don't try to access it as a struct
- * field. Must do it the hard way with SysCacheGetAttr.
+ * typdefault is potentially null, so don't try to access it as a
+ * struct field. Must do it the hard way with SysCacheGetAttr.
*/
textDefaultVal = SysCacheGetAttr(TYPEOID,
typeTuple,
*/
if (typlen > 0)
return typlen;
+
/*
* type_maximum_size knows the encoding of typmod for some datatypes;
* don't duplicate that knowledge here.
if (maxwidth > 0)
{
/*
- * For BPCHAR, the max width is also the only width. Otherwise
- * we need to guess about the typical data width given the max.
- * A sliding scale for percentage of max width seems reasonable.
+ * For BPCHAR, the max width is also the only width. Otherwise we
+ * need to guess about the typical data width given the max. A
+ * sliding scale for percentage of max width seems reasonable.
*/
if (typid == BPCHAROID)
return maxwidth;
if (maxwidth <= 32)
return maxwidth; /* assume full width */
if (maxwidth < 1000)
- return 32 + (maxwidth - 32) / 2; /* assume 50% */
+ return 32 + (maxwidth - 32) / 2; /* assume 50% */
+
/*
* Beyond 1000, assume we're looking at something like
* "varchar(10000)" where the limit isn't actually reached often,
*/
return 32 + (1000 - 32) / 2;
}
+
/*
* Ooops, we have no idea ... wild guess time.
*/
else
return '\0';
}
-
#endif
/* ---------- STATISTICS CACHE ---------- */
0, 0);
if (HeapTupleIsValid(tp))
{
- int32 stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
+ int32 stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
ReleaseSysCache(tp);
if (stawidth > 0)
if (isnull)
elog(ERROR, "get_attstatsslot: stavalues is null");
statarray = DatumGetArrayTypeP(val);
+
/*
- * Do initial examination of the array. This produces a list
- * of text Datums --- ie, pointers into the text array value.
+ * Do initial examination of the array. This produces a list of
+ * text Datums --- ie, pointers into the text array value.
*/
deconstruct_array(statarray, false, -1, 'i', values, nvalues);
narrayelem = *nvalues;
+
/*
- * We now need to replace each text Datum by its internal equivalent.
+ * We now need to replace each text Datum by its internal
+ * equivalent.
*
* Get the type input proc and typelem for the column datatype.
*/
fmgr_info(((Form_pg_type) GETSTRUCT(typeTuple))->typinput, &inputproc);
typelem = ((Form_pg_type) GETSTRUCT(typeTuple))->typelem;
ReleaseSysCache(typeTuple);
+
/*
- * Do the conversions. The palloc'd array of Datums is reused
- * in place.
+ * Do the conversions. The palloc'd array of Datums is reused in
+ * place.
*/
for (j = 0; j < narrayelem; j++)
{
Int32GetDatum(atttypmod));
pfree(strval);
}
+
/*
* Free statarray if it's a detoasted copy.
*/
if (isnull)
elog(ERROR, "get_attstatsslot: stanumbers is null");
statarray = DatumGetArrayTypeP(val);
+
/*
- * We expect the array to be a 1-D float4 array; verify that.
- * We don't need to use deconstruct_array() since the array
- * data is just going to look like a C array of float4 values.
+ * We expect the array to be a 1-D float4 array; verify that. We
+ * don't need to use deconstruct_array() since the array data is
+ * just going to look like a C array of float4 values.
*/
narrayelem = ARR_DIMS(statarray)[0];
if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
*numbers = (float4 *) palloc(narrayelem * sizeof(float4));
memcpy(*numbers, ARR_DATA_PTR(statarray), narrayelem * sizeof(float4));
*nnumbers = narrayelem;
+
/*
* Free statarray if it's a detoasted copy.
*/
{
if (values)
{
- if (! get_typbyval(atttype))
+ if (!get_typbyval(atttype))
{
- int i;
+ int i;
for (i = 0; i < nvalues; i++)
pfree(DatumGetPointer(values[i]));
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.146 2001/10/06 23:21:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.147 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifdef ENABLE_REINDEX_NAILED_RELATIONS
static void RelationReloadClassinfo(Relation relation);
-
#endif /* ENABLE_REINDEX_NAILED_RELATIONS */
static void RelationFlushRelation(Relation relation);
static Relation RelationNameCacheGetRelation(const char *relationName);
static HeapTuple
ScanPgRelation(RelationBuildDescInfo buildinfo)
{
-
/*
* If this is bootstrap time (initdb), then we can't use the system
* catalog indices, because they may not exist yet. Otherwise, we
return_tuple = pg_class_tuple;
else
{
-
/*
* a satanic bug used to live here: pg_class_tuple used to be
* returned here without having the corresponding buffer pinned.
default:
elog(ERROR, "ScanPgRelation: bad buildinfo");
- return_tuple = NULL;/* keep compiler quiet */
+ return_tuple = NULL; /* keep compiler quiet */
}
heap_close(pg_class_desc, AccessShareLock);
RelationBuildTupleDesc(RelationBuildDescInfo buildinfo,
Relation relation)
{
-
/*
* If this is bootstrap time (initdb), then we can't use the system
* catalog indices, because they may not exist yet. Otherwise, we
{
#ifdef _DROP_COLUMN_HACK__
bool columnDropped = false;
-
#endif /* _DROP_COLUMN_HACK__ */
atttup = AttributeRelidNumIndexScan(attrel,
*/
rulescxt = AllocSetContextCreate(CacheMemoryContext,
RelationGetRelationName(relation),
- 0, /* minsize */
+ 0, /* minsize */
1024, /* initsize */
1024); /* maxsize */
relation->rd_rulescxt = rulescxt;
amsupport = relation->rd_am->amsupport;
/*
- * Make the private context to hold index access info. The reason
- * we need a context, and not just a couple of pallocs, is so that
- * we won't leak any subsidiary info attached to fmgr lookup records.
+ * Make the private context to hold index access info. The reason we
+ * need a context, and not just a couple of pallocs, is so that we
+ * won't leak any subsidiary info attached to fmgr lookup records.
*
* Context parameters are set on the assumption that it'll probably not
* contain much data.
*/
indexcxt = AllocSetContextCreate(CacheMemoryContext,
RelationGetRelationName(relation),
- 0, /* minsize */
+ 0, /* minsize */
512, /* initsize */
1024); /* maxsize */
relation->rd_indexcxt = indexcxt;
if (amsupport > 0)
{
- int nsupport = natts * amsupport;
+ int nsupport = natts * amsupport;
support = (RegProcedure *)
MemoryContextAlloc(indexcxt, nsupport * sizeof(RegProcedure));
strcpy(RelationGetPhysicalRelationName(relation), relationName);
/*
- * It's important to distinguish between shared and non-shared relations,
- * even at bootstrap time, to make sure we know where they are stored.
+ * It's important to distinguish between shared and non-shared
+ * relations, even at bootstrap time, to make sure we know where they
+ * are stored.
*/
relation->rd_rel->relisshared = IsSharedSystemRelationName(relationName);
if (!IsBootstrapProcessingMode())
{
/*
- * This list is incomplete, but it only has to work for the
- * set of rels that formrdesc is used for ...
+ * This list is incomplete, but it only has to work for the set of
+ * rels that formrdesc is used for ...
*/
if (strcmp(relationName, RelationRelationName) == 0 ||
strcmp(relationName, AttributeRelationName) == 0 ||
return;
}
-
#endif /* ENABLE_REINDEX_NAILED_RELATIONS */
/*
}
else
{
-
/*
* When rebuilding an open relcache entry, must preserve ref count
* and myxactonly flag. Also attempt to preserve the tupledesc,
RuleLock *old_rules = relation->rd_rules;
MemoryContext old_rulescxt = relation->rd_rulescxt;
TriggerDesc *old_trigdesc = relation->trigdesc;
- BlockNumber old_nblocks = relation->rd_nblocks;
+ BlockNumber old_nblocks = relation->rd_nblocks;
RelationBuildDescInfo buildinfo;
buildinfo.infotype = INFO_RELID;
if (relation->rd_myxactonly)
{
-
/*
* Local rels should always be rebuilt, not flushed; the relcache
* entry must live until RelationPurgeLocalRelation().
}
else
{
-
/*
* Nonlocal rels can be dropped from the relcache if not open.
*/
relation->rd_rel->relam == accessMethodId))
RelationFlushRelation(relation);
}
-
#endif
rel->rd_isnailed = true;
/*
- * create a new tuple descriptor from the one passed in
- * (we do this to copy it into the cache context)
+ * create a new tuple descriptor from the one passed in (we do this to
+ * copy it into the cache context)
*/
rel->rd_att = CreateTupleDescCopyConstr(tupDesc);
rel->rd_rel->relchecks = tupDesc->constr->num_check;
/*
- * Insert relation OID and database/tablespace ID into the right places.
- * XXX currently we assume physical tblspace/relnode are same as logical
- * dbid/reloid. Probably should pass an extra pair of parameters.
+ * Insert relation OID and database/tablespace ID into the right
+ * places. XXX currently we assume physical tblspace/relnode are same
+ * as logical dbid/reloid. Probably should pass an extra pair of
+ * parameters.
*/
rel->rd_rel->relisshared = (dbid == InvalidOid);
void
RelationCacheInitializePhase2(void)
{
-
/*
* Get the real pg_class tuple for each nailed-in-cache relcache entry
* that was made by RelationCacheInitialize(), and replace the phony
*/
if (!IsBootstrapProcessingMode())
{
-
/*
* Initialize critical system index relation descriptors, first.
* They are to make building relation descriptors fast.
*/
indexcxt = AllocSetContextCreate(CacheMemoryContext,
RelationGetRelationName(ird),
- 0, /* minsize */
- 512, /* initsize */
- 1024); /* maxsize */
+ 0, /* minsize */
+ 512, /* initsize */
+ 1024); /* maxsize */
ird->rd_indexcxt = indexcxt;
/* next, read the index strategy map */
fd = PathNameOpenFile(tempfilename, O_WRONLY | O_CREAT | O_TRUNC | PG_BINARY, 0600);
if (fd < 0)
{
-
/*
* We used to consider this a fatal error, but we might as well
* continue with backend startup ...
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.65 2001/08/21 16:36:05 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.66 2001/10/25 05:49:46 momjian Exp $
*
* NOTES
* These routines allow the parser/planner/executor to perform
0,
0
}},
- {AccessMethodProcedureRelationName, /* AMPROCNUM */
+ {AccessMethodProcedureRelationName, /* AMPROCNUM */
AccessMethodProcedureIndex,
0,
2,
}}
};
-static CatCache *SysCache[lengthof(cacheinfo)];
+static CatCache *SysCache[
+ lengthof(cacheinfo)];
static int SysCacheSize = lengthof(cacheinfo);
static bool CacheInitialized = false;
AttrNumber attributeNumber,
bool *isNull)
{
-
/*
* We just need to get the TupleDesc out of the cache entry, and then
* we can apply heap_getattr(). We expect that the cache control data
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.89 2001/10/18 23:07:29 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.90 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
errorstr = useful_strerror(errno);
/*
- * Convert initialization errors into fatal errors. This is
- * probably redundant, because Warn_restart_ready won't be set
- * anyway.
+ * Convert initialization errors into fatal errors. This is probably
+ * redundant, because Warn_restart_ready won't be set anyway.
*/
if (lev == ERROR && IsInitProcessingMode())
lev = FATAL;
/*
- * If we are inside a critical section, all errors become
- * REALLYFATAL errors. See miscadmin.h.
+ * If we are inside a critical section, all errors become REALLYFATAL
+ * errors. See miscadmin.h.
*/
if (lev == ERROR || lev == FATAL)
{
timestamp_size += PID_SIZE;
fmt = gettext(fmt);
+
/*
* Set up the expanded format, consisting of the prefix string plus
* input format, with any %m replaced by strerror() string (since
lev = ERROR;
prefix = elog_message_prefix(lev);
}
+
/*
- * gettext doesn't allocate memory, except in the very
- * first call (which this isn't), so it's safe to
- * translate here. Worst case we get the untranslated
- * string back.
+ * gettext doesn't allocate memory, except in the very first
+ * call (which this isn't), so it's safe to translate here.
+ * Worst case we get the untranslated string back.
*/
/* translator: This must fit in fmt_fixedbuf. */
fmt = gettext("elog: out of memory");
write_syslog(syslog_level, msg_buf + timestamp_size);
}
-#endif /* ENABLE_SYSLOG */
+#endif /* ENABLE_SYSLOG */
/* syslog doesn't want a trailing newline, but other destinations do */
strcat(msg_buf, "\n");
syslog(level, "[%lu] %s", seq, line);
}
}
-
-#endif /* ENABLE_SYSLOG */
+#endif /* ENABLE_SYSLOG */
static void
pq_endmessage(&buf);
/*
- * This flush is normally not necessary, since postgres.c will
- * flush out waiting data when control returns to the main loop.
- * But it seems best to leave it here, so that the client has some
- * clue what happened if the backend dies before getting back to
- * the main loop ... error/notice messages should not be a
- * performance-critical path anyway, so an extra flush won't hurt
- * much ...
+ * This flush is normally not necessary, since postgres.c will flush
+ * out waiting data when control returns to the main loop. But it
+ * seems best to leave it here, so that the client has some clue what
+ * happened if the backend dies before getting back to the main loop
+ * ... error/notice messages should not be a performance-critical path
+ * anyway, so an extra flush won't hurt much ...
*/
pq_flush();
}
-static const char *useful_strerror(int errnum)
+static const char *
+useful_strerror(int errnum)
{
/* this buffer is only used if errno has a bogus value */
- static char errorstr_buf[48];
+ static char errorstr_buf[48];
char *str;
if (errnum == ERANGE)
*/
if (str == NULL || *str == '\0')
{
- /* translator: This string will be truncated at 47 characters expanded. */
+ /*
+ * translator: This string will be truncated at 47 characters
+ * expanded.
+ */
snprintf(errorstr_buf, 48, gettext("operating system error %d"), errnum);
str = errorstr_buf;
}
static const char *
elog_message_prefix(int lev)
{
- const char * prefix = NULL;
+ const char *prefix = NULL;
switch (lev)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.37 2001/03/22 03:59:58 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.38 2001/10/25 05:49:46 momjian Exp $
*
* NOTE
* XXX this code needs improvement--check for state violations and
}
#ifdef NOT_USED
-ExcProc *
+ExcProc *
ExcGetUnCaught(void)
{
return ExcUnCaughtP;
}
-
#endif
#ifdef NOT_USED
-ExcProc *
+ExcProc *
ExcSetUnCaught(ExcProc *newP)
{
ExcProc *oldP = ExcUnCaughtP;
return oldP;
}
-
#endif
static void
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.53 2001/10/06 23:21:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.54 2001/10/25 05:49:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define SAME_INODE(A,B) ((A).st_ino == (B).inode && (A).st_dev == (B).device)
-char * Dynamic_library_path;
+char *Dynamic_library_path;
static bool file_exists(const char *name);
-static char * find_in_dynamic_libpath(const char * basename);
-static char * expand_dynamic_library_name(const char *name);
-static char * substitute_libpath_macro(const char * name);
+static char *find_in_dynamic_libpath(const char *basename);
+static char *expand_dynamic_library_name(const char *name);
+static char *substitute_libpath_macro(const char *name);
/*
* Load the specified dynamic-link library file, and look for a function
if (stat(name, &st) == 0)
return S_ISDIR(st.st_mode) ? false : true;
else if (!(errno == ENOENT || errno == ENOTDIR || errno == EACCES))
- elog(ERROR, "stat failed on %s: %s", name, strerror(errno));
+ elog(ERROR, "stat failed on %s: %s", name, strerror(errno));
return false;
}
* If name contains a slash, check if the file exists, if so return
* the name. Else (no slash) try to expand using search path (see
* find_in_dynamic_libpath below); if that works, return the fully
- * expanded file name. If the previous failed, append DLSUFFIX and
+ * expanded file name. If the previous failed, append DLSUFFIX and
* try again. If all fails, return NULL.
*
* A non-NULL result will always be freshly palloc'd.
static char *
expand_dynamic_library_name(const char *name)
{
- bool have_slash;
- char * new;
- char * full;
+ bool have_slash;
+ char *new;
+ char *full;
AssertArg(name);
pfree(full);
}
- new = palloc(strlen(name)+ strlen(DLSUFFIX) + 1);
+ new = palloc(strlen(name) + strlen(DLSUFFIX) + 1);
strcpy(new, name);
strcat(new, DLSUFFIX);
return full;
pfree(full);
}
-
+
return NULL;
}
* Result is always freshly palloc'd.
*/
static char *
-substitute_libpath_macro(const char * name)
+substitute_libpath_macro(const char *name)
{
- size_t macroname_len;
- char * replacement = NULL;
+ size_t macroname_len;
+ char *replacement = NULL;
AssertArg(name != NULL);
macroname_len = strcspn(name + 1, "/") + 1;
- if (strncmp(name, "$libdir", macroname_len)==0)
+ if (strncmp(name, "$libdir", macroname_len) == 0)
replacement = PKGLIBDIR;
else
elog(ERROR, "invalid macro name in dynamic library path");
return pstrdup(replacement);
else
{
- char * new;
+ char *new;
new = palloc(strlen(replacement) + (strlen(name) - macroname_len) + 1);
* return NULL.
*/
static char *
-find_in_dynamic_libpath(const char * basename)
+find_in_dynamic_libpath(const char *basename)
{
const char *p;
- size_t baselen;
+ size_t baselen;
AssertArg(basename != NULL);
AssertArg(strchr(basename, '/') == NULL);
for (;;)
{
- size_t len;
- char * piece;
- char * mangled;
- char *full;
+ size_t len;
+ char *piece;
+ char *mangled;
+ char *full;
len = strcspn(p, ":");
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.55 2001/10/06 23:21:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.56 2001/10/25 05:49:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#else
typedef char *((*func_ptr) ());
-
#endif
/*
char *prosrc;
/*
- * fn_oid *must* be filled in last. Some code assumes that if fn_oid is
- * valid, the whole struct is valid. Some FmgrInfo struct's do survive
- * elogs.
+ * fn_oid *must* be filled in last. Some code assumes that if fn_oid
+ * is valid, the whole struct is valid. Some FmgrInfo struct's do
+ * survive elogs.
*/
finfo->fn_oid = InvalidOid;
finfo->fn_extra = NULL;
if ((fbp = fmgr_isbuiltin(functionId)) != NULL)
{
/*
- * Fast path for builtin functions: don't bother consulting pg_proc
+ * Fast path for builtin functions: don't bother consulting
+ * pg_proc
*/
finfo->fn_nargs = fbp->nargs;
finfo->fn_strict = fbp->strict;
switch (procedureStruct->prolang)
{
case INTERNALlanguageId:
+
/*
* For an ordinary builtin function, we should never get here
* because the isbuiltin() search above will have succeeded.
* Copy an FmgrInfo struct
*
* This is inherently somewhat bogus since we can't reliably duplicate
- * language-dependent subsidiary info. We cheat by zeroing fn_extra,
+ * language-dependent subsidiary info. We cheat by zeroing fn_extra,
* instead, meaning that subsidiary info will have to be recomputed.
*/
void
static Datum
fmgr_untrusted(PG_FUNCTION_ARGS)
{
-
/*
* Currently these are unsupported. Someday we might do something
* like forking a subprocess to execute 'em.
*retval = X;
return PointerGetDatum(retval);
-#else /* INT64_IS_BUSTED */
+#else /* INT64_IS_BUSTED */
+
/*
- * On a machine with no 64-bit-int C datatype, sizeof(int64) will not be
- * 8, but we want Int64GetDatum to return an 8-byte object anyway, with
- * zeroes in the unused bits. This is needed so that, for example,
- * hash join of int8 will behave properly.
+ * On a machine with no 64-bit-int C datatype, sizeof(int64) will not
+ * be 8, but we want Int64GetDatum to return an 8-byte object anyway,
+ * with zeroes in the unused bits. This is needed so that, for
+ * example, hash join of int8 will behave properly.
*/
int64 *retval = (int64 *) palloc(Max(sizeof(int64), 8));
MemSet(retval, 0, Max(sizeof(int64), 8));
*retval = X;
return PointerGetDatum(retval);
-#endif /* INT64_IS_BUSTED */
+#endif /* INT64_IS_BUSTED */
}
Datum
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.38 2001/10/05 17:28:13 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.39 2001/10/25 05:49:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static void *DynaHashAlloc(Size size);
static uint32 call_hash(HTAB *hashp, void *k);
static HASHSEGMENT seg_alloc(HTAB *hashp);
-static bool element_alloc(HTAB *hashp);
-static bool dir_realloc(HTAB *hashp);
-static bool expand_table(HTAB *hashp);
-static bool hdefault(HTAB *hashp);
-static bool init_htab(HTAB *hashp, long nelem);
+static bool element_alloc(HTAB *hashp);
+static bool dir_realloc(HTAB *hashp);
+static bool expand_table(HTAB *hashp);
+static bool hdefault(HTAB *hashp);
+static bool init_htab(HTAB *hashp, long nelem);
static void hash_corrupted(HTAB *hashp);
hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
{
HTAB *hashp;
- HASHHDR *hctl;
+ HASHHDR *hctl;
/* First time through, create a memory context for hash tables */
if (!DynaHashCxt)
if (flags & HASH_FUNCTION)
hashp->hash = info->hash;
else
- hashp->hash = string_hash; /* default hash function */
+ hashp->hash = string_hash; /* default hash function */
if (flags & HASH_SHARED_MEM)
{
{
/* hash table structures live in child of given context */
CurrentDynaHashCxt = AllocSetContextCreate(info->hcxt,
- "DynaHashTable",
- ALLOCSET_DEFAULT_MINSIZE,
- ALLOCSET_DEFAULT_INITSIZE,
- ALLOCSET_DEFAULT_MAXSIZE);
+ "DynaHashTable",
+ ALLOCSET_DEFAULT_MINSIZE,
+ ALLOCSET_DEFAULT_INITSIZE,
+ ALLOCSET_DEFAULT_MAXSIZE);
hashp->hcxt = CurrentDynaHashCxt;
}
else
{
/* hash table structures live in child of DynaHashCxt */
CurrentDynaHashCxt = AllocSetContextCreate(DynaHashCxt,
- "DynaHashTable",
- ALLOCSET_DEFAULT_MINSIZE,
- ALLOCSET_DEFAULT_INITSIZE,
- ALLOCSET_DEFAULT_MAXSIZE);
+ "DynaHashTable",
+ ALLOCSET_DEFAULT_MINSIZE,
+ ALLOCSET_DEFAULT_INITSIZE,
+ ALLOCSET_DEFAULT_MAXSIZE);
hashp->hcxt = CurrentDynaHashCxt;
}
}
static bool
hdefault(HTAB *hashp)
{
- HASHHDR *hctl = hashp->hctl;
+ HASHHDR *hctl = hashp->hctl;
MemSet(hctl, 0, sizeof(HASHHDR));
static bool
init_htab(HTAB *hashp, long nelem)
{
- HASHHDR *hctl = hashp->hctl;
+ HASHHDR *hctl = hashp->hctl;
HASHSEGMENT *segp;
int nbuckets;
int nsegs;
nDirEntries <<= 1; /* dir_alloc doubles dsize at each call */
/* fixed control info */
- size += MAXALIGN(sizeof(HASHHDR)); /* but not HTAB, per above */
+ size += MAXALIGN(sizeof(HASHHDR)); /* but not HTAB, per above */
/* directory */
size += MAXALIGN(nDirEntries * sizeof(HASHSEGMENT));
/* segments */
hash_stats("destroy", hashp);
/*
- * Free buckets, dir etc. by destroying the hash table's
- * memory context.
+ * Free buckets, dir etc. by destroying the hash table's memory
+ * context.
*/
MemoryContextDelete(hashp->hcxt);
/*
- * Free the HTAB and control structure, which are allocated
- * in the parent context (DynaHashCxt or the context given
- * by the caller of hash_create()).
+ * Free the HTAB and control structure, which are allocated in the
+ * parent context (DynaHashCxt or the context given by the caller
+ * of hash_create()).
*/
MEM_FREE(hashp->hctl);
MEM_FREE(hashp->tabname);
where, hash_accesses, hash_collisions);
fprintf(stderr, "hash_stats: total expansions %ld\n",
hash_expansions);
-
#endif
}
static uint32
call_hash(HTAB *hashp, void *k)
{
- HASHHDR *hctl = hashp->hctl;
+ HASHHDR *hctl = hashp->hctl;
long hash_val,
bucket;
* HASH_ENTER case, but is redundant with the return value otherwise.
*
* The HASH_FIND_SAVE/HASH_REMOVE_SAVED interface is a hack to save one
- * table lookup in a find/process/remove scenario. Note that no other
+ * table lookup in a find/process/remove scenario. Note that no other
* addition or removal in the table can safely happen in between.
*----------
*/
HASHACTION action,
bool *foundPtr)
{
- HASHHDR *hctl = hashp->hctl;
+ HASHHDR *hctl = hashp->hctl;
uint32 bucket;
long segment_num;
long segment_ndx;
- HASHSEGMENT segp;
- HASHBUCKET currBucket;
+ HASHSEGMENT segp;
+ HASHBUCKET currBucket;
HASHBUCKET *prevBucketPtr;
static struct State
{
- HASHBUCKET currBucket;
+ HASHBUCKET currBucket;
HASHBUCKET *prevBucketPtr;
} saveState;
{
/* no free elements. allocate another chunk of buckets */
if (!element_alloc(hashp))
- return NULL; /* out of memory */
+ return NULL; /* out of memory */
currBucket = hctl->freeList;
Assert(currBucket != NULL);
}
if (++hctl->nentries / (hctl->max_bucket + 1) > hctl->ffactor)
{
/*
- * NOTE: failure to expand table is not a fatal error, it just
- * means we have to run at higher fill factor than we wanted.
+ * NOTE: failure to expand table is not a fatal error, it
+ * just means we have to run at higher fill factor than we
+ * wanted.
*/
expand_table(hashp);
}
hash_seq_search(HASH_SEQ_STATUS *status)
{
HTAB *hashp = status->hashp;
- HASHHDR *hctl = hashp->hctl;
+ HASHHDR *hctl = hashp->hctl;
while (status->curBucket <= hctl->max_bucket)
{
long segment_num;
long segment_ndx;
- HASHSEGMENT segp;
+ HASHSEGMENT segp;
if (status->curEntry != NULL)
{
curElem = status->curEntry;
status->curEntry = curElem->link;
- if (status->curEntry == NULL) /* end of this bucket */
+ if (status->curEntry == NULL) /* end of this bucket */
++status->curBucket;
return (void *) ELEMENTKEY(curElem);
}
*/
status->curEntry = segp[segment_ndx];
- if (status->curEntry == NULL) /* empty bucket */
+ if (status->curEntry == NULL) /* empty bucket */
++status->curBucket;
}
static bool
expand_table(HTAB *hashp)
{
- HASHHDR *hctl = hashp->hctl;
- HASHSEGMENT old_seg,
+ HASHHDR *hctl = hashp->hctl;
+ HASHSEGMENT old_seg,
new_seg;
long old_bucket,
new_bucket;
old_segndx;
HASHBUCKET *oldlink,
*newlink;
- HASHBUCKET currElement,
+ HASHBUCKET currElement,
nextElement;
#ifdef HASH_STATISTICS
static HASHSEGMENT
seg_alloc(HTAB *hashp)
{
- HASHSEGMENT segp;
+ HASHSEGMENT segp;
CurrentDynaHashCxt = hashp->hcxt;
segp = (HASHSEGMENT) hashp->alloc(sizeof(HASHBUCKET) * hashp->hctl->ssize);
static bool
element_alloc(HTAB *hashp)
{
- HASHHDR *hctl = hashp->hctl;
+ HASHHDR *hctl = hashp->hctl;
Size elementSize;
HASHELEMENT *tmpElement;
int i;
{
/*
* If the corruption is in a shared hashtable, we'd better force a
- * systemwide restart. Otherwise, just shut down this one backend.
+ * systemwide restart. Otherwise, just shut down this one backend.
*/
if (hashp->isshared)
elog(STOP, "Hash table '%s' corrupted", hashp->tabname);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/hash/hashfn.c,v 1.14 2001/10/01 05:36:16 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/hash/hashfn.c,v 1.15 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* Use four byte chunks in a "jump table" to go a little faster.
*
* Currently the maximum keysize is 16 (mar 17 1992). I have put in
- * cases for up to 32. Bigger than this will resort to a for loop
+ * cases for up to 32. Bigger than this will resort to a for loop
* (see the default case).
*/
switch (keysize)
{
case 8 * sizeof(int):
- h = (h * PRIME1) ^ (*k++);
+ h = (h * PRIME1) ^(*k++);
/* fall through */
case 7 * sizeof(int):
- h = (h * PRIME1) ^ (*k++);
+ h = (h * PRIME1) ^(*k++);
/* fall through */
case 6 * sizeof(int):
- h = (h * PRIME1) ^ (*k++);
+ h = (h * PRIME1) ^(*k++);
/* fall through */
case 5 * sizeof(int):
- h = (h * PRIME1) ^ (*k++);
+ h = (h * PRIME1) ^(*k++);
/* fall through */
case 4 * sizeof(int):
- h = (h * PRIME1) ^ (*k++);
+ h = (h * PRIME1) ^(*k++);
/* fall through */
case 3 * sizeof(int):
- h = (h * PRIME1) ^ (*k++);
+ h = (h * PRIME1) ^(*k++);
/* fall through */
case 2 * sizeof(int):
- h = (h * PRIME1) ^ (*k++);
+ h = (h * PRIME1) ^(*k++);
/* fall through */
case sizeof(int):
- h = (h * PRIME1) ^ (*k++);
+ h = (h * PRIME1) ^(*k++);
break;
default:
/* Cope with any partial-int leftover bytes */
if (keysize > 0)
{
- unsigned char *keybyte = (unsigned char *) k;
+ unsigned char *keybyte = (unsigned char *) k;
do
h = (h * PRIME1) ^ (*keybyte++);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/hash/pg_crc.c,v 1.3 2001/03/23 18:42:12 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/hash/pg_crc.c,v 1.4 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
INT64CONST(0x5DEDC41A34BBEEB2), INT64CONST(0x1F1D25F19D51D821),
INT64CONST(0xD80C07CD676F8394), INT64CONST(0x9AFCE626CE85B507)
};
-
#endif /* INT64_IS_BUSTED */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.61 2001/10/21 03:25:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.62 2001/10/25 05:49:51 momjian Exp $
*
* NOTES
* Globals used all over the place should be declared here and not
char OutputFileName[MAXPGPATH];
-char pg_pathname[MAXPGPATH]; /* full path to postgres executable */
+char pg_pathname[MAXPGPATH]; /* full path to postgres
+ * executable */
BackendId MyBackendId;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.80 2001/10/19 18:19:41 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.81 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (c != '\n')
{
-
/*
* build a token in buf of next characters up to EOF, eol, or
* blank.
if (p && *p != '\0')
{
- map_file = malloc(strlen(DataDir) + strlen(p) + 2);
- if (! map_file)
+ map_file = malloc(strlen(DataDir) + strlen(p) + 2);
+ if (!map_file)
elog(FATAL, "out of memory");
sprintf(map_file, "%s/%s", DataDir, p);
file = AllocateFile(map_file, PG_BINARY_R);
}
return ch;
}
-
#endif
/*
* Change session auth ID while running
*/
-void SetSessionAuthorization(const char * username)
+void
+SetSessionAuthorization(const char *username)
{
int32 userid;
pid_t my_pid = getpid();
/*
- * We need a loop here because of race conditions. But don't loop
+ * We need a loop here because of race conditions. But don't loop
* forever (for example, a non-writable $PGDATA directory might cause
* a failure that won't go away). 100 tries seems like plenty.
*/
- for (ntries = 0; ; ntries++)
+ for (ntries = 0;; ntries++)
{
-
/*
* Try to create the lock file --- O_EXCL makes this atomic.
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.94 2001/10/19 17:03:08 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.95 2001/10/25 05:49:51 momjian Exp $
*
*
*-------------------------------------------------------------------------
char *fullpath,
datpath[MAXPGPATH];
- /* Formerly we validated DataDir here, but now that's done earlier. */
+ /*
+ * Formerly we validated DataDir here, but now that's done
+ * earlier.
+ */
/*
* Find oid and path of the database we're about to open. Since
*/
/*
- * Set up my per-backend PROC struct in shared memory. (We need to
+ * Set up my per-backend PROC struct in shared memory. (We need to
* know MyDatabaseId before we can do this, since it's entered into
* the PROC struct.)
*/
AmiTransactionOverride(bootstrap);
/*
- * Initialize the relation descriptor cache.
- * The pre-allocated reldescs are created here.
+ * Initialize the relation descriptor cache. The pre-allocated
+ * reldescs are created here.
*/
RelationCacheInitialize();
RelationCacheInitializePhase2();
/*
- * Figure out our postgres user id. In standalone mode we use a
- * fixed id, otherwise we figure it out from the authenticated
- * user name.
+ * Figure out our postgres user id. In standalone mode we use a fixed
+ * id, otherwise we figure it out from the authenticated user name.
*/
if (bootstrap)
InitializeSessionUserIdStandalone();
static void
ShutdownPostgres(void)
{
-
/*
* These operations are really just a minimal subset of
* AbortTransaction(). We don't want to do any inessential cleanup,
* has to happen before bufmgr shutdown, so having smgr register a
* callback for it wouldn't work.
*/
- smgrDoPendingDeletes(false);/* delete as though aborting xact */
+ smgrDoPendingDeletes(false); /* delete as though aborting xact */
}
*
* 1999/1/15 Tatsuo Ishii
*
- * $Id: big5.c,v 1.7 2001/02/10 02:31:27 tgl Exp $
+ * $Id: big5.c,v 1.8 2001/10/25 05:49:51 momjian Exp $
*/
/* can be used in either frontend or backend */
{
unsigned short code,
peer;
-} codes_t;
+} codes_t;
/* map Big5 Level 1 to CNS 11643-1992 Plane 1 */
static codes_t big5Level1ToCnsPlane1[25] = { /* range */
};
static unsigned short BinarySearchRange
- (codes_t * array, int high, unsigned short code)
+ (codes_t *array, int high, unsigned short code)
{
int low,
mid,
* WIN1250 client encoding support contributed by Pavel Behal
* SJIS UDC (NEC selection IBM kanji) support contributed by Eiji Tokuya
*
- * $Id: conv.c,v 1.32 2001/10/16 10:09:17 ishii Exp $
+ * $Id: conv.c,v 1.33 2001/10/25 05:49:51 momjian Exp $
*
*
*/
#include "Unicode/utf8_to_koi8r.map"
#include "Unicode/utf8_to_win1251.map"
-
#endif /* UNICODE_CONVERSION */
/*
}
else if (c1 > 0x7f)
{
-
/*
* JIS X0208, X0212, user defined extended characters
*/
}
else if (k >= 0xf040 && k < 0xf540)
{
-
/*
* UDC1 mapping to X0208 85 ku - 94 ku JIS code 0x7521 -
* 0x7e7e EUC 0xf5a1 - 0xfefe
}
else if (k >= 0xf540 && k < 0xfa40)
{
-
/*
* UDC2 mapping to X0212 85 ku - 94 ku JIS code 0x7521 -
* 0x7e7e EUC 0x8ff5a1 - 0x8ffefe
}
else if (k >= 0xfa40)
{
-
/*
* mapping IBM kanji to X0208 and X0212
*
{
if (lc == LC_CNS11643_3 || lc == LC_CNS11643_4)
{
- *p++ = 0x9d;/* LCPRV2 */
+ *p++ = 0x9d; /* LCPRV2 */
}
*p++ = lc; /* Plane No. */
*p++ = (cnsBuf >> 8) & 0x00ff;
{
mic2latin(mic, p, len, LC_ISO8859_5);
}
-
#endif
/*
*/
static void
utf_to_local(unsigned char *utf, unsigned char *iso,
- pg_utf_to_local * map, int size, int len)
+ pg_utf_to_local *map, int size, int len)
{
unsigned int iutf;
int l;
{
utf_to_local(utf, iso, ULmapISO8859_5, sizeof(ULmapISO8859_5) / sizeof(pg_utf_to_local), len);
}
-#endif /* NOT_USED */
+#endif /* NOT_USED */
/*
* Cyrillic charsets
*/
/*
- * UTF-8 --->KOI8-R
+ * UTF-8 --->KOI8-R
*/
static void
utf_to_KOI8R(unsigned char *utf, unsigned char *iso, int len)
}
/*
- * UTF-8 --->WIN1251
+ * UTF-8 --->WIN1251
*/
static void
utf_to_WIN1251(unsigned char *utf, unsigned char *iso, int len)
}
/*
- * UTF-8 --->ALT
+ * UTF-8 --->ALT
*/
static void
utf_to_ALT(unsigned char *utf, unsigned char *iso, int len)
*/
static void
local_to_utf(unsigned char *iso, unsigned char *utf,
- pg_local_to_utf * map, int size, int encoding, int len)
+ pg_local_to_utf *map, int size, int encoding, int len)
{
unsigned int iiso;
int l;
if (p == NULL)
{
elog(NOTICE, "local_to_utf: could not convert (0x%04x) %s to UTF-8. Ignored",
- iiso, (&pg_enc2name_tbl[ encoding ])->name);
+ iiso, (&pg_enc2name_tbl[encoding])->name);
continue;
}
if (p->utf & 0xff000000)
{
local_to_utf(iso, utf, LUmapISO8859_5, sizeof(LUmapISO8859_5) / sizeof(pg_local_to_utf), PG_LATIN5, len);
}
-#endif /* NOT_USED */
+#endif /* NOT_USED */
#define UTF_ISO8859(_id_) \
static void \
{
local_to_utf(iso, utf, LUmapALT, sizeof(LUmapALT) / sizeof(pg_local_to_utf), PG_ALT, len);
}
+
/*
* UTF-8 ---> EUC_JP
*/
euc_jp_to_utf(unsigned char *euc, unsigned char *utf, int len)
{
local_to_utf(euc, utf, LUmapEUC_JP,
- sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len);
+ sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len);
}
/*
euc_cn_to_utf(unsigned char *euc, unsigned char *utf, int len)
{
local_to_utf(euc, utf, LUmapEUC_CN,
- sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len);
+ sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len);
}
/*
euc_kr_to_utf(unsigned char *euc, unsigned char *utf, int len)
{
local_to_utf(euc, utf, LUmapEUC_KR,
- sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len);
+ sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len);
}
/*
euc_tw_to_utf(unsigned char *euc, unsigned char *utf, int len)
{
local_to_utf(euc, utf, LUmapEUC_TW,
- sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len);
+ sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len);
}
/*
sjis_to_utf(unsigned char *euc, unsigned char *utf, int len)
{
local_to_utf(euc, utf, LUmapSJIS,
- sizeof(LUmapSJIS) / sizeof(pg_local_to_utf), PG_SJIS, len);
+ sizeof(LUmapSJIS) / sizeof(pg_local_to_utf), PG_SJIS, len);
}
/*
big5_to_utf(unsigned char *euc, unsigned char *utf, int len)
{
local_to_utf(euc, utf, LUmapBIG5,
- sizeof(LUmapBIG5) / sizeof(pg_local_to_utf), PG_BIG5, len);
+ sizeof(LUmapBIG5) / sizeof(pg_local_to_utf), PG_BIG5, len);
}
/* ----------
* WARINIG: must by same order as pg_enc in include/mb/pg_wchar.h!
* ----------
*/
-pg_enconv pg_enconv_tbl[] =
-{
- { PG_SQL_ASCII, ascii2mic, mic2ascii, ascii2utf, utf2ascii},
- { PG_EUC_JP, euc_jp2mic, mic2euc_jp, euc_jp_to_utf, utf_to_euc_jp},
- { PG_EUC_CN, euc_cn2mic, mic2euc_cn, euc_cn_to_utf, utf_to_euc_cn},
- { PG_EUC_KR, euc_kr2mic, mic2euc_kr, euc_kr_to_utf, utf_to_euc_kr},
- { PG_EUC_TW, euc_tw2mic, mic2euc_tw, euc_tw_to_utf, utf_to_euc_tw},
- { PG_UTF8, 0, 0, 0, 0},
- { PG_MULE_INTERNAL, 0, 0, 0, 0},
- { PG_LATIN1, latin12mic, mic2latin1, iso8859_1_to_utf, utf_to_iso8859_1},
- { PG_LATIN2, latin22mic, mic2latin2, iso8859_2_to_utf, utf_to_iso8859_2},
- { PG_LATIN3, latin32mic, mic2latin3, iso8859_3_to_utf, utf_to_iso8859_3},
- { PG_LATIN4, latin42mic, mic2latin4, iso8859_4_to_utf, utf_to_iso8859_4},
- { PG_LATIN5, iso2mic, mic2iso, iso8859_9_to_utf, utf_to_iso8859_9},
- { PG_LATIN6, 0, 0, iso8859_10_to_utf, utf_to_iso8859_10},
- { PG_LATIN7, 0, 0, iso8859_13_to_utf, utf_to_iso8859_13},
- { PG_LATIN8, 0, 0, iso8859_14_to_utf, utf_to_iso8859_14},
- { PG_LATIN9, 0, 0, iso8859_15_to_utf, utf_to_iso8859_15},
- { PG_LATIN10, 0, 0, iso8859_16_to_utf, utf_to_iso8859_16},
- { PG_KOI8R, koi8r2mic, mic2koi8r, KOI8R_to_utf, utf_to_KOI8R},
- { PG_WIN1251, win12512mic, mic2win1251, WIN1251_to_utf, utf_to_WIN1251},
- { PG_ALT, alt2mic, mic2alt, ALT_to_utf, utf_to_ALT},
- { PG_ISO_8859_5, 0, 0, iso8859_5_to_utf, utf_to_iso8859_5},
- { PG_ISO_8859_6, 0, 0, iso8859_6_to_utf, utf_to_iso8859_6},
- { PG_ISO_8859_7, 0, 0, iso8859_7_to_utf, utf_to_iso8859_7},
- { PG_ISO_8859_8, 0, 0, iso8859_8_to_utf, utf_to_iso8859_8},
-
- { PG_SJIS, sjis2mic, mic2sjis, sjis_to_utf, utf_to_sjis},
- { PG_BIG5, big52mic, mic2big5, big5_to_utf, utf_to_big5},
- { PG_WIN1250, win12502mic, mic2win1250, 0, 0},
+pg_enconv pg_enconv_tbl[] =
+{
+ {
+ PG_SQL_ASCII, ascii2mic, mic2ascii, ascii2utf, utf2ascii
+ } ,
+ {
+ PG_EUC_JP, euc_jp2mic, mic2euc_jp, euc_jp_to_utf, utf_to_euc_jp
+ },
+ {
+ PG_EUC_CN, euc_cn2mic, mic2euc_cn, euc_cn_to_utf, utf_to_euc_cn
+ },
+ {
+ PG_EUC_KR, euc_kr2mic, mic2euc_kr, euc_kr_to_utf, utf_to_euc_kr
+ },
+ {
+ PG_EUC_TW, euc_tw2mic, mic2euc_tw, euc_tw_to_utf, utf_to_euc_tw
+ },
+ {
+ PG_UTF8, 0, 0, 0, 0
+ },
+ {
+ PG_MULE_INTERNAL, 0, 0, 0, 0
+ },
+ {
+ PG_LATIN1, latin12mic, mic2latin1, iso8859_1_to_utf, utf_to_iso8859_1
+ },
+ {
+ PG_LATIN2, latin22mic, mic2latin2, iso8859_2_to_utf, utf_to_iso8859_2
+ },
+ {
+ PG_LATIN3, latin32mic, mic2latin3, iso8859_3_to_utf, utf_to_iso8859_3
+ },
+ {
+ PG_LATIN4, latin42mic, mic2latin4, iso8859_4_to_utf, utf_to_iso8859_4
+ },
+ {
+ PG_LATIN5, iso2mic, mic2iso, iso8859_9_to_utf, utf_to_iso8859_9
+ },
+ {
+ PG_LATIN6, 0, 0, iso8859_10_to_utf, utf_to_iso8859_10
+ },
+ {
+ PG_LATIN7, 0, 0, iso8859_13_to_utf, utf_to_iso8859_13
+ },
+ {
+ PG_LATIN8, 0, 0, iso8859_14_to_utf, utf_to_iso8859_14
+ },
+ {
+ PG_LATIN9, 0, 0, iso8859_15_to_utf, utf_to_iso8859_15
+ },
+ {
+ PG_LATIN10, 0, 0, iso8859_16_to_utf, utf_to_iso8859_16
+ },
+ {
+ PG_KOI8R, koi8r2mic, mic2koi8r, KOI8R_to_utf, utf_to_KOI8R
+ },
+ {
+ PG_WIN1251, win12512mic, mic2win1251, WIN1251_to_utf, utf_to_WIN1251
+ },
+ {
+ PG_ALT, alt2mic, mic2alt, ALT_to_utf, utf_to_ALT
+ },
+ {
+ PG_ISO_8859_5, 0, 0, iso8859_5_to_utf, utf_to_iso8859_5
+ },
+ {
+ PG_ISO_8859_6, 0, 0, iso8859_6_to_utf, utf_to_iso8859_6
+ },
+ {
+ PG_ISO_8859_7, 0, 0, iso8859_7_to_utf, utf_to_iso8859_7
+ },
+ {
+ PG_ISO_8859_8, 0, 0, iso8859_8_to_utf, utf_to_iso8859_8
+ },
+
+ {
+ PG_SJIS, sjis2mic, mic2sjis, sjis_to_utf, utf_to_sjis
+ },
+ {
+ PG_BIG5, big52mic, mic2big5, big5_to_utf, utf_to_big5
+ },
+ {
+ PG_WIN1250, win12502mic, mic2win1250, 0, 0
+ },
};
#else
-pg_enconv pg_enconv_tbl[] =
-{
- { PG_SQL_ASCII, ascii2mic, mic2ascii, 0, 0},
- { PG_EUC_JP, euc_jp2mic, mic2euc_jp, 0, 0},
- { PG_EUC_CN, euc_cn2mic, mic2euc_cn, 0, 0},
- { PG_EUC_KR, euc_kr2mic, mic2euc_kr, 0, 0},
- { PG_EUC_TW, euc_tw2mic, mic2euc_tw, 0, 0},
- { PG_UTF8, 0, 0, 0, 0},
- { PG_MULE_INTERNAL, 0, 0, 0, 0},
- { PG_LATIN1, latin12mic, mic2latin1, 0, 0},
- { PG_LATIN2, latin22mic, mic2latin2, 0, 0},
- { PG_LATIN3, latin32mic, mic2latin3, 0, 0},
- { PG_LATIN4, latin42mic, mic2latin4, 0, 0},
- { PG_LATIN5, iso2mic, mic2iso, 0, 0},
- { PG_LATIN6, 0, 0, 0, 0},
- { PG_LATIN7, 0, 0, 0, 0},
- { PG_LATIN8, 0, 0, 0, 0},
- { PG_LATIN9, 0, 0, 0, 0},
- { PG_LATIN10, 0, 0, 0, 0},
- { PG_KOI8R, koi8r2mic, mic2koi8r, 0, 0},
- { PG_WIN1251, win12512mic, mic2win1251, 0, 0},
- { PG_ALT, alt2mic, mic2alt, 0, 0},
- { PG_ISO_8859_5, 0, 0, 0, 0},
- { PG_ISO_8859_6, 0, 0, 0, 0},
- { PG_ISO_8859_7, 0, 0, 0, 0},
- { PG_ISO_8859_8, 0, 0, 0, 0},
- { PG_SJIS, sjis2mic, mic2sjis, 0, 0},
- { PG_BIG5, big52mic, mic2big5, 0, 0},
- { PG_WIN1250, win12502mic, mic2win1250, 0, 0},
+pg_enconv pg_enconv_tbl[] =
+{
+ {
+ PG_SQL_ASCII, ascii2mic, mic2ascii, 0, 0
+ } ,
+ {
+ PG_EUC_JP, euc_jp2mic, mic2euc_jp, 0, 0
+ },
+ {
+ PG_EUC_CN, euc_cn2mic, mic2euc_cn, 0, 0
+ },
+ {
+ PG_EUC_KR, euc_kr2mic, mic2euc_kr, 0, 0
+ },
+ {
+ PG_EUC_TW, euc_tw2mic, mic2euc_tw, 0, 0
+ },
+ {
+ PG_UTF8, 0, 0, 0, 0
+ },
+ {
+ PG_MULE_INTERNAL, 0, 0, 0, 0
+ },
+ {
+ PG_LATIN1, latin12mic, mic2latin1, 0, 0
+ },
+ {
+ PG_LATIN2, latin22mic, mic2latin2, 0, 0
+ },
+ {
+ PG_LATIN3, latin32mic, mic2latin3, 0, 0
+ },
+ {
+ PG_LATIN4, latin42mic, mic2latin4, 0, 0
+ },
+ {
+ PG_LATIN5, iso2mic, mic2iso, 0, 0
+ },
+ {
+ PG_LATIN6, 0, 0, 0, 0
+ },
+ {
+ PG_LATIN7, 0, 0, 0, 0
+ },
+ {
+ PG_LATIN8, 0, 0, 0, 0
+ },
+ {
+ PG_LATIN9, 0, 0, 0, 0
+ },
+ {
+ PG_LATIN10, 0, 0, 0, 0
+ },
+ {
+ PG_KOI8R, koi8r2mic, mic2koi8r, 0, 0
+ },
+ {
+ PG_WIN1251, win12512mic, mic2win1251, 0, 0
+ },
+ {
+ PG_ALT, alt2mic, mic2alt, 0, 0
+ },
+ {
+ PG_ISO_8859_5, 0, 0, 0, 0
+ },
+ {
+ PG_ISO_8859_6, 0, 0, 0, 0
+ },
+ {
+ PG_ISO_8859_7, 0, 0, 0, 0
+ },
+ {
+ PG_ISO_8859_8, 0, 0, 0, 0
+ },
+ {
+ PG_SJIS, sjis2mic, mic2sjis, 0, 0
+ },
+ {
+ PG_BIG5, big52mic, mic2big5, 0, 0
+ },
+ {
+ PG_WIN1250, win12502mic, mic2win1250, 0, 0
+ },
};
-
#endif /* UNICODE_CONVERSION */
* Encoding names and routines for work with it. All
* in this file is shared bedween FE and BE.
*
- * $Id: encnames.c,v 1.4 2001/10/16 10:09:17 ishii Exp $
+ * $Id: encnames.c,v 1.5 2001/10/25 05:49:51 momjian Exp $
*/
#ifdef FRONTEND
#include "postgres_fe.h"
#include
/* ----------
- * All encoding names, sorted: *** A L P H A B E T I C ***
+ * All encoding names, sorted: *** A L P H A B E T I C ***
*
* All names must be without irrelevan chars, search routines use
* isalnum() chars only. It means ISO-8859-1, iso_8859-1 and Iso8859_1
* Karel Zak, Aug 2001
* ----------
*/
-pg_encname pg_encname_tbl[] =
+pg_encname pg_encname_tbl[] =
{
- { "alt", PG_ALT }, /* IBM866 */
- { "big5", PG_BIG5 }, /* Big5; Chinese for Taiwan Multi-byte set */
- { "euccn", PG_EUC_CN }, /* EUC-CN; Extended Unix Code for simplified Chinese */
- { "eucjp", PG_EUC_JP }, /* EUC-JP; Extended UNIX Code fixed Width for Japanese, stdandard OSF */
- { "euckr", PG_EUC_KR }, /* EUC-KR; RFC1557,Choi */
- { "euctw", PG_EUC_TW }, /* EUC-TW; Extended Unix Code for traditional Chinese */
- { "iso88591", PG_LATIN1 }, /* ISO-8859-1; RFC1345,KXS2 */
- { "iso885910", PG_LATIN6 }, /* ISO-8859-10; RFC1345,KXS2 */
- { "iso885913", PG_LATIN7 }, /* ISO-8859-13; RFC1345,KXS2 */
- { "iso885914", PG_LATIN8 }, /* ISO-8859-14; RFC1345,KXS2 */
- { "iso885915", PG_LATIN9 }, /* ISO-8859-15; RFC1345,KXS2 */
- { "iso885916", PG_LATIN10 }, /* ISO-8859-16; RFC1345,KXS2 */
- { "iso88592", PG_LATIN2 }, /* ISO-8859-2; RFC1345,KXS2 */
- { "iso88593", PG_LATIN3 }, /* ISO-8859-3; RFC1345,KXS2 */
- { "iso88594", PG_LATIN4 }, /* ISO-8859-4; RFC1345,KXS2 */
- { "iso88595", PG_ISO_8859_5 }, /* ISO-8859-5; RFC1345,KXS2 */
- { "iso88596", PG_ISO_8859_6 }, /* ISO-8859-6; RFC1345,KXS2 */
- { "iso88597", PG_ISO_8859_7 }, /* ISO-8859-7; RFC1345,KXS2 */
- { "iso88598", PG_ISO_8859_8 }, /* ISO-8859-8; RFC1345,KXS2 */
- { "iso88599", PG_LATIN5 }, /* ISO-8859-9; RFC1345,KXS2 */
- { "koi8", PG_KOI8R }, /* _dirty_ alias for KOI8-R (backward compatibility) */
- { "koi8r", PG_KOI8R }, /* KOI8-R; RFC1489 */
- { "latin1", PG_LATIN1 }, /* alias for ISO-8859-1 */
- { "latin10", PG_LATIN10}, /* alias for ISO-8859-16 */
- { "latin2", PG_LATIN2 }, /* alias for ISO-8859-2 */
- { "latin3", PG_LATIN3 }, /* alias for ISO-8859-3 */
- { "latin4", PG_LATIN4 }, /* alias for ISO-8859-4 */
- { "latin5", PG_LATIN5 }, /* alias for ISO-8859-9 */
- { "latin6", PG_LATIN6}, /* alias for ISO-8859-10 */
- { "latin7", PG_LATIN7}, /* alias for ISO-8859-13 */
- { "latin8", PG_LATIN8}, /* alias for ISO-8859-14 */
- { "latin9", PG_LATIN9}, /* alias for ISO-8859-15 */
- { "mskanji", PG_SJIS }, /* alias for Shift_JIS */
- { "muleinternal",PG_MULE_INTERNAL },
- { "shiftjis", PG_SJIS }, /* Shift_JIS; JIS X 0202-1991 */
- { "sjis", PG_SJIS }, /* alias for Shift_JIS */
- { "sqlascii", PG_SQL_ASCII },
- { "unicode", PG_UTF8 }, /* alias for UTF-8 */
- { "utf8", PG_UTF8 }, /* UTF-8; RFC2279 */
- { "win", PG_WIN1251 }, /* _dirty_ alias for windows-1251 (backward compatibility) */
- { "win1250", PG_WIN1250 }, /* alias for Windows-1250 */
- { "win1251", PG_WIN1251 }, /* alias for Windows-1251 */
- { "windows1250",PG_WIN1250 }, /* Windows-1251; Microsoft */
- { "windows1251",PG_WIN1251 }, /* Windows-1251; Microsoft */
+ {
+ "alt", PG_ALT
+ } , /* IBM866 */
+ {
+ "big5", PG_BIG5
+ }, /* Big5; Chinese for Taiwan Multi-byte set */
+ {
+ "euccn", PG_EUC_CN
+ }, /* EUC-CN; Extended Unix Code for
+ * simplified Chinese */
+ {
+ "eucjp", PG_EUC_JP
+ }, /* EUC-JP; Extended UNIX Code fixed Width
+ * for Japanese, stdandard OSF */
+ {
+ "euckr", PG_EUC_KR
+ }, /* EUC-KR; RFC1557,Choi */
+ {
+ "euctw", PG_EUC_TW
+ }, /* EUC-TW; Extended Unix Code for
+ * traditional Chinese */
+ {
+ "iso88591", PG_LATIN1
+ }, /* ISO-8859-1; RFC1345,KXS2 */
+ {
+ "iso885910", PG_LATIN6
+ }, /* ISO-8859-10; RFC1345,KXS2 */
+ {
+ "iso885913", PG_LATIN7
+ }, /* ISO-8859-13; RFC1345,KXS2 */
+ {
+ "iso885914", PG_LATIN8
+ }, /* ISO-8859-14; RFC1345,KXS2 */
+ {
+ "iso885915", PG_LATIN9
+ }, /* ISO-8859-15; RFC1345,KXS2 */
+ {
+ "iso885916", PG_LATIN10
+ }, /* ISO-8859-16; RFC1345,KXS2 */
+ {
+ "iso88592", PG_LATIN2
+ }, /* ISO-8859-2; RFC1345,KXS2 */
+ {
+ "iso88593", PG_LATIN3
+ }, /* ISO-8859-3; RFC1345,KXS2 */
+ {
+ "iso88594", PG_LATIN4
+ }, /* ISO-8859-4; RFC1345,KXS2 */
+ {
+ "iso88595", PG_ISO_8859_5
+ }, /* ISO-8859-5; RFC1345,KXS2 */
+ {
+ "iso88596", PG_ISO_8859_6
+ }, /* ISO-8859-6; RFC1345,KXS2 */
+ {
+ "iso88597", PG_ISO_8859_7
+ }, /* ISO-8859-7; RFC1345,KXS2 */
+ {
+ "iso88598", PG_ISO_8859_8
+ }, /* ISO-8859-8; RFC1345,KXS2 */
+ {
+ "iso88599", PG_LATIN5
+ }, /* ISO-8859-9; RFC1345,KXS2 */
+ {
+ "koi8", PG_KOI8R
+ }, /* _dirty_ alias for KOI8-R (backward
+ * compatibility) */
+ {
+ "koi8r", PG_KOI8R
+ }, /* KOI8-R; RFC1489 */
+ {
+ "latin1", PG_LATIN1
+ }, /* alias for ISO-8859-1 */
+ {
+ "latin10", PG_LATIN10
+ }, /* alias for ISO-8859-16 */
+ {
+ "latin2", PG_LATIN2
+ }, /* alias for ISO-8859-2 */
+ {
+ "latin3", PG_LATIN3
+ }, /* alias for ISO-8859-3 */
+ {
+ "latin4", PG_LATIN4
+ }, /* alias for ISO-8859-4 */
+ {
+ "latin5", PG_LATIN5
+ }, /* alias for ISO-8859-9 */
+ {
+ "latin6", PG_LATIN6
+ }, /* alias for ISO-8859-10 */
+ {
+ "latin7", PG_LATIN7
+ }, /* alias for ISO-8859-13 */
+ {
+ "latin8", PG_LATIN8
+ }, /* alias for ISO-8859-14 */
+ {
+ "latin9", PG_LATIN9
+ }, /* alias for ISO-8859-15 */
+ {
+ "mskanji", PG_SJIS
+ }, /* alias for Shift_JIS */
+ {
+ "muleinternal", PG_MULE_INTERNAL
+ },
+ {
+ "shiftjis", PG_SJIS
+ }, /* Shift_JIS; JIS X 0202-1991 */
+ {
+ "sjis", PG_SJIS
+ }, /* alias for Shift_JIS */
+ {
+ "sqlascii", PG_SQL_ASCII
+ },
+ {
+ "unicode", PG_UTF8
+ }, /* alias for UTF-8 */
+ {
+ "utf8", PG_UTF8
+ }, /* UTF-8; RFC2279 */
+ {
+ "win", PG_WIN1251
+ }, /* _dirty_ alias for windows-1251
+ * (backward compatibility) */
+ {
+ "win1250", PG_WIN1250
+ }, /* alias for Windows-1250 */
+ {
+ "win1251", PG_WIN1251
+ }, /* alias for Windows-1251 */
+ {
+ "windows1250", PG_WIN1250
+ }, /* Windows-1251; Microsoft */
+ {
+ "windows1251", PG_WIN1251
+ }, /* Windows-1251; Microsoft */
- { NULL, 0 } /* last */
+ {
+ NULL, 0
+ } /* last */
};
unsigned int pg_encname_tbl_sz = \
- sizeof(pg_encname_tbl) / sizeof(pg_encname_tbl[0]) -1;
+sizeof(pg_encname_tbl) / sizeof(pg_encname_tbl[0]) - 1;
/* ----------
* These are "official" encoding names.
*/
pg_enc2name pg_enc2name_tbl[] =
{
- { "SQL_ASCII", PG_SQL_ASCII },
- { "EUC_JP", PG_EUC_JP },
- { "EUC_CN", PG_EUC_CN },
- { "EUC_KR", PG_EUC_KR },
- { "EUC_TW", PG_EUC_TW },
- { "UNICODE", PG_UTF8 },
- { "MULE_INTERNAL",PG_MULE_INTERNAL },
- { "LATIN1", PG_LATIN1 },
- { "LATIN2", PG_LATIN2 },
- { "LATIN3", PG_LATIN3 },
- { "LATIN4", PG_LATIN4 },
- { "LATIN5", PG_LATIN5 },
- { "LATIN6", PG_LATIN6 },
- { "LATIN7", PG_LATIN7 },
- { "LATIN8", PG_LATIN8 },
- { "LATIN9", PG_LATIN9 },
- { "LATIN10", PG_LATIN10 },
- { "KOI8", PG_KOI8R },
- { "WIN", PG_WIN1251 },
- { "ALT", PG_ALT },
- { "ISO_8859_5", PG_ISO_8859_5 },
- { "ISO_8859_6", PG_ISO_8859_6 },
- { "ISO_8859_7", PG_ISO_8859_7 },
- { "ISO_8859_8", PG_ISO_8859_8 },
- { "SJIS", PG_SJIS },
- { "BIG5", PG_BIG5 },
- { "WIN1250", PG_WIN1250 }
+ {
+ "SQL_ASCII", PG_SQL_ASCII
+ } ,
+ {
+ "EUC_JP", PG_EUC_JP
+ },
+ {
+ "EUC_CN", PG_EUC_CN
+ },
+ {
+ "EUC_KR", PG_EUC_KR
+ },
+ {
+ "EUC_TW", PG_EUC_TW
+ },
+ {
+ "UNICODE", PG_UTF8
+ },
+ {
+ "MULE_INTERNAL", PG_MULE_INTERNAL
+ },
+ {
+ "LATIN1", PG_LATIN1
+ },
+ {
+ "LATIN2", PG_LATIN2
+ },
+ {
+ "LATIN3", PG_LATIN3
+ },
+ {
+ "LATIN4", PG_LATIN4
+ },
+ {
+ "LATIN5", PG_LATIN5
+ },
+ {
+ "LATIN6", PG_LATIN6
+ },
+ {
+ "LATIN7", PG_LATIN7
+ },
+ {
+ "LATIN8", PG_LATIN8
+ },
+ {
+ "LATIN9", PG_LATIN9
+ },
+ {
+ "LATIN10", PG_LATIN10
+ },
+ {
+ "KOI8", PG_KOI8R
+ },
+ {
+ "WIN", PG_WIN1251
+ },
+ {
+ "ALT", PG_ALT
+ },
+ {
+ "ISO_8859_5", PG_ISO_8859_5
+ },
+ {
+ "ISO_8859_6", PG_ISO_8859_6
+ },
+ {
+ "ISO_8859_7", PG_ISO_8859_7
+ },
+ {
+ "ISO_8859_8", PG_ISO_8859_8
+ },
+ {
+ "SJIS", PG_SJIS
+ },
+ {
+ "BIG5", PG_BIG5
+ },
+ {
+ "WIN1250", PG_WIN1250
+ }
};
/* ----------
int
pg_valid_client_encoding(const char *name)
{
- int enc;
+ int enc;
if ((enc = pg_char_to_encoding(name)) < 0)
return -1;
- if (!PG_VALID_FE_ENCODING( enc))
+ if (!PG_VALID_FE_ENCODING(enc))
return -1;
return enc;
int
pg_valid_server_encoding(const char *name)
{
- int enc;
+ int enc;
if ((enc = pg_char_to_encoding(name)) < 0)
return -1;
- if (!PG_VALID_BE_ENCODING( enc))
+ if (!PG_VALID_BE_ENCODING(enc))
return -1;
return enc;
static char *
clean_encoding_name(char *key, char *newkey)
{
- char *p, *np;
+ char *p,
+ *np;
- for(p=key, np=newkey; *p!='\0'; p++)
+ for (p = key, np = newkey; *p != '\0'; p++)
{
if (isalnum((unsigned char) *p))
- *np++=tolower((unsigned char) *p);
+ *np++ = tolower((unsigned char) *p);
}
*np = '\0';
return newkey;
pg_encname *
pg_char_to_encname_struct(const char *name)
{
- unsigned int nel = pg_encname_tbl_sz;
- pg_encname *base = pg_encname_tbl,
- *last = base + nel - 1,
- *position;
- int result;
+ unsigned int nel = pg_encname_tbl_sz;
+ pg_encname *base = pg_encname_tbl,
+ *last = base + nel - 1,
+ *position;
+ int result;
char buff[NAMEDATALEN],
- *key;
+ *key;
- if(name==NULL || *name=='\0')
+ if (name == NULL || *name == '\0')
return NULL;
if (strlen(name) > NAMEDATALEN)
PG_char_to_encoding(PG_FUNCTION_ARGS)
{
Name s = PG_GETARG_NAME(0);
+
PG_RETURN_INT32(pg_char_to_encoding(NameStr(*s)));
}
#endif
{
if (PG_VALID_ENCODING(encoding))
{
- pg_enc2name *p = &pg_enc2name_tbl[ encoding ];
- Assert( encoding == p->encoding );
+ pg_enc2name *p = &pg_enc2name_tbl[encoding];
+
+ Assert(encoding == p->encoding);
return p->name;
}
return "";
PG_encoding_to_char(PG_FUNCTION_ARGS)
{
int32 encoding = PG_GETARG_INT32(0);
- const char *encoding_name = pg_encoding_to_char(encoding);
+ const char *encoding_name = pg_encoding_to_char(encoding);
return DirectFunctionCall1(namein, CStringGetDatum(encoding_name));
}
#endif
-
* client encoding and server internal encoding.
* (currently mule internal code (mic) is used)
* Tatsuo Ishii
- * $Id: mbutils.c,v 1.24 2001/10/12 02:08:34 ishii Exp $
+ * $Id: mbutils.c,v 1.25 2001/10/25 05:49:51 momjian Exp $
*/
#include "postgres.h"
#include "utils/builtins.h"
/*
- * We handle for actual FE and BE encoding setting encoding-identificator
+ * We handle for actual FE and BE encoding setting encoding-identificator
* and encoding-name too. It prevent searching and conversion from encoding
* to encoding name in getdatabaseencoding() and other routines.
*
*
* Karel Zak (Aug 2001)
*/
-static pg_enc2name *ClientEncoding = &pg_enc2name_tbl[ PG_SQL_ASCII ];
-static pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[ PG_SQL_ASCII ];
+static pg_enc2name *ClientEncoding = &pg_enc2name_tbl[PG_SQL_ASCII];
+static pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII];
static to_mic_converter client_to_mic; /* something to MIC */
-static from_mic_converter client_from_mic; /* MIC to something */
+static from_mic_converter client_from_mic; /* MIC to something */
static to_mic_converter server_to_mic; /* something to MIC */
-static from_mic_converter server_from_mic; /* MIC to something */
+static from_mic_converter server_from_mic; /* MIC to something */
/*
* find encoding table entry by encoding
{
if (PG_VALID_ENCODING(encoding))
{
- Assert((&pg_enconv_tbl[ encoding ])->encoding == encoding);
- return &pg_enconv_tbl[ encoding ];
+ Assert((&pg_enconv_tbl[encoding])->encoding == encoding);
+ return &pg_enconv_tbl[encoding];
}
return 0;
}
int
pg_set_client_encoding(int encoding)
{
- int current_server_encoding = DatabaseEncoding->encoding;
+ int current_server_encoding = DatabaseEncoding->encoding;
if (!PG_VALID_FE_ENCODING(encoding))
return (-1);
if (pg_find_encoding_converters(encoding, current_server_encoding, &client_to_mic, &server_from_mic) < 0)
return (-1);
- ClientEncoding = &pg_enc2name_tbl[ encoding ];
+ ClientEncoding = &pg_enc2name_tbl[encoding];
Assert(ClientEncoding->encoding == encoding);
* function). Another case is you have direct-conversion function from
* src to dest. In this case either src_to_mic or dest_from_mic could
* be set to 0 also.
- *
+ *
* Note that If src or dest is UNICODE, we have to do
* direct-conversion, since we don't support conversion bwteen UNICODE
* and MULE_INTERNAL, we cannot go through MULE_INTERNAL.
* to determine whether to pfree the result or not!
*
* Note: we assume that conversion cannot cause more than a 4-to-1 growth
- * in the length of the string --- is this enough? */
+ * in the length of the string --- is this enough? */
unsigned char *
pg_do_encoding_conversion(unsigned char *src, int len,
Datum
pg_convert(PG_FUNCTION_ARGS)
{
- text *string = PG_GETARG_TEXT_P(0);
- Name s = PG_GETARG_NAME(1);
- int encoding = pg_char_to_encoding(NameStr(*s));
- int db_encoding = DatabaseEncoding->encoding;
+ text *string = PG_GETARG_TEXT_P(0);
+ Name s = PG_GETARG_NAME(1);
+ int encoding = pg_char_to_encoding(NameStr(*s));
+ int db_encoding = DatabaseEncoding->encoding;
to_mic_converter src;
from_mic_converter dest;
- unsigned char *result;
- text *retval;
+ unsigned char *result;
+ text *retval;
if (encoding < 0)
- elog(ERROR, "Invalid encoding name %s", NameStr(*s));
+ elog(ERROR, "Invalid encoding name %s", NameStr(*s));
if (pg_find_encoding_converters(db_encoding, encoding, &src, &dest) < 0)
{
- char *encoding_name = (char *)pg_encoding_to_char(db_encoding);
- elog(ERROR, "Conversion from %s to %s is not possible", NameStr(*s), encoding_name);
+ char *encoding_name = (char *) pg_encoding_to_char(db_encoding);
+
+ elog(ERROR, "Conversion from %s to %s is not possible", NameStr(*s), encoding_name);
}
- result = pg_do_encoding_conversion(VARDATA(string), VARSIZE(string)-VARHDRSZ,
- src, dest);
+ result = pg_do_encoding_conversion(VARDATA(string), VARSIZE(string) - VARHDRSZ,
+ src, dest);
if (result == NULL)
- elog(ERROR, "Encoding conversion failed");
+ elog(ERROR, "Encoding conversion failed");
retval = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(result)));
- if (result != (unsigned char *)VARDATA(string))
- pfree(result);
+ if (result != (unsigned char *) VARDATA(string))
+ pfree(result);
/* free memory if allocated by the toaster */
PG_FREE_IF_COPY(string, 0);
Datum
pg_convert2(PG_FUNCTION_ARGS)
{
- text *string = PG_GETARG_TEXT_P(0);
- char *src_encoding_name = NameStr(*PG_GETARG_NAME(1));
- int src_encoding = pg_char_to_encoding(src_encoding_name);
- char *dest_encoding_name = NameStr(*PG_GETARG_NAME(2));
- int dest_encoding = pg_char_to_encoding(dest_encoding_name);
+ text *string = PG_GETARG_TEXT_P(0);
+ char *src_encoding_name = NameStr(*PG_GETARG_NAME(1));
+ int src_encoding = pg_char_to_encoding(src_encoding_name);
+ char *dest_encoding_name = NameStr(*PG_GETARG_NAME(2));
+ int dest_encoding = pg_char_to_encoding(dest_encoding_name);
to_mic_converter src;
from_mic_converter dest;
- unsigned char *result;
- text *retval;
+ unsigned char *result;
+ text *retval;
if (src_encoding < 0)
- elog(ERROR, "Invalid source encoding name %s", src_encoding_name);
+ elog(ERROR, "Invalid source encoding name %s", src_encoding_name);
if (dest_encoding < 0)
- elog(ERROR, "Invalid destination encoding name %s", dest_encoding_name);
+ elog(ERROR, "Invalid destination encoding name %s", dest_encoding_name);
if (pg_find_encoding_converters(src_encoding, dest_encoding, &src, &dest) < 0)
{
- elog(ERROR, "Conversion from %s to %s is not possible",
- src_encoding_name, dest_encoding_name);
+ elog(ERROR, "Conversion from %s to %s is not possible",
+ src_encoding_name, dest_encoding_name);
}
- result = pg_do_encoding_conversion(VARDATA(string), VARSIZE(string)-VARHDRSZ,
- src, dest);
+ result = pg_do_encoding_conversion(VARDATA(string), VARSIZE(string) - VARHDRSZ,
+ src, dest);
if (result == NULL)
- elog(ERROR, "Encoding conversion failed");
+ elog(ERROR, "Encoding conversion failed");
retval = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(result)));
- if (result != (unsigned char *)VARDATA(string))
- pfree(result);
+ if (result != (unsigned char *) VARDATA(string))
+ pfree(result);
/* free memory if allocated by the toaster */
PG_FREE_IF_COPY(string, 0);
Assert(ClientEncoding);
if (ClientEncoding->encoding == DatabaseEncoding->encoding)
- return s;
+ return s;
return pg_do_encoding_conversion(s, len, client_to_mic, server_from_mic);
}
/* convert a multi-byte string to a wchar */
int
-pg_mb2wchar(const unsigned char *from, pg_wchar * to)
+pg_mb2wchar(const unsigned char *from, pg_wchar *to)
{
- return (*pg_wchar_table[ DatabaseEncoding->encoding ].mb2wchar_with_len) (from, to, strlen(from));
+ return (*pg_wchar_table[DatabaseEncoding->encoding].mb2wchar_with_len) (from, to, strlen(from));
}
/* convert a multi-byte string to a wchar with a limited length */
int
-pg_mb2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
+pg_mb2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
{
- return (*pg_wchar_table[ DatabaseEncoding->encoding ].mb2wchar_with_len) (from, to, len);
+ return (*pg_wchar_table[DatabaseEncoding->encoding].mb2wchar_with_len) (from, to, len);
}
/* returns the byte length of a multi-byte word */
int
pg_mblen(const unsigned char *mbstr)
{
- return ((*pg_wchar_table[ DatabaseEncoding->encoding ].mblen) (mbstr));
+ return ((*pg_wchar_table[DatabaseEncoding->encoding].mblen) (mbstr));
}
/* returns the length (counted as a wchar) of a multi-byte string */
if (!PG_VALID_BE_ENCODING(encoding))
elog(ERROR, "SetDatabaseEncoding(): invalid database encoding");
- DatabaseEncoding = &pg_enc2name_tbl[ encoding ];
+ DatabaseEncoding = &pg_enc2name_tbl[encoding];
Assert(DatabaseEncoding->encoding == encoding);
}
/*
* conversion functions between pg_wchar and multi-byte streams.
* Tatsuo Ishii
- * $Id: wchar.c,v 1.24 2001/10/15 01:19:15 ishii Exp $
+ * $Id: wchar.c,v 1.25 2001/10/25 05:49:51 momjian Exp $
*
* WIN1250 client encoding updated by Pavel Behal
*
* SQL/ASCII
*/
static int pg_ascii2wchar_with_len
- (const unsigned char *from, pg_wchar * to, int len)
+ (const unsigned char *from, pg_wchar *to, int len)
{
int cnt = 0;
*/
static int pg_euc2wchar_with_len
- (const unsigned char *from, pg_wchar * to, int len)
+ (const unsigned char *from, pg_wchar *to, int len)
{
int cnt = 0;
* EUC_JP
*/
static int pg_eucjp2wchar_with_len
- (const unsigned char *from, pg_wchar * to, int len)
+ (const unsigned char *from, pg_wchar *to, int len)
{
return (pg_euc2wchar_with_len(from, to, len));
}
* EUC_KR
*/
static int pg_euckr2wchar_with_len
- (const unsigned char *from, pg_wchar * to, int len)
+ (const unsigned char *from, pg_wchar *to, int len)
{
return (pg_euc2wchar_with_len(from, to, len));
}
* EUC_CN
*/
static int pg_euccn2wchar_with_len
- (const unsigned char *from, pg_wchar * to, int len)
+ (const unsigned char *from, pg_wchar *to, int len)
{
int cnt = 0;
* EUC_TW
*/
static int pg_euctw2wchar_with_len
- (const unsigned char *from, pg_wchar * to, int len)
+ (const unsigned char *from, pg_wchar *to, int len)
{
int cnt = 0;
* "from" not necessarily null terminated.
*/
static int
-pg_utf2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
+pg_utf2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
{
unsigned char c1,
c2,
* "from" not necessarily null terminated.
*/
static int
-pg_mule2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
+pg_mule2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
{
int cnt = 0;
* ISO8859-1
*/
static int
-pg_latin12wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
+pg_latin12wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
{
int cnt = 0;
}
pg_wchar_tbl pg_wchar_table[] = {
- {pg_ascii2wchar_with_len, pg_ascii_mblen, 1}, /* 0; PG_SQL_ASCII */
- {pg_eucjp2wchar_with_len, pg_eucjp_mblen, 3}, /* 1; PG_EUC_JP */
- {pg_euccn2wchar_with_len, pg_euccn_mblen, 3}, /* 2; PG_EUC_CN */
- {pg_euckr2wchar_with_len, pg_euckr_mblen, 3}, /* 3; PG_EUC_KR */
- {pg_euctw2wchar_with_len, pg_euctw_mblen, 3}, /* 4; PG_EUC_TW */
+ {pg_ascii2wchar_with_len, pg_ascii_mblen, 1}, /* 0; PG_SQL_ASCII */
+ {pg_eucjp2wchar_with_len, pg_eucjp_mblen, 3}, /* 1; PG_EUC_JP */
+ {pg_euccn2wchar_with_len, pg_euccn_mblen, 3}, /* 2; PG_EUC_CN */
+ {pg_euckr2wchar_with_len, pg_euckr_mblen, 3}, /* 3; PG_EUC_KR */
+ {pg_euctw2wchar_with_len, pg_euctw_mblen, 3}, /* 4; PG_EUC_TW */
{pg_utf2wchar_with_len, pg_utf_mblen, 3}, /* 5; PG_UNICODE */
- {pg_mule2wchar_with_len, pg_mule_mblen, 3}, /* 6; PG_MULE_INTERNAL */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 7; PG_LATIN1 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 8; PG_LATIN2 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 9; PG_LATIN3 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 10; PG_LATIN4 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 11; PG_LATIN5 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 12; PG_KOI8 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 13; PG_WIN1251 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 14; PG_ALT */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 15; ISO-8859-5 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 16; ISO-8859-6 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 17; ISO-8859-7 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 18; ISO-8859-8 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 19; ISO-8859-10 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 20; ISO-8859-13 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 21; ISO-8859-14 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 22; ISO-8859-15 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 23; ISO-8859-16 */
- {0, pg_sjis_mblen, 2}, /* 24; PG_SJIS */
- {0, pg_big5_mblen, 2}, /* 25; PG_BIG5 */
- {pg_latin12wchar_with_len, pg_latin1_mblen, 1} /* 26; PG_WIN1250 */
+ {pg_mule2wchar_with_len, pg_mule_mblen, 3}, /* 6; PG_MULE_INTERNAL */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 7; PG_LATIN1 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 8; PG_LATIN2 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 9; PG_LATIN3 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 10; PG_LATIN4 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 11; PG_LATIN5 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 12; PG_KOI8 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 13; PG_WIN1251 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 14; PG_ALT */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 15; ISO-8859-5 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 16; ISO-8859-6 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 17; ISO-8859-7 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 18; ISO-8859-8 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 19; ISO-8859-10 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 20; ISO-8859-13 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 21; ISO-8859-14 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 22; ISO-8859-15 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 23; ISO-8859-16 */
+ {0, pg_sjis_mblen, 2}, /* 24; PG_SJIS */
+ {0, pg_big5_mblen, 2}, /* 25; PG_BIG5 */
+ {pg_latin12wchar_with_len, pg_latin1_mblen, 1} /* 26; PG_WIN1250 */
};
/* returns the byte length of a word for mule internal code */
{
Assert(PG_VALID_ENCODING(encoding));
- return( (encoding >= 0 &&
- encoding < sizeof(pg_wchar_table)/sizeof(pg_wchar_tbl)) ?
- ((*pg_wchar_table[encoding].mblen) (mbstr)) :
+ return ((encoding >= 0 &&
+ encoding < sizeof(pg_wchar_table) / sizeof(pg_wchar_tbl)) ?
+ ((*pg_wchar_table[encoding].mblen) (mbstr)) :
((*pg_wchar_table[PG_SQL_ASCII].mblen) (mbstr)));
}
char *
pg_verifymbstr(const unsigned char *mbstr, int len)
{
- int l;
- int i, j;
- static char buf[256];
- int slen = 0;
+ int l;
+ int i,
+ j;
+ static char buf[256];
+ int slen = 0;
/* we do not check single byte encodings */
if (pg_database_encoding_max_length() <= 1)
- return NULL;
+ return NULL;
while (len > 0 && *mbstr)
{
/* special UTF-8 check */
if (GetDatabaseEncoding() == PG_UTF8 &&
- (*mbstr & 0xf8) == 0xf0)
+ (*mbstr & 0xf8) == 0xf0)
{
- snprintf(buf, sizeof(buf), "Unicode >= 0x10000 is not supoorted");
- return(buf);
+ snprintf(buf, sizeof(buf), "Unicode >= 0x10000 is not supoorted");
+ return (buf);
}
-
+
l = pg_mblen(mbstr);
/* multi-byte letter? */
if (l > 1)
{
- for (i=1;i
- {
- if (i > len || *(mbstr+i) == '\0' ||
- /* we assume that every muti-byte letter
- * consists of bytes being the 8th bit set
- */
- ((*(mbstr+i) & 0x80) == 0))
+ for (i = 1; i < l; i++)
{
- int remains = sizeof(buf);
- char *p = buf;
-
- slen = snprintf(p, remains, "Invalid %s character sequence found (0x",
- GetDatabaseEncodingName());
- p += slen;
- remains -= slen;
-
- i = ((*(mbstr+i) & 0x80) == 0)?l:i;
-
- for (j=0;j
- {
- slen = snprintf(p, remains, "%02x",
- *(mbstr+j));
- p += slen;
- remains -= slen;
- }
- snprintf(p, remains, ")");
- return(buf);
+ if (i > len || *(mbstr + i) == '\0' ||
+
+ /*
+ * we assume that every muti-byte letter consists of bytes
+ * being the 8th bit set
+ */
+ ((*(mbstr + i) & 0x80) == 0))
+ {
+ int remains = sizeof(buf);
+ char *p = buf;
+
+ slen = snprintf(p, remains, "Invalid %s character sequence found (0x",
+ GetDatabaseEncodingName());
+ p += slen;
+ remains -= slen;
+
+ i = ((*(mbstr + i) & 0x80) == 0) ? l : i;
+
+ for (j = 0; j < i; j++)
+ {
+ slen = snprintf(p, remains, "%02x",
+ *(mbstr + j));
+ p += slen;
+ remains -= slen;
+ }
+ snprintf(p, remains, ")");
+ return (buf);
+ }
}
- }
}
len -= l;
mbstr += l;
{
return pg_wchar_table[GetDatabaseEncoding()].maxmblen;
}
-
#endif
register const char *s1;
register const pg_wchar *s2;
{
- while ((pg_wchar) * s1 == *s2++)
+ while ((pg_wchar) *s1 == *s2++)
if (*s1++ == 0)
return 0;
return *(const unsigned char *) s1 - *(const pg_wchar *) (s2 - 1);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.48 2001/08/25 18:52:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.49 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
for (cp = buf; *cp; cp++)
{
-
/*
* The following characters will not be allowed anywhere in the
* database path. (Do not include the slash or '.' here.)
* Support for grand unified configuration scheme, including SET
* command, configuration file, and command line options.
*
- * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.55 2001/09/30 20:16:21 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.56 2001/10/25 05:49:51 momjian Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut
.
*/
enum config_type
{
- PGC_NONE = 0,
- PGC_BOOL,
- PGC_INT,
- PGC_REAL,
- PGC_STRING
+ PGC_NONE = 0,
+ PGC_BOOL,
+ PGC_INT,
+ PGC_REAL,
+ PGC_STRING
};
const char *boot_default_val;
bool (*parse_hook) (const char *proposed);
void (*assign_hook) (const char *newval);
- char *default_val;
+ char *default_val;
};
static struct config_bool
ConfigureNamesBool[] =
{
- {"enable_seqscan", PGC_USERSET, &enable_seqscan, true, NULL},
- {"enable_indexscan", PGC_USERSET, &enable_indexscan, true, NULL},
- {"enable_tidscan", PGC_USERSET, &enable_tidscan, true, NULL},
- {"enable_sort", PGC_USERSET, &enable_sort, true, NULL},
- {"enable_nestloop", PGC_USERSET, &enable_nestloop, true, NULL},
- {"enable_mergejoin", PGC_USERSET, &enable_mergejoin, true, NULL},
- {"enable_hashjoin", PGC_USERSET, &enable_hashjoin, true, NULL},
-
- {"ksqo", PGC_USERSET, &_use_keyset_query_optimizer, false, NULL},
- {"geqo", PGC_USERSET, &enable_geqo, true, NULL},
-
- {"tcpip_socket", PGC_POSTMASTER, &NetServer, false, NULL},
- {"ssl", PGC_POSTMASTER, &EnableSSL, false, NULL},
- {"fsync", PGC_SIGHUP, &enableFsync, true, NULL},
- {"silent_mode", PGC_POSTMASTER, &SilentMode, false, NULL},
-
- {"log_connections", PGC_BACKEND, &Log_connections, false, NULL},
- {"log_timestamp", PGC_SIGHUP, &Log_timestamp, false, NULL},
- {"log_pid", PGC_SIGHUP, &Log_pid, false, NULL},
+ {
+ "enable_seqscan", PGC_USERSET, &enable_seqscan, true, NULL
+ } ,
+ {
+ "enable_indexscan", PGC_USERSET, &enable_indexscan, true, NULL
+ },
+ {
+ "enable_tidscan", PGC_USERSET, &enable_tidscan, true, NULL
+ },
+ {
+ "enable_sort", PGC_USERSET, &enable_sort, true, NULL
+ },
+ {
+ "enable_nestloop", PGC_USERSET, &enable_nestloop, true, NULL
+ },
+ {
+ "enable_mergejoin", PGC_USERSET, &enable_mergejoin, true, NULL
+ },
+ {
+ "enable_hashjoin", PGC_USERSET, &enable_hashjoin, true, NULL
+ },
+
+ {
+ "ksqo", PGC_USERSET, &_use_keyset_query_optimizer, false, NULL
+ },
+ {
+ "geqo", PGC_USERSET, &enable_geqo, true, NULL
+ },
+
+ {
+ "tcpip_socket", PGC_POSTMASTER, &NetServer, false, NULL
+ },
+ {
+ "ssl", PGC_POSTMASTER, &EnableSSL, false, NULL
+ },
+ {
+ "fsync", PGC_SIGHUP, &enableFsync, true, NULL
+ },
+ {
+ "silent_mode", PGC_POSTMASTER, &SilentMode, false, NULL
+ },
+
+ {
+ "log_connections", PGC_BACKEND, &Log_connections, false, NULL
+ },
+ {
+ "log_timestamp", PGC_SIGHUP, &Log_timestamp, false, NULL
+ },
+ {
+ "log_pid", PGC_SIGHUP, &Log_pid, false, NULL
+ },
#ifdef USE_ASSERT_CHECKING
- {"debug_assertions", PGC_USERSET, &assert_enabled, true, NULL},
+ {
+ "debug_assertions", PGC_USERSET, &assert_enabled, true, NULL
+ },
#endif
- {"debug_print_query", PGC_USERSET, &Debug_print_query, false, NULL},
- {"debug_print_parse", PGC_USERSET, &Debug_print_parse, false, NULL},
- {"debug_print_rewritten", PGC_USERSET, &Debug_print_rewritten, false, NULL},
- {"debug_print_plan", PGC_USERSET, &Debug_print_plan, false, NULL},
- {"debug_pretty_print", PGC_USERSET, &Debug_pretty_print, false, NULL},
+ {
+ "debug_print_query", PGC_USERSET, &Debug_print_query, false, NULL
+ },
+ {
+ "debug_print_parse", PGC_USERSET, &Debug_print_parse, false, NULL
+ },
+ {
+ "debug_print_rewritten", PGC_USERSET, &Debug_print_rewritten, false, NULL
+ },
+ {
+ "debug_print_plan", PGC_USERSET, &Debug_print_plan, false, NULL
+ },
+ {
+ "debug_pretty_print", PGC_USERSET, &Debug_pretty_print, false, NULL
+ },
- {"show_parser_stats", PGC_USERSET, &Show_parser_stats, false, NULL},
- {"show_planner_stats", PGC_USERSET, &Show_planner_stats, false, NULL},
- {"show_executor_stats", PGC_USERSET, &Show_executor_stats, false, NULL},
- {"show_query_stats", PGC_USERSET, &Show_query_stats, false, NULL},
+ {
+ "show_parser_stats", PGC_USERSET, &Show_parser_stats, false, NULL
+ },
+ {
+ "show_planner_stats", PGC_USERSET, &Show_planner_stats, false, NULL
+ },
+ {
+ "show_executor_stats", PGC_USERSET, &Show_executor_stats, false, NULL
+ },
+ {
+ "show_query_stats", PGC_USERSET, &Show_query_stats, false, NULL
+ },
#ifdef BTREE_BUILD_STATS
- {"show_btree_build_stats", PGC_SUSET, &Show_btree_build_stats, false, NULL},
+ {
+ "show_btree_build_stats", PGC_SUSET, &Show_btree_build_stats, false, NULL
+ },
#endif
- {"stats_start_collector", PGC_POSTMASTER, &pgstat_collect_startcollector, true, NULL},
- {"stats_reset_on_server_start", PGC_POSTMASTER, &pgstat_collect_resetonpmstart, true, NULL},
- {"stats_command_string", PGC_SUSET, &pgstat_collect_querystring, false, NULL},
- {"stats_row_level", PGC_SUSET, &pgstat_collect_tuplelevel, false, NULL},
- {"stats_block_level", PGC_SUSET, &pgstat_collect_blocklevel, false, NULL},
+ {
+ "stats_start_collector", PGC_POSTMASTER, &pgstat_collect_startcollector, true, NULL
+ },
+ {
+ "stats_reset_on_server_start", PGC_POSTMASTER, &pgstat_collect_resetonpmstart, true, NULL
+ },
+ {
+ "stats_command_string", PGC_SUSET, &pgstat_collect_querystring, false, NULL
+ },
+ {
+ "stats_row_level", PGC_SUSET, &pgstat_collect_tuplelevel, false, NULL
+ },
+ {
+ "stats_block_level", PGC_SUSET, &pgstat_collect_blocklevel, false, NULL
+ },
- {"trace_notify", PGC_USERSET, &Trace_notify, false, NULL},
+ {
+ "trace_notify", PGC_USERSET, &Trace_notify, false, NULL
+ },
#ifdef LOCK_DEBUG
- {"trace_locks", PGC_SUSET, &Trace_locks, false, NULL},
- {"trace_userlocks", PGC_SUSET, &Trace_userlocks, false, NULL},
- {"trace_lwlocks", PGC_SUSET, &Trace_lwlocks, false, NULL},
- {"debug_deadlocks", PGC_SUSET, &Debug_deadlocks, false, NULL},
+ {
+ "trace_locks", PGC_SUSET, &Trace_locks, false, NULL
+ },
+ {
+ "trace_userlocks", PGC_SUSET, &Trace_userlocks, false, NULL
+ },
+ {
+ "trace_lwlocks", PGC_SUSET, &Trace_lwlocks, false, NULL
+ },
+ {
+ "debug_deadlocks", PGC_SUSET, &Debug_deadlocks, false, NULL
+ },
#endif
- {"hostname_lookup", PGC_SIGHUP, &HostnameLookup, false, NULL},
- {"show_source_port", PGC_SIGHUP, &ShowPortNumber, false, NULL},
+ {
+ "hostname_lookup", PGC_SIGHUP, &HostnameLookup, false, NULL
+ },
+ {
+ "show_source_port", PGC_SIGHUP, &ShowPortNumber, false, NULL
+ },
- {"sql_inheritance", PGC_USERSET, &SQL_inheritance, true, NULL},
- {"australian_timezones", PGC_USERSET, &Australian_timezones, false, ClearDateCache},
- {"fixbtree", PGC_POSTMASTER, &FixBTree, true, NULL},
- {"password_encryption", PGC_USERSET, &Password_encryption, false, NULL},
- {"transform_null_equals", PGC_USERSET, &Transform_null_equals, false, NULL},
+ {
+ "sql_inheritance", PGC_USERSET, &SQL_inheritance, true, NULL
+ },
+ {
+ "australian_timezones", PGC_USERSET, &Australian_timezones, false, ClearDateCache
+ },
+ {
+ "fixbtree", PGC_POSTMASTER, &FixBTree, true, NULL
+ },
+ {
+ "password_encryption", PGC_USERSET, &Password_encryption, false, NULL
+ },
+ {
+ "transform_null_equals", PGC_USERSET, &Transform_null_equals, false, NULL
+ },
- {NULL, 0, NULL, false, NULL}
+ {
+ NULL, 0, NULL, false, NULL
+ }
};
static struct config_int
ConfigureNamesInt[] =
{
- {"geqo_threshold", PGC_USERSET, &geqo_rels,
- DEFAULT_GEQO_RELS, 2, INT_MAX, NULL, NULL},
- {"geqo_pool_size", PGC_USERSET, &Geqo_pool_size,
- DEFAULT_GEQO_POOL_SIZE, 0, MAX_GEQO_POOL_SIZE, NULL, NULL},
- {"geqo_effort", PGC_USERSET, &Geqo_effort,
- 1, 1, INT_MAX, NULL, NULL},
- {"geqo_generations", PGC_USERSET, &Geqo_generations,
- 0, 0, INT_MAX, NULL, NULL},
- {"geqo_random_seed", PGC_USERSET, &Geqo_random_seed,
- -1, INT_MIN, INT_MAX, NULL, NULL},
-
- {"deadlock_timeout", PGC_POSTMASTER, &DeadlockTimeout,
- 1000, 0, INT_MAX, NULL, NULL},
+ {
+ "geqo_threshold", PGC_USERSET, &geqo_rels,
+ DEFAULT_GEQO_RELS, 2, INT_MAX, NULL, NULL
+ } ,
+ {
+ "geqo_pool_size", PGC_USERSET, &Geqo_pool_size,
+ DEFAULT_GEQO_POOL_SIZE, 0, MAX_GEQO_POOL_SIZE, NULL, NULL
+ },
+ {
+ "geqo_effort", PGC_USERSET, &Geqo_effort,
+ 1, 1, INT_MAX, NULL, NULL
+ },
+ {
+ "geqo_generations", PGC_USERSET, &Geqo_generations,
+ 0, 0, INT_MAX, NULL, NULL
+ },
+ {
+ "geqo_random_seed", PGC_USERSET, &Geqo_random_seed,
+ -1, INT_MIN, INT_MAX, NULL, NULL
+ },
+
+ {
+ "deadlock_timeout", PGC_POSTMASTER, &DeadlockTimeout,
+ 1000, 0, INT_MAX, NULL, NULL
+ },
#ifdef ENABLE_SYSLOG
- {"syslog", PGC_SIGHUP, &Use_syslog,
- 0, 0, 2, NULL, NULL},
+ {
+ "syslog", PGC_SIGHUP, &Use_syslog,
+ 0, 0, 2, NULL, NULL
+ },
#endif
/*
* sure the buffers are at least twice the number of backends, so the
* constraints here are partially unused.
*/
- {"max_connections", PGC_POSTMASTER, &MaxBackends,
- DEF_MAXBACKENDS, 1, INT_MAX, NULL, NULL},
+ {
+ "max_connections", PGC_POSTMASTER, &MaxBackends,
+ DEF_MAXBACKENDS, 1, INT_MAX, NULL, NULL
+ },
- {"shared_buffers", PGC_POSTMASTER, &NBuffers,
- DEF_NBUFFERS, 16, INT_MAX, NULL, NULL},
+ {
+ "shared_buffers", PGC_POSTMASTER, &NBuffers,
+ DEF_NBUFFERS, 16, INT_MAX, NULL, NULL
+ },
- {"port", PGC_POSTMASTER, &PostPortNumber,
- DEF_PGPORT, 1, 65535, NULL, NULL},
+ {
+ "port", PGC_POSTMASTER, &PostPortNumber,
+ DEF_PGPORT, 1, 65535, NULL, NULL
+ },
- {"unix_socket_permissions", PGC_POSTMASTER, &Unix_socket_permissions,
- 0777, 0000, 0777, NULL, NULL},
+ {
+ "unix_socket_permissions", PGC_POSTMASTER, &Unix_socket_permissions,
+ 0777, 0000, 0777, NULL, NULL
+ },
- {"sort_mem", PGC_USERSET, &SortMem,
- 512, 4*BLCKSZ/1024, INT_MAX, NULL, NULL},
+ {
+ "sort_mem", PGC_USERSET, &SortMem,
+ 512, 4 * BLCKSZ / 1024, INT_MAX, NULL, NULL
+ },
- {"vacuum_mem", PGC_USERSET, &VacuumMem,
- 8192, 1024, INT_MAX, NULL, NULL},
+ {
+ "vacuum_mem", PGC_USERSET, &VacuumMem,
+ 8192, 1024, INT_MAX, NULL, NULL
+ },
- {"max_files_per_process", PGC_BACKEND, &max_files_per_process,
- 1000, 25, INT_MAX, NULL, NULL},
+ {
+ "max_files_per_process", PGC_BACKEND, &max_files_per_process,
+ 1000, 25, INT_MAX, NULL, NULL
+ },
- {"debug_level", PGC_USERSET, &DebugLvl,
- 0, 0, 16, NULL, NULL},
+ {
+ "debug_level", PGC_USERSET, &DebugLvl,
+ 0, 0, 16, NULL, NULL
+ },
#ifdef LOCK_DEBUG
- {"trace_lock_oidmin", PGC_SUSET, &Trace_lock_oidmin,
- BootstrapObjectIdData, 1, INT_MAX, NULL, NULL},
- {"trace_lock_table", PGC_SUSET, &Trace_lock_table,
- 0, 0, INT_MAX, NULL, NULL},
+ {
+ "trace_lock_oidmin", PGC_SUSET, &Trace_lock_oidmin,
+ BootstrapObjectIdData, 1, INT_MAX, NULL, NULL
+ },
+ {
+ "trace_lock_table", PGC_SUSET, &Trace_lock_table,
+ 0, 0, INT_MAX, NULL, NULL
+ },
#endif
- {"max_expr_depth", PGC_USERSET, &max_expr_depth,
- DEFAULT_MAX_EXPR_DEPTH, 10, INT_MAX, NULL, NULL},
+ {
+ "max_expr_depth", PGC_USERSET, &max_expr_depth,
+ DEFAULT_MAX_EXPR_DEPTH, 10, INT_MAX, NULL, NULL
+ },
- {"max_fsm_relations", PGC_POSTMASTER, &MaxFSMRelations,
- 100, 10, INT_MAX, NULL, NULL},
- {"max_fsm_pages", PGC_POSTMASTER, &MaxFSMPages,
- 10000, 1000, INT_MAX, NULL, NULL},
+ {
+ "max_fsm_relations", PGC_POSTMASTER, &MaxFSMRelations,
+ 100, 10, INT_MAX, NULL, NULL
+ },
+ {
+ "max_fsm_pages", PGC_POSTMASTER, &MaxFSMPages,
+ 10000, 1000, INT_MAX, NULL, NULL
+ },
- {"max_locks_per_transaction", PGC_POSTMASTER, &max_locks_per_xact,
- 64, 10, INT_MAX, NULL, NULL},
+ {
+ "max_locks_per_transaction", PGC_POSTMASTER, &max_locks_per_xact,
+ 64, 10, INT_MAX, NULL, NULL
+ },
- {"authentication_timeout", PGC_SIGHUP, &AuthenticationTimeout,
- 60, 1, 600, NULL, NULL},
+ {
+ "authentication_timeout", PGC_SIGHUP, &AuthenticationTimeout,
+ 60, 1, 600, NULL, NULL
+ },
- {"pre_auth_delay", PGC_SIGHUP, &PreAuthDelay,
- 0, 0, 60, NULL, NULL},
+ {
+ "pre_auth_delay", PGC_SIGHUP, &PreAuthDelay,
+ 0, 0, 60, NULL, NULL
+ },
- {"checkpoint_segments", PGC_SIGHUP, &CheckPointSegments,
- 3, 1, INT_MAX, NULL, NULL},
+ {
+ "checkpoint_segments", PGC_SIGHUP, &CheckPointSegments,
+ 3, 1, INT_MAX, NULL, NULL
+ },
- {"checkpoint_timeout", PGC_SIGHUP, &CheckPointTimeout,
- 300, 30, 3600, NULL, NULL},
+ {
+ "checkpoint_timeout", PGC_SIGHUP, &CheckPointTimeout,
+ 300, 30, 3600, NULL, NULL
+ },
- {"wal_buffers", PGC_POSTMASTER, &XLOGbuffers,
- 8, 4, INT_MAX, NULL, NULL},
+ {
+ "wal_buffers", PGC_POSTMASTER, &XLOGbuffers,
+ 8, 4, INT_MAX, NULL, NULL
+ },
- {"wal_files", PGC_SIGHUP, &XLOGfiles,
- 0, 0, 64, NULL, NULL},
+ {
+ "wal_files", PGC_SIGHUP, &XLOGfiles,
+ 0, 0, 64, NULL, NULL
+ },
- {"wal_debug", PGC_SUSET, &XLOG_DEBUG,
- 0, 0, 16, NULL, NULL},
+ {
+ "wal_debug", PGC_SUSET, &XLOG_DEBUG,
+ 0, 0, 16, NULL, NULL
+ },
- {"commit_delay", PGC_USERSET, &CommitDelay,
- 0, 0, 100000, NULL, NULL},
+ {
+ "commit_delay", PGC_USERSET, &CommitDelay,
+ 0, 0, 100000, NULL, NULL
+ },
- {"commit_siblings", PGC_USERSET, &CommitSiblings,
- 5, 1, 1000, NULL, NULL},
+ {
+ "commit_siblings", PGC_USERSET, &CommitSiblings,
+ 5, 1, 1000, NULL, NULL
+ },
- {NULL, 0, NULL, 0, 0, 0, NULL, NULL}
+ {
+ NULL, 0, NULL, 0, 0, 0, NULL, NULL
+ }
};
static struct config_real
ConfigureNamesReal[] =
{
- {"effective_cache_size", PGC_USERSET, &effective_cache_size,
- DEFAULT_EFFECTIVE_CACHE_SIZE, 0, DBL_MAX, NULL, NULL},
- {"random_page_cost", PGC_USERSET, &random_page_cost,
- DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX, NULL, NULL},
- {"cpu_tuple_cost", PGC_USERSET, &cpu_tuple_cost,
- DEFAULT_CPU_TUPLE_COST, 0, DBL_MAX, NULL, NULL},
- {"cpu_index_tuple_cost", PGC_USERSET, &cpu_index_tuple_cost,
- DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX, NULL, NULL},
- {"cpu_operator_cost", PGC_USERSET, &cpu_operator_cost,
- DEFAULT_CPU_OPERATOR_COST, 0, DBL_MAX, NULL, NULL},
-
- {"geqo_selection_bias", PGC_USERSET, &Geqo_selection_bias,
- DEFAULT_GEQO_SELECTION_BIAS, MIN_GEQO_SELECTION_BIAS,
- MAX_GEQO_SELECTION_BIAS, NULL, NULL},
-
- {NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, NULL}
+ {
+ "effective_cache_size", PGC_USERSET, &effective_cache_size,
+ DEFAULT_EFFECTIVE_CACHE_SIZE, 0, DBL_MAX, NULL, NULL
+ } ,
+ {
+ "random_page_cost", PGC_USERSET, &random_page_cost,
+ DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX, NULL, NULL
+ },
+ {
+ "cpu_tuple_cost", PGC_USERSET, &cpu_tuple_cost,
+ DEFAULT_CPU_TUPLE_COST, 0, DBL_MAX, NULL, NULL
+ },
+ {
+ "cpu_index_tuple_cost", PGC_USERSET, &cpu_index_tuple_cost,
+ DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX, NULL, NULL
+ },
+ {
+ "cpu_operator_cost", PGC_USERSET, &cpu_operator_cost,
+ DEFAULT_CPU_OPERATOR_COST, 0, DBL_MAX, NULL, NULL
+ },
+
+ {
+ "geqo_selection_bias", PGC_USERSET, &Geqo_selection_bias,
+ DEFAULT_GEQO_SELECTION_BIAS, MIN_GEQO_SELECTION_BIAS,
+ MAX_GEQO_SELECTION_BIAS, NULL, NULL
+ },
+
+ {
+ NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, NULL
+ }
};
static struct config_string
ConfigureNamesString[] =
{
- {"default_transaction_isolation", PGC_USERSET, &default_iso_level_string,
- "read committed", check_defaultxactisolevel, assign_defaultxactisolevel},
+ {
+ "default_transaction_isolation", PGC_USERSET, &default_iso_level_string,
+ "read committed", check_defaultxactisolevel, assign_defaultxactisolevel
+ } ,
- {"dynamic_library_path", PGC_SUSET, &Dynamic_library_path,
- "$libdir", NULL, NULL},
+ {
+ "dynamic_library_path", PGC_SUSET, &Dynamic_library_path,
+ "$libdir", NULL, NULL
+ },
- {"krb_server_keyfile", PGC_POSTMASTER, &pg_krb_server_keyfile,
- PG_KRB_SRVTAB, NULL, NULL},
+ {
+ "krb_server_keyfile", PGC_POSTMASTER, &pg_krb_server_keyfile,
+ PG_KRB_SRVTAB, NULL, NULL
+ },
#ifdef ENABLE_SYSLOG
- {"syslog_facility", PGC_POSTMASTER, &Syslog_facility,
- "LOCAL0", check_facility, NULL},
- {"syslog_ident", PGC_POSTMASTER, &Syslog_ident,
- "postgres", NULL, NULL},
+ {
+ "syslog_facility", PGC_POSTMASTER, &Syslog_facility,
+ "LOCAL0", check_facility, NULL
+ },
+ {
+ "syslog_ident", PGC_POSTMASTER, &Syslog_ident,
+ "postgres", NULL, NULL
+ },
#endif
- {"unix_socket_group", PGC_POSTMASTER, &Unix_socket_group,
- "", NULL, NULL},
+ {
+ "unix_socket_group", PGC_POSTMASTER, &Unix_socket_group,
+ "", NULL, NULL
+ },
- {"unix_socket_directory", PGC_POSTMASTER, &UnixSocketDir,
- "", NULL, NULL},
+ {
+ "unix_socket_directory", PGC_POSTMASTER, &UnixSocketDir,
+ "", NULL, NULL
+ },
- {"virtual_host", PGC_POSTMASTER, &VirtualHost,
- "", NULL, NULL},
+ {
+ "virtual_host", PGC_POSTMASTER, &VirtualHost,
+ "", NULL, NULL
+ },
- {"wal_sync_method", PGC_SIGHUP, &XLOG_sync_method,
- XLOG_sync_method_default, check_xlog_sync_method,
- assign_xlog_sync_method},
+ {
+ "wal_sync_method", PGC_SIGHUP, &XLOG_sync_method,
+ XLOG_sync_method_default, check_xlog_sync_method,
+ assign_xlog_sync_method
+ },
- {NULL, 0, NULL, NULL, NULL, NULL}
+ {
+ NULL, 0, NULL, NULL, NULL, NULL
+ }
};
/******** end of options list ********/
val = strtol(value, &endptr, 0);
if (endptr == value || *endptr != '\0' || errno == ERANGE
#ifdef HAVE_LONG_INT_64
- /* if long > 32 bits, check for overflow of int4 */
+ /* if long > 32 bits, check for overflow of int4 */
|| val != (long) ((int32) val)
#endif
- )
+ )
return false;
if (result)
*result = (int) val;
case PGC_SIGHUP:
if (context != PGC_SIGHUP && context != PGC_POSTMASTER)
elog(ERROR, "'%s' cannot be changed now", name);
+
/*
- * Hmm, the idea of the SIGHUP context is "ought to be global, but
- * can be changed after postmaster start". But there's nothing
- * that prevents a crafty administrator from sending SIGHUP
- * signals to individual backends only.
+ * Hmm, the idea of the SIGHUP context is "ought to be global,
+ * but can be changed after postmaster start". But there's
+ * nothing that prevents a crafty administrator from sending
+ * SIGHUP signals to individual backends only.
*/
break;
case PGC_BACKEND:
if (context == PGC_SIGHUP)
{
/*
- * If a PGC_BACKEND parameter is changed in the config file,
- * we want to accept the new value in the postmaster (whence
- * it will propagate to subsequently-started backends), but
- * ignore it in existing backends. This is a tad klugy, but
- * necessary because we don't re-read the config file during
- * backend start.
+ * If a PGC_BACKEND parameter is changed in the config
+ * file, we want to accept the new value in the postmaster
+ * (whence it will propagate to subsequently-started
+ * backends), but ignore it in existing backends. This is
+ * a tad klugy, but necessary because we don't re-read the
+ * config file during backend start.
*/
if (IsUnderPostmaster)
return true;
if (makeDefault)
{
str = strdup(value);
- if (str == NULL) {
+ if (str == NULL)
+ {
elog(elevel, "out of memory");
return false;
}
}
static void
-_ShowOption(enum config_type opttype, struct config_generic *record)
+_ShowOption(enum config_type opttype, struct config_generic * record)
{
- char buffer[256];
- char *val;
+ char buffer[256];
+ char *val;
switch (opttype)
{
int i;
for (i = 0; ConfigureNamesBool[i].name; i++)
- _ShowOption(PGC_BOOL, (struct config_generic *)&ConfigureNamesBool[i]);
+ _ShowOption(PGC_BOOL, (struct config_generic *) & ConfigureNamesBool[i]);
for (i = 0; ConfigureNamesInt[i].name; i++)
- _ShowOption(PGC_INT, (struct config_generic *)&ConfigureNamesInt[i]);
+ _ShowOption(PGC_INT, (struct config_generic *) & ConfigureNamesInt[i]);
for (i = 0; ConfigureNamesReal[i].name; i++)
- _ShowOption(PGC_REAL, (struct config_generic *)&ConfigureNamesReal[i]);
+ _ShowOption(PGC_REAL, (struct config_generic *) & ConfigureNamesReal[i]);
for (i = 0; ConfigureNamesString[i].name; i++)
- _ShowOption(PGC_STRING, (struct config_generic *)&ConfigureNamesString[i]);
+ _ShowOption(PGC_STRING, (struct config_generic *) & ConfigureNamesString[i]);
}
return true;
return false;
}
-
#endif
* to contain some useful information. Mechanism differs wildly across
* platforms.
*
- * $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.7 2001/10/22 19:41:38 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.8 2001/10/25 05:49:51 momjian Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* various details abducted from various places
#else /* PS_USE_CLOBBER_ARGV */
static char *ps_buffer; /* will point to argv area */
static size_t ps_buffer_size; /* space determined at run time */
-
#endif /* PS_USE_CLOBBER_ARGV */
static size_t ps_buffer_fixed_size; /* size of the constant prefix */
* Call this early in startup to save the original argc/argv values.
*
* argv[] will not be overwritten by this routine, but may be overwritten
- * during init_ps_display. Also, the physical location of the environment
+ * during init_ps_display. Also, the physical location of the environment
* strings may be moved, so this should be called before any code that
* might try to hang onto a getenv() result.
*/
save_argv = argv;
#ifdef PS_USE_CLOBBER_ARGV
+
/*
* If we're going to overwrite the argv area, count the available
* space. Also move the environment to make additional room.
end_of_area = argv[i] + strlen(argv[i]);
}
- if (end_of_area == NULL) /* probably can't happen? */
+ if (end_of_area == NULL)/* probably can't happen? */
{
ps_buffer = NULL;
ps_buffer_size = 0;
/*
* Call this once during subprocess startup to set the identification
- * values. At this point, the original argv[] array may be overwritten.
+ * values. At this point, the original argv[] array may be overwritten.
*/
void
init_ps_display(const char *username, const char *dbname,
*/
#ifdef PS_USE_SETPROCTITLE
+
/*
* apparently setproctitle() already adds a `progname:' prefix to the
* ps line
*cp = PS_PADDING;
}
#endif /* PS_USE_CLOBBER_ARGV */
-
#endif /* not PS_USE_NONE */
}
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.41 2001/03/22 04:00:07 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.42 2001/10/25 05:49:51 momjian Exp $
*
* NOTE:
* This is a new (Feb. 05, 1999) implementation of the allocation set
#ifdef MEMORY_CONTEXT_CHECKING
static void AllocSetCheck(MemoryContext context);
-
#endif
static void AllocSetStats(MemoryContext context);
static void
AllocSetInit(MemoryContext context)
{
-
/*
* Since MemoryContextCreate already zeroed the context node, we don't
* have to do anything here: it's already OK.
if (availspace < (chunk_size + ALLOC_CHUNKHDRSZ))
{
-
/*
* The existing active (top) block does not have enough room
* for the requested allocation, but it might still have a
if (chunk->size > ALLOC_CHUNK_LIMIT)
{
-
/*
* Big chunks are certain to have been allocated as single-chunk
* blocks. Find the containing block and return it to malloc().
if (oldsize > ALLOC_CHUNK_LIMIT)
{
-
/*
* The chunk must been allocated as a single-chunk block. Find
* the containing block and use realloc() to make it bigger with
}
else
{
-
/*
* Small-chunk case. If the chunk is the last one in its block,
* there might be enough free space after it that we can just
name, block);
}
}
-
#endif /* MEMORY_CONTEXT_CHECKING */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.28 2001/03/22 04:00:08 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.29 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
for (child = context->firstchild; child != NULL; child = child->nextchild)
MemoryContextCheck(child);
}
-
#endif
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.43 2001/10/05 17:28:13 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.44 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*
* XXX This assumes that portals can be deleted in a random order, ie,
* no portal has a reference to any other (at least not one that will be
- * exercised during deletion). I think this is okay at the moment, but
+ * exercised during deletion). I think this is okay at the moment, but
* we've had bugs of that ilk in the past. Keep a close eye on cursor
* references...
*/
hash_seq_init(&status, PortalHashTable);
while ((hentry = (PortalHashEnt *) hash_seq_search(&status)) != NULL)
- {
PortalDrop(hentry->portal);
- }
}
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/sort/logtape.c,v 1.6 2001/01/24 19:43:17 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/sort/logtape.c,v 1.7 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static long
ltsGetFreeBlock(LogicalTapeSet *lts)
{
-
/*
* If there are multiple free blocks, we select the one appearing last
* in freeBlocks[]. If there are none, assign the next block at the
{
if (indirect->nextSlot >= BLOCKS_PER_INDIR_BLOCK)
{
-
/*
* This indirect block is full, so dump it out and recursively
* save its address in the next indirection level. Create a new
ltsRewindFrozenIndirectBlock(LogicalTapeSet *lts,
IndirectBlock *indirect)
{
-
/*
* If block is not topmost, recurse to obtain address of first block
* in this hierarchy level. Read that one in.
{
if (lt->writing)
{
-
/*
* Completion of a write phase. Flush last partial data
* block, flush any partial indirect blocks, rewind for normal
}
else
{
-
/*
* This is only OK if tape is frozen; we rewind for (another)
* read pass.
}
else
{
-
/*
* Completion of a read phase. Rewind and prepare for write.
*
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.18 2001/08/21 16:36:05 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.19 2001/10/25 05:49:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
typedef enum
{
- TSS_INITIAL, /* Loading tuples; still within memory
+ TSS_INITIAL, /* Loading tuples; still within memory
* limit */
- TSS_BUILDRUNS, /* Loading tuples; writing to tape */
- TSS_SORTEDINMEM, /* Sort completed entirely in memory */
- TSS_SORTEDONTAPE, /* Sort completed, final run is on tape */
- TSS_FINALMERGE /* Performing final merge on-the-fly */
+ TSS_BUILDRUNS, /* Loading tuples; writing to tape */
+ TSS_SORTEDINMEM,/* Sort completed entirely in memory */
+ TSS_SORTEDONTAPE, /* Sort completed, final run is on
+ * tape */
+ TSS_FINALMERGE /* Performing final merge on-the-fly */
} TupSortStatus;
/*
* kind of tuple we are sorting from the routines that don't need to
* know it. They are set up by the tuplesort_begin_xxx routines.
*
- * Function to compare two tuples; result is per qsort() convention,
- * ie:
+ * Function to compare two tuples; result is per qsort() convention, ie:
*
- * <0, 0, >0 according as ab.
+ * <0, 0, >0 according as ab.
*/
int (*comparetup) (Tuplesortstate *state, const void *a, const void *b);
if (state->memtupindex)
pfree(state->memtupindex);
- /* this stuff might better belong in a variant-specific shutdown routine */
+ /*
+ * this stuff might better belong in a variant-specific shutdown
+ * routine
+ */
if (state->scanKeys)
pfree(state->scanKeys);
if (state->sortFnKinds)
void
tuplesort_puttuple(Tuplesortstate *state, void *tuple)
{
-
/*
* Copy the given tuple into memory we control, and decrease availMem.
* Then call the code shared with the Datum case.
{
switch (state->status)
{
- case TSS_INITIAL:
+ case TSS_INITIAL:
/*
* Save the copied tuple into the unsorted array.
{
switch (state->status)
{
- case TSS_INITIAL:
+ case TSS_INITIAL:
/*
* We were able to accumulate all the tuples within the
*/
if (state->eof_reached)
{
-
/*
* Seek position is pointing just past the zero tuplen at
* the end of file; back up to fetch last tuple's ending
}
else
{
-
/*
* Back up and fetch previously-returned tuple's ending
* length word. If seek fails, assume we are at start of
state->result_tape,
tuplen + 2 * sizeof(unsigned int)))
{
-
/*
* If that fails, presumably the prev tuple is the
* first in the file. Back up so that it becomes next
tuplesort_heap_siftup(state, false);
if ((tupIndex = state->mergenext[srcTape]) == 0)
{
-
/*
* out of preloaded data on this tape, try to read
* more
while (alltuples ||
(LACKMEM(state) && state->memtupcount > 1))
{
-
/*
* Dump the heap's frontmost entry, and sift up to remove it from
* the heap.
/*
* This routine selects an appropriate sorting function to implement
- * a sort operator as efficiently as possible. The straightforward
+ * a sort operator as efficiently as possible. The straightforward
* method is to use the operator's implementation proc --- ie, "<"
- * comparison. However, that way often requires two calls of the function
- * per comparison. If we can find a btree three-way comparator function
+ * comparison. However, that way often requires two calls of the function
+ * per comparison. If we can find a btree three-way comparator function
* associated with the operator, we can use it to do the comparisons
* more efficiently. We also support the possibility that the operator
* is ">" (descending sort), in which case we have to reverse the output
Oid opclass = InvalidOid;
/*
- * Scan pg_amop to see if the target operator is registered as the
- * "<" or ">" operator of any btree opclass. It's possible that it
- * might be registered both ways (eg, if someone were to build a
- * "reverse sort" opclass for some reason); prefer the "<" case if so.
- * If the operator is registered the same way in multiple opclasses,
- * assume we can use the associated comparator function from any one.
+ * Scan pg_amop to see if the target operator is registered as the "<"
+ * or ">" operator of any btree opclass. It's possible that it might
+ * be registered both ways (eg, if someone were to build a "reverse
+ * sort" opclass for some reason); prefer the "<" case if so. If the
+ * operator is registered the same way in multiple opclasses, assume
+ * we can use the associated comparator function from any one.
*/
ScanKeyEntryInitialize(&skey[0], 0x0,
Anum_pg_amop_amopopr,
if (HeapTupleIsValid(tuple))
{
Form_pg_amproc aform = (Form_pg_amproc) GETSTRUCT(tuple);
+
*sortFunction = aform->amproc;
ReleaseSysCache(tuple);
Assert(RegProcedureIsValid(*sortFunction));
/*
* Can't find a comparator, so use the operator as-is. Decide whether
* it is forward or reverse sort by looking at its name (grotty, but
- * this only matters for deciding which end NULLs should get sorted to).
+ * this only matters for deciding which end NULLs should get sorted
+ * to).
*/
tuple = SearchSysCache(OPEROID,
ObjectIdGetDatum(sortOperator),
}
if (isNull2)
return 1;
- return - DatumGetInt32(FunctionCall2(sortFunction,
- datum1, datum2));
+ return -DatumGetInt32(FunctionCall2(sortFunction,
+ datum1, datum2));
default:
elog(ERROR, "Invalid SortFunctionKind %d", (int) kind);
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplestore.c,v 1.3 2001/03/22 04:00:10 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplestore.c,v 1.4 2001/10/25 05:49:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
typedef enum
{
- TSS_INITIAL, /* Loading tuples; still within memory
+ TSS_INITIAL, /* Loading tuples; still within memory
* limit */
- TSS_WRITEFILE, /* Loading tuples; writing to temp file */
- TSS_READMEM, /* Reading tuples; entirely in memory */
- TSS_READFILE /* Reading tuples from temp file */
+ TSS_WRITEFILE, /* Loading tuples; writing to temp file */
+ TSS_READMEM, /* Reading tuples; entirely in memory */
+ TSS_READFILE /* Reading tuples from temp file */
} TupStoreStatus;
/*
void
tuplestore_puttuple(Tuplestorestate *state, void *tuple)
{
-
/*
* Copy the tuple. (Must do this even in WRITEFILE case.)
*/
{
switch (state->status)
{
- case TSS_INITIAL:
+ case TSS_INITIAL:
/*
* We were able to accumulate all the tuples within the
*/
if (state->eof_reached)
{
-
/*
* Seek position is pointing just past the zero tuplen at
* the end of file; back up to fetch last tuple's ending
}
else
{
-
/*
* Back up and fetch previously-returned tuple's ending
* length word. If seek fails, assume we are at start of
-(long) (tuplen + 2 * sizeof(unsigned int)),
SEEK_CUR) != 0)
{
-
/*
* If that fails, presumably the prev tuple is the
* first in the file. Back up so that it becomes next
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.42 2001/08/26 16:56:00 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.43 2001/10/25 05:49:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
if (th->t_infomask & HEAP_MARKED_FOR_UPDATE)
return HeapTupleMayBeUpdated;
- return HeapTupleUpdated;/* updated by other */
+ return HeapTupleUpdated; /* updated by other */
}
if (TransactionIdIsCurrentTransactionId(th->t_xmax))
if (tuple->t_infomask & HEAP_MOVED_OFF)
{
-
/*
* HeapTupleSatisfiesDirty is used by unique btree-s and so
* may be used while vacuuming.
* HeapTupleSatisfiesVacuum - determine tuple status for VACUUM and related
* operations
*
- * OldestXmin is a cutoff XID (obtained from GetOldestXmin()). Tuples
+ * OldestXmin is a cutoff XID (obtained from GetOldestXmin()). Tuples
* deleted by XIDs >= OldestXmin are deemed "recently dead"; they might
* still be visible to some open transaction, so we can't remove them,
* even if we see that the deleting transaction has committed.
* NOTE: must check TransactionIdIsInProgress (which looks in PROC array)
* before TransactionIdDidCommit/TransactionIdDidAbort (which look in
* pg_clog). Otherwise we have a race condition where we might decide
- * that a just-committed transaction crashed, because none of the tests
- * succeed. xact.c is careful to record commit/abort in pg_clog before
- * it unsets MyProc->xid in PROC array.
+ * that a just-committed transaction crashed, because none of the
+ * tests succeed. xact.c is careful to record commit/abort in pg_clog
+ * before it unsets MyProc->xid in PROC array.
*/
if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
{
else
{
/*
- * Not in Progress, Not Committed, Not Aborted -
- * so it's from crashed process. - vadim 11/26/96
+ * Not in Progress, Not Committed, Not Aborted - so it's from
+ * crashed process. - vadim 11/26/96
*/
tuple->t_infomask |= HEAP_XMIN_INVALID;
return HEAPTUPLE_DEAD;
}
/*
- * Okay, the inserter committed, so it was good at some point. Now
+ * Okay, the inserter committed, so it was good at some point. Now
* what about the deleting transaction?
*/
if (tuple->t_infomask & HEAP_XMAX_INVALID)
else
{
/*
- * Not in Progress, Not Committed, Not Aborted -
- * so it's from crashed process. - vadim 06/02/97
+ * Not in Progress, Not Committed, Not Aborted - so it's from
+ * crashed process. - vadim 06/02/97
*/
tuple->t_infomask |= HEAP_XMAX_INVALID;
return HEAPTUPLE_LIVE;
if (TransactionIdEquals(tuple->t_xmin, tuple->t_xmax))
{
- /* inserter also deleted it, so it was never visible to anyone else */
+ /*
+ * inserter also deleted it, so it was never visible to anyone
+ * else
+ */
return HEAPTUPLE_DEAD;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.59 2001/10/22 19:31:09 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.60 2001/10/25 05:49:52 momjian Exp $
*
*
selfInd = findTableByOid(tblinfo, numTables, oid);
if (selfInd >= 0)
write_msg(NULL, "failed sanity check, parent oid %s of table %s (oid %s) not found\n",
- inhinfo[i].inhparent,
- tblinfo[selfInd].relname,
- oid);
+ inhinfo[i].inhparent,
+ tblinfo[selfInd].relname,
+ oid);
else
write_msg(NULL, "failed sanity check, parent oid %s of table (oid %s) not found\n",
- inhinfo[i].inhparent,
- oid);
+ inhinfo[i].inhparent,
+ oid);
exit_nicely();
}
*
*/
-TableInfo *
+TableInfo *
dumpSchema(Archive *fout,
int *numTablesPtr,
const char *tablename,
int parentInd;
int inhAttrInd;
int (*parentIndexes)[];
- bool foundAttr; /* Attr was found in a parent */
+ bool foundAttr; /* Attr was found in a parent */
bool foundNotNull; /* Attr was NOT NULL in a parent */
bool defaultsMatch; /* All non-empty defaults match */
bool defaultsFound; /* Found a default in a parent */
- char *attrDef;
- char *inhDef;
+ char *attrDef;
+ char *inhDef;
/*
* we go backwards because the tables in tblinfo are in OID order,
&parentIndexes);
/*
- * For each attr, check the parent info: if no parent has
- * an attr with the same name, then it's not inherited. If there
- * *is* an attr with the same name, then only dump it if:
+ * For each attr, check the parent info: if no parent has an attr
+ * with the same name, then it's not inherited. If there *is* an
+ * attr with the same name, then only dump it if:
*
- * - it is NOT NULL and zero parents are NOT NULL
- * OR
- * - it has a default value AND the default value
- * does not match all parent default values, or
- * no parents specify a default.
+ * - it is NOT NULL and zero parents are NOT NULL OR - it has a
+ * default value AND the default value does not match all parent
+ * default values, or no parents specify a default.
*
* See discussion on -hackers around 2-Apr-2001.
*/
{
foundAttr = true;
foundNotNull |= tblinfo[parentInd].notnull[inhAttrInd];
- if (attrDef != NULL) /* It we have a default, check parent */
+ if (attrDef != NULL) /* It we have a default,
+ * check parent */
{
inhDef = tblinfo[parentInd].adef_expr[inhAttrInd];
};
};
- /*
- * Based on the scan of the parents, decide if we
- * can rely on the inherited attr
+ /*
+ * Based on the scan of the parents, decide if we can rely on
+ * the inherited attr
*/
- if (foundAttr) /* Attr was inherited */
+ if (foundAttr) /* Attr was inherited */
{
/* Set inherited flag by default */
tblinfo[i].inhAttrs[j] = 1;
tblinfo[i].inhAttrDef[j] = 1;
tblinfo[i].inhNotNull[j] = 1;
- /* Clear it if attr had a default, but parents did not, or mismatch */
- if ( (attrDef != NULL) && (!defaultsFound || !defaultsMatch) )
+ /*
+ * Clear it if attr had a default, but parents did not, or
+ * mismatch
+ */
+ if ((attrDef != NULL) && (!defaultsFound || !defaultsMatch))
{
tblinfo[i].inhAttrs[j] = 0;
tblinfo[i].inhAttrDef[j] = 0;
}
- /* Clear it if NOT NULL and none of the parents were NOT NULL */
+ /*
+ * Clear it if NOT NULL and none of the parents were NOT
+ * NULL
+ */
if (tblinfo[i].notnull[j] && !foundNotNull)
{
tblinfo[i].inhAttrs[j] = 0;
appendPQExpBufferChar(id_return, '\"');
for (cp = rawid; *cp; cp++)
{
-
/*
* Did we find a double-quote in the string? Then make this a
* double double-quote per SQL99. Before, we put in a
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.15 2001/10/03 21:58:28 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.16 2001/10/25 05:49:52 momjian Exp $
*
*
typedef enum _archiveFormat
{
- archUnknown = 0,
- archCustom = 1,
- archFiles = 2,
- archTar = 3,
- archNull = 4
+ archUnknown = 0,
+ archCustom = 1,
+ archFiles = 2,
+ archTar = 3,
+ archNull = 4
} ArchiveFormat;
/*
*/
typedef struct _Archive
{
- int verbose;
- int remoteVersion;
- int minRemoteVersion;
- int maxRemoteVersion;
+ int verbose;
+ int remoteVersion;
+ int minRemoteVersion;
+ int maxRemoteVersion;
/* The rest is private */
} Archive;
* original object owner */
int noReconnect; /* Don't reconnect to database under any
* cirsumstances */
- int use_setsessauth; /* use SET SESSSION AUTHORIZATION instead of \connect */
+ int use_setsessauth;/* use SET SESSSION AUTHORIZATION instead
+ * of \connect */
char *superuser; /* Username to use as superuser */
int dataOnly;
int dropSchema;
int limitToList;
int compression;
- int suppressDumpWarnings; /* Suppress output of WARNING entries to stderr */
+ int suppressDumpWarnings; /* Suppress output of WARNING
+ * entries to stderr */
} RestoreOptions;
/*
* Main archiver interface.
*/
-extern void exit_horribly(Archive *AH, const char *modulename, const char *fmt, ...)
-__attribute__((format(printf,3,4)));
+extern void
+exit_horribly(Archive *AH, const char *modulename, const char *fmt,...)
+__attribute__((format(printf, 3, 4)));
extern char *
-simple_prompt(const char *prompt, int maxlen, bool echo);
+ simple_prompt(const char *prompt, int maxlen, bool echo);
/* Lets the archibe know we have a DB connection to shutdown if it dies */
/* Convenience functions used only when writing DATA */
extern int archputs(const char *s, Archive *AH);
extern int archputc(const char c, Archive *AH);
-extern int archprintf(Archive *AH, const char *fmt, ...)
+extern int
+archprintf(Archive *AH, const char *fmt,...)
/* This extension allows gcc to check the format string */
__attribute__((format(printf, 2, 3)));
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.34 2001/10/23 21:26:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.35 2001/10/25 05:49:52 momjian Exp $
*
*
* - Only disable triggers in DataOnly (or implied data-only) restores.
*
- *
+ *
* - Rudimentary support for dependencies in archives. Current implementation
* uses dependencies to modify the OID used in sorting TOC entries.
* This will NOT handle multi-level dependencies, but will manage simple
* relationships like UDTs & their functions.
*
- * - Treat OIDs with more respect (avoid using ints, use macros for
+ * - Treat OIDs with more respect (avoid using ints, use macros for
* conversion & comparison).
*
* - Treat SEQUENCE SET TOC entries as data entries rather than schema
* entries.
* - Make allowance for data entries that did not have a data dumper
- * routine (eg. SEQUENCE SET)
+ * routine (eg. SEQUENCE SET)
*
*-------------------------------------------------------------------------
*/
static void _moveBefore(ArchiveHandle *AH, TocEntry *pos, TocEntry *te);
static int _discoverArchiveFormat(ArchiveHandle *AH);
static void _fixupOidInfo(TocEntry *te);
-static Oid _findMaxOID(const char *((*deps)[]));
+static Oid _findMaxOID(const char *((*deps)[]));
const char *progname;
static char *modulename = gettext_noop("archiver");
/* Create a new archive */
/* Public */
-Archive *
+Archive *
CreateArchive(const char *FileSpec, const ArchiveFormat fmt,
const int compression)
/* Open an existing archive */
/* Public */
-Archive *
+Archive *
OpenArchive(const char *FileSpec, const ArchiveFormat fmt)
{
ArchiveHandle *AH = _allocAH(FileSpec, fmt, 0, archModeRead);
*
* NB: create+dropSchema is useless because if you're creating the DB,
* there's no need to drop individual items in it. Moreover, if we
- * tried to do that then we'd issue the drops in the database initially
- * connected to, not the one we will create, which is very bad...
+ * tried to do that then we'd issue the drops in the database
+ * initially connected to, not the one we will create, which is very
+ * bad...
*/
if (ropt->create && ropt->noReconnect)
die_horribly(AH, modulename, "-C and -R are incompatible options\n");
write_msg(modulename, "WARNING:\n"
" Data restoration may fail because existing triggers cannot be disabled\n"
" (no superuser user name specified). This is only a problem when\n"
- " restoring into a database with already existing triggers.\n");
+ " restoring into a database with already existing triggers.\n");
/*
* Setup the output file if necessary.
/* Dump any relevant dump warnings to stderr */
if (!ropt->suppressDumpWarnings && strcmp(te->desc, "WARNING") == 0)
{
- if (!ropt->dataOnly && te->defn != NULL && strlen(te->defn) != 0)
+ if (!ropt->dataOnly && te->defn != NULL && strlen(te->defn) != 0)
write_msg(modulename, "warning from original dump file: %s\n", te->defn);
else if (te->copyStmt != NULL && strlen(te->copyStmt) != 0)
write_msg(modulename, "warning from original dump file: %s\n", te->copyStmt);
- }
+ }
defnDumped = false;
ahlog(AH, 1, "connecting to new database %s as user %s\n", te->name, te->owner);
_reconnectAsUser(AH, te->name, te->owner);
}
- }
+ }
/*
* If we have a data component, then process it
*/
- if ( (reqs & 2) != 0 )
+ if ((reqs & 2) != 0)
{
- /* hadDumper will be set if there is genuine data component for this
- * node. Otherwise, we need to check the defn field for statements
- * that need to be executed in data-only restores.
+ /*
+ * hadDumper will be set if there is genuine data component
+ * for this node. Otherwise, we need to check the defn field
+ * for statements that need to be executed in data-only
+ * restores.
*/
- if (te->hadDumper)
+ if (te->hadDumper)
{
/*
* If we can output the data, then restore it.
_printTocEntry(AH, te, ropt, true);
/*
- * Maybe we can't do BLOBS, so check if this node is for BLOBS
+ * Maybe we can't do BLOBS, so check if this node is
+ * for BLOBS
*/
if ((strcmp(te->desc, "BLOBS") == 0) && !_canRestoreBlobs(AH))
{
ahprintf(AH, "--\n-- SKIPPED \n--\n\n");
/*
- * This is a bit nasty - we assume, for the moment, that
- * if a custom output is used, then we don't want
- * warnings.
+ * This is a bit nasty - we assume, for the
+ * moment, that if a custom output is used, then
+ * we don't want warnings.
*/
if (!AH->CustomOutPtr)
write_msg(modulename, "WARNING: skipping large object restoration\n");
_disableTriggersIfNecessary(AH, te, ropt);
/*
- * Reconnect if necessary (_disableTriggers may have
- * reconnected)
+ * Reconnect if necessary (_disableTriggers may
+ * have reconnected)
*/
_reconnectAsOwner(AH, NULL, te);
ahlog(AH, 1, "restoring data for table %s\n", te->name);
/*
- * If we have a copy statement, use it. As of V1.3, these
- * are separate to allow easy import from withing a
- * database connection. Pre 1.3 archives can not use DB
- * connections and are sent to output only.
+ * If we have a copy statement, use it. As of
+ * V1.3, these are separate to allow easy import
+ * from withing a database connection. Pre 1.3
+ * archives can not use DB connections and are
+ * sent to output only.
*
- * For V1.3+, the table data MUST have a copy statement so
- * that we can go into appropriate mode with libpq.
+ * For V1.3+, the table data MUST have a copy
+ * statement so that we can go into appropriate
+ * mode with libpq.
*/
if (te->copyStmt && strlen(te->copyStmt) > 0)
ahprintf(AH, te->copyStmt);
_enableTriggersIfNecessary(AH, te, ropt);
}
}
- } else if (!defnDumped) {
- /* If we haven't already dumped the defn part, do so now */
+ }
+ else if (!defnDumped)
+ {
+ /* If we haven't already dumped the defn part, do so now */
ahlog(AH, 1, "executing %s %s\n", te->desc, te->name);
_printTocEntry(AH, te, ropt, false);
}
{
if (!_restoringToDB(AH) || !ConnectedUserIsSuperuser(AH))
{
-
/*
* If we're not allowing changes for ownership, then remember
* the user so we can change it back here. Otherwise, let
{
if (!_restoringToDB(AH) || !ConnectedUserIsSuperuser(AH))
{
-
/*
* If we're not allowing changes for ownership, then remember
* the user so we can change it back here. Otherwise, let
#ifdef HAVE_LIBZ
char fmode[10];
-
#endif
int fn = 0;
}
else
{
-
/*
* If we're doing a restore, and it's direct to DB, and we're
* connected then send it to the DB.
}
void
-write_msg(const char *modulename, const char *fmt, ...)
+write_msg(const char *modulename, const char *fmt,...)
{
va_list ap;
int wantClose = 0;
#if 0
- write_msg(modulename, "attempting to ascertain archive format\n");
+ write_msg(modulename, "attempting to ascertain archive format\n");
#endif
if (AH->lookahead)
}
else
{
-
/*
* *Maybe* we have a tar archive format file... So, read first 512
* byte header...
/* If we can't seek, then mark the header as read */
if (fseek(fh, 0, SEEK_SET) != 0)
{
-
/*
* NOTE: Formats that use the looahead buffer can unset this in
* their Init routine.
ArchiveHandle *AH;
#if 0
- write_msg(modulename, "allocating AH for %s, format %d\n", FileSpec, fmt);
+ write_msg(modulename, "allocating AH for %s, format %d\n", FileSpec, fmt);
#endif
AH = (ArchiveHandle *) calloc(1, sizeof(ArchiveHandle));
AH->OF = stdout;
#if 0
- write_msg(modulename, "archive format is %d\n", fmt);
+ write_msg(modulename, "archive format is %d\n", fmt);
#endif
if (fmt == archUnknown)
if (te->depOid != NULL)
{
i = 0;
- while( (dep = (*te->depOid)[i++]) != NULL)
- {
+ while ((dep = (*te->depOid)[i++]) != NULL)
WriteStr(AH, dep);
- }
}
- WriteStr(AH, NULL); /* Terminate List */
+ WriteStr(AH, NULL); /* Terminate List */
if (AH->WriteExtraTocPtr)
(*AH->WriteExtraTocPtr) (AH, te);
ReadToc(ArchiveHandle *AH)
{
int i;
- char *((*deps)[]);
+ char *((*deps)[]);
int depIdx;
int depSize;
if (AH->version >= K_VERS_1_5)
{
depSize = 100;
- deps = malloc(sizeof(char*) * depSize);
+ deps = malloc(sizeof(char *) * depSize);
depIdx = 0;
do
{
if (depIdx > depSize)
{
depSize *= 2;
- deps = realloc(deps, sizeof(char*) * depSize);
+ deps = realloc(deps, sizeof(char *) * depSize);
}
(*deps)[depIdx] = ReadStr(AH);
#if 0
write_msg(modulename, "read dependency for %s -> %s\n",
te->name, (*deps)[depIdx]);
#endif
- } while ( (*deps)[depIdx++] != NULL);
+ } while ((*deps)[depIdx++] != NULL);
- if (depIdx > 1) /* We have a non-null entry */
- te->depOid = realloc(deps, sizeof(char*) * depIdx); /* trim it */
+ if (depIdx > 1) /* We have a non-null entry */
+ te->depOid = realloc(deps, sizeof(char *) * depIdx); /* trim it */
else
- te->depOid = NULL; /* no deps */
+ te->depOid = NULL; /* no deps */
}
else
te->depOid = NULL;
* user, this won't do anything.
*
* If we're currently restoring right into a database, this will
- * actuall establish a connection. Otherwise it puts a \connect into
+ * actuall establish a connection. Otherwise it puts a \connect into
* the script output.
*/
static void
|| (strcmp(AH->currUser, user) == 0 && !dbname))
return; /* no need to do anything */
- /* Use SET SESSION AUTHORIZATION if allowed and no database change needed */
+ /*
+ * Use SET SESSION AUTHORIZATION if allowed and no database change
+ * needed
+ */
if (!dbname && AH->ropt->use_setsessauth)
{
if (RestoringToDB(AH))
dbname ? dbname : "-",
user ? user : "-");
- /* NOTE: currUser keeps track of what the imaginary session user
- in our script is */
+ /*
+ * NOTE: currUser keeps track of what the imaginary session user in
+ * our script is
+ */
if (AH->currUser)
free(AH->currUser);
static int
_printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData)
{
- char *pfx;
+ char *pfx;
if (isData)
- {
pfx = "Data for ";
- } else {
+ else
pfx = "";
- }
ahprintf(AH, "--\n-- %sTOC Entry ID %d (OID %s)\n--\n-- Name: %s Type: %s Owner: %s\n",
pfx, te->id, te->oid, te->name, te->desc, te->owner);
te = AH->toc;
for (i = 0; i <= AH->tocCount + 1; i++)
{
-
/*
* printf("%d: %x (%x, %x) - %d\n", i, te, te->prev, te->next,
* te->oidVal);
te = AH->toc;
for (i = 0; i <= AH->tocCount + 1; i++)
{
-
/*
* printf("%d: %x (%x, %x) - %d\n", i, te, te->prev, te->next,
* te->oidVal);
/* If we have a deterministic answer, return it. */
if (cmpval != 0)
- return cmpval;
+ return cmpval;
/* More comparisons required */
- if ( oideq(id1, te1->maxDepOidVal) ) /* maxOid1 came from deps */
+ if (oideq(id1, te1->maxDepOidVal)) /* maxOid1 came from deps */
{
- if ( oideq(id2, te2->maxDepOidVal) ) /* maxOid2 also came from deps */
+ if (oideq(id2, te2->maxDepOidVal)) /* maxOid2 also came from
+ * deps */
{
- cmpval = oidcmp(te1->oidVal, te2->oidVal); /* Just compare base OIDs */
+ cmpval = oidcmp(te1->oidVal, te2->oidVal); /* Just compare base
+ * OIDs */
}
- else /* MaxOid2 was entry OID */
+ else
+/* MaxOid2 was entry OID */
{
- return 1; /* entry1 > entry2 */
+ return 1; /* entry1 > entry2 */
};
- }
- else /* must have oideq(id1, te1->oidVal) => maxOid1 = Oid1 */
+ }
+ else
+/* must have oideq(id1, te1->oidVal) => maxOid1 = Oid1 */
{
- if ( oideq(id2, te2->maxDepOidVal) ) /* maxOid2 came from deps */
+ if (oideq(id2, te2->maxDepOidVal)) /* maxOid2 came from deps */
{
- return -1; /* entry1 < entry2 */
+ return -1; /* entry1 < entry2 */
}
- else /* MaxOid2 was entry OID - deps don't matter */
+ else
+/* MaxOid2 was entry OID - deps don't matter */
{
cmpval = 0;
};
};
- /* If we get here, then we've done another comparison
- * Once again, a 0 result means we require even more
+ /*
+ * If we get here, then we've done another comparison Once again, a 0
+ * result means we require even more
*/
if (cmpval != 0)
return cmpval;
- /* Entire OID details match, so use ID number (ie. original pg_dump order) */
+ /*
+ * Entire OID details match, so use ID number (ie. original pg_dump
+ * order)
+ */
return _tocSortCompareByIDNum(te1, te2);
}
* Assuming Oid and depOid are set, work out the various
* Oid values used in sorting.
*/
-static void
+static void
_fixupOidInfo(TocEntry *te)
{
te->oidVal = atooid(te->oid);
te->maxDepOidVal = _findMaxOID(te->depOid);
/* For the purpose of sorting, find the max OID. */
- if (oidcmp(te->oidVal, te->maxDepOidVal) >= 0)
+ if (oidcmp(te->oidVal, te->maxDepOidVal) >= 0)
te->maxOidVal = te->oidVal;
else
te->maxOidVal = te->maxDepOidVal;
}
-/*
- * Find the max OID value for a given list of string Oid values
+/*
+ * Find the max OID value for a given list of string Oid values
*/
static Oid
_findMaxOID(const char *((*deps)[]))
{
const char *dep;
int i;
- Oid maxOid = (Oid)0;
+ Oid maxOid = (Oid) 0;
Oid currOid;
if (!deps)
return maxOid;
i = 0;
- while( (dep = (*deps)[i++]) != NULL)
+ while ((dep = (*deps)[i++]) != NULL)
{
currOid = atooid(dep);
if (oidcmp(maxOid, currOid) < 0)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.37 2001/08/22 20:23:23 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.38 2001/10/25 05:49:52 momjian Exp $
*
* - Initial version.
int avail_out;
} z_stream;
typedef z_stream *z_streamp;
-
#endif
#include "pg_backup.h"
#define K_VERS_MAJOR 1
#define K_VERS_MINOR 5
-#define K_VERS_REV 6
+#define K_VERS_REV 6
/* Data block types */
#define BLK_DATA 1
typedef enum _archiveMode
{
- archModeWrite,
- archModeRead
+ archModeWrite,
+ archModeRead
} ArchiveMode;
typedef struct _outputContext
typedef enum
{
- SQL_SCAN = 0,
- SQL_IN_SQL_COMMENT,
- SQL_IN_EXT_COMMENT,
- SQL_IN_QUOTE
+ SQL_SCAN = 0,
+ SQL_IN_SQL_COMMENT,
+ SQL_IN_EXT_COMMENT,
+ SQL_IN_QUOTE
} sqlparseState;
typedef struct
ReadBufPtr ReadBufPtr; /* Read a buffer of input from the archive */
ClosePtr ClosePtr; /* Close the archive */
WriteExtraTocPtr WriteExtraTocPtr; /* Write extra TOC entry data
- * associated with
- * the current archive format */
+ * associated with the current
+ * archive format */
ReadExtraTocPtr ReadExtraTocPtr; /* Read extr info associated with
* archie format */
PrintExtraTocPtr PrintExtraTocPtr; /* Extra TOC info for format */
int loFd; /* BLOB fd */
int writingBlob; /* Flag */
- int createdBlobXref;/* Flag */
+ int createdBlobXref; /* Flag */
int blobCount; /* # of blobs restored */
int lastID; /* Last internal ID for a TOC entry */
char *dropStmt;
char *copyStmt;
char *owner;
- char *oid; /* Oid of source of entry */
+ char *oid; /* Oid of source of entry */
Oid oidVal; /* Value of above */
const char *((*depOid)[]);
Oid maxDepOidVal; /* Value of largest OID in deps */
- Oid maxOidVal; /* Max of entry OID and max dep OID */
+ Oid maxOidVal; /* Max of entry OID and max dep OID */
int printed; /* Indicates if entry defn has been dumped */
DataDumperPtr dataDumper; /* Routine to dump data for object */
/* Used everywhere */
extern const char *progname;
-extern void die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt, ...) __attribute__((format(printf,3,4)));
-extern void write_msg(const char *modulename, const char *fmt, ...) __attribute__((format(printf,2,3)));
+extern void die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...) __attribute__((format(printf, 3, 4)));
+extern void write_msg(const char *modulename, const char *fmt,...) __attribute__((format(printf, 2, 3)));
extern void WriteTOC(ArchiveHandle *AH);
extern void ReadTOC(ArchiveHandle *AH);
extern int ConnectedUserIsSuperuser(ArchiveHandle *AH);
int ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH);
-int ahprintf(ArchiveHandle *AH, const char *fmt,...) __attribute__((format(printf,2,3)));
-
-void ahlog(ArchiveHandle *AH, int level, const char *fmt,...) __attribute__((format(printf,3,4)));
+int ahprintf(ArchiveHandle *AH, const char *fmt,...) __attribute__((format(printf, 2, 3)));
+void ahlog(ArchiveHandle *AH, int level, const char *fmt,...) __attribute__((format(printf, 3, 4)));
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.15 2001/09/21 21:58:30 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.16 2001/10/25 05:49:52 momjian Exp $
*
*
if ((TocIDRequired(AH, id, ropt) & 2) != 0)
die_horribly(AH, modulename,
"Dumping a specific TOC data block out of order is not supported"
- " without id on this input stream (fseek required)\n");
+ " without id on this input stream (fseek required)\n");
switch (blkType)
{
#ifdef HAVE_LIBZ
int res;
char *out = ctx->zlibOut;
-
#endif
#ifdef HAVE_LIBZ
if (inflateInit(zp) != Z_OK)
die_horribly(AH, modulename, "could not initialize compression library: %s\n", zp->msg);
}
-
#endif
blkLen = ReadInt(AH);
#else
AH->compression = 0;
-
#endif
/* Just be paranoid - maybe End is called after Start, with no Write */
|| (zp->avail_in != 0)
)
{
-
/*
* Extra paranoia: avoid zero-length chunks since a zero
* length chunk is the EOF marker. This should never happen
*/
if (zp->avail_out < zlibOutSize)
{
-
/*
* printf("Wrote %d byte deflated chunk\n", zlibOutSize -
* zp->avail_out);
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.28 2001/10/18 21:57:11 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.29 2001/10/25 05:49:52 momjian Exp $
*
* NOTES
*
{
int length;
char *destination;
- FILE *termin, *termout;
+ FILE *termin,
+ *termout;
+
#ifdef HAVE_TERMIOS_H
struct termios t_orig,
t;
prompt_state = true; /* disable SIGINT */
/*
- * Do not try to collapse these into one "w+" mode file.
- * Doesn't work on some platforms (eg, HPUX 10.20).
+ * Do not try to collapse these into one "w+" mode file. Doesn't work
+ * on some platforms (eg, HPUX 10.20).
*/
termin = fopen("/dev/tty", "r");
termout = fopen("/dev/tty", "w");
tcsetattr(fileno(termin), TCSAFLUSH, &t);
}
#endif
-
+
if (prompt)
{
fputs(gettext(prompt), termout);
static int
-_parse_version(ArchiveHandle *AH, const char* versionString)
+_parse_version(ArchiveHandle *AH, const char *versionString)
{
int cnt;
- int vmaj, vmin, vrev;
+ int vmaj,
+ vmin,
+ vrev;
cnt = sscanf(versionString, "%d.%d.%d", &vmaj, &vmin, &vrev);
if (cnt < 2)
- {
die_horribly(AH, modulename, "unable to parse version string \"%s\"\n", versionString);
- }
if (cnt == 2)
vrev = 0;
AH->public.remoteVersion = remoteversion;
- if (myversion != remoteversion
- && (remoteversion < AH->public.minRemoteVersion || remoteversion > AH->public.maxRemoteVersion) )
+ if (myversion != remoteversion
+ && (remoteversion < AH->public.minRemoteVersion || remoteversion > AH->public.maxRemoteVersion))
{
write_msg(NULL, "server version: %s; %s version: %s\n",
remoteversion_str, progname, PG_VERSION);
/*
* Reconnect to the server. If dbname is not NULL, use that database,
* else the one associated with the archive handle. If username is
- * not NULL, use that user name, else the one from the handle. If
+ * not NULL, use that user name, else the one from the handle. If
* both the database and the user and match the existing connection
* already, nothing will be done.
*
noPwd = (strcmp(PQerrorMessage(newConn),
"fe_sendauth: no password supplied\n") == 0);
badPwd = (strncmp(PQerrorMessage(newConn),
- "Password authentication failed for user", 39) == 0);
+ "Password authentication failed for user", 39) == 0);
if (noPwd || badPwd)
{
AH->requirePassword = false;
/*
- * Start the connection. Loop until we have a password if
- * requested by backend.
+ * Start the connection. Loop until we have a password if requested
+ * by backend.
*/
do
{
}
-static void notice_processor(void *arg, const char *message)
+static void
+notice_processor(void *arg, const char *message)
{
write_msg(NULL, "%s", message);
}
/* We may have finished Copy In, and have a non-empty buffer */
if (!AH->pgCopyIn)
{
-
/*
* The following is a mini state machine to assess then of of an
* SQL statement. It really only needs to parse good SQL, or at
appendPQExpBuffer(tblQry, "SELECT a.attname FROM pg_class c, pg_attribute a, pg_type t "
" WHERE a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid "
- " AND t.typname in ('oid', 'lo') AND c.relname = '%s';", tablename);
+ " AND t.typname in ('oid', 'lo') AND c.relname = '%s';", tablename);
res = PQexec(AH->blobConnection, tblQry->data);
if (!res)
uRes = PQexec(AH->blobConnection, tblQry->data);
if (!uRes)
die_horribly(AH, modulename,
- "could not update column \"%s\" of table \"%s\": %s",
- attr, tablename, PQerrorMessage(AH->blobConnection));
+ "could not update column \"%s\" of table \"%s\": %s",
+ attr, tablename, PQerrorMessage(AH->blobConnection));
if (PQresultStatus(uRes) != PGRES_COMMAND_OK)
die_horribly(AH, modulename,
- "error while updating column \"%s\" of table \"%s\": %s",
- attr, tablename, PQerrorMessage(AH->blobConnection));
+ "error while updating column \"%s\" of table \"%s\": %s",
+ attr, tablename, PQerrorMessage(AH->blobConnection));
PQclear(uRes);
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.13 2001/09/21 21:58:30 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.14 2001/10/25 05:49:52 momjian Exp $
*
*
die_horribly(AH, modulename, "could not close large object TOC file: %s\n", strerror(errno));
}
-
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.18 2001/09/21 21:58:30 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.19 2001/10/25 05:49:52 momjian Exp $
*
*
#else
typedef FILE ThingFile;
-
#endif
typedef struct
#ifdef __NOT_USED__
static char *tarGets(char *buf, int len, TAR_MEMBER *th);
-
#endif
static int tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...);
if (ctx->tarFH == NULL)
die_horribly(NULL, modulename,
- "could not open TOC file for output: %s\n", strerror(errno));
+ "could not open TOC file for output: %s\n", strerror(errno));
ctx->tarFHpos = 0;
#ifdef HAVE_LIBZ
char fmode[10];
-
#endif
if (mode == 'r')
#else
tm->nFH = ctx->tarFH;
-
#endif
}
#else
tm->nFH = tm->tmpFH;
-
#endif
tm->AH = AH;
static void
tarClose(ArchiveHandle *AH, TAR_MEMBER *th)
{
-
/*
* Close the GZ file since we dup'd. This will flush the buffers.
*/
return s;
}
-
#endif
/*
StartRestoreBlobs(AH);
- th = tarOpen(AH, NULL, 'r');/* Open next file */
+ th = tarOpen(AH, NULL, 'r'); /* Open next file */
while (th != NULL)
{
ctx->FH = th;
- oid = (Oid)strtoul(&th->targetFile[5], NULL, 10);
+ oid = (Oid) strtoul(&th->targetFile[5], NULL, 10);
if (strncmp(th->targetFile, "blob_", 5) == 0 && oid != 0)
{
if (AH->mode == archModeWrite)
{
-
/*
* Write the Header & TOC to the archive FIRST
*/
{
if (fputc(0, ctx->tarFH) == EOF)
die_horribly(AH, modulename,
- "could not write null block at end of tar archive\n");
+ "could not write null block at end of tar archive\n");
}
}
_tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
{
lclContext *ctx = (lclContext *) AH->formatData;
- FILE *tmp = th->tmpFH;/* Grab it for convenience */
+ FILE *tmp = th->tmpFH; /* Grab it for convenience */
char buf[32768];
int cnt;
int len = 0;
id = atoi(th->targetFile);
if ((TocIDRequired(AH, id, AH->ropt) & 2) != 0)
die_horribly(AH, modulename, "dumping data out of order is not supported in this archive format: "
- "%s is required, but comes before %s in the archive file.\n",
+ "%s is required, but comes before %s in the archive file.\n",
th->targetFile, filename);
/* Header doesn't match, so read to next header */
if (chk != sum)
die_horribly(AH, modulename,
"corrupt tar header found in %s "
- "(expected %d (%o), computed %d (%o)) file position %ld (%lx)\n",
+ "(expected %d (%o), computed %d (%o)) file position %ld (%lx)\n",
&name[0], sum, sum, chk, chk, ftell(ctx->tarFH), ftell(ctx->tarFH));
th->targetFile = strdup(name);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.234 2001/10/22 19:31:09 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.235 2001/10/25 05:49:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef enum _formatLiteralOptions
{
- CONV_ALL = 0,
- PASS_LFTAB = 3 /* NOTE: 1 and 2 are reserved in case we
+ CONV_ALL = 0,
+ PASS_LFTAB = 3 /* NOTE: 1 and 2 are reserved in case we
* want to make a mask. */
/* We could make this a bit mask for control chars, but I don't */
/* see any value in making it more complex...the current code */
} formatLiteralOptions;
static void dumpComment(Archive *fout, const char *target, const char *oid,
- const char *classname, int subid,
- const char *((*deps)[]));
+ const char *classname, int subid,
+ const char *((*deps)[]));
static void dumpSequence(Archive *fout, TableInfo tbinfo, const bool schemaOnly, const bool dataOnly);
static void dumpACL(Archive *fout, TableInfo tbinfo);
static void dumpTriggers(Archive *fout, const char *tablename,
#ifdef HAVE_GETOPT_LONG
puts(gettext(
" -a, --data-only dump only the data, not the schema\n"
- " -b, --blobs include large objects in dump\n"
- " -c, --clean clean (drop) schema prior to create\n"
- " -C, --create include commands to create database in dump\n"
- " -d, --inserts dump data as INSERT, rather than COPY, commands\n"
- " -D, --column-inserts dump data as INSERT commands with column names\n"
- " -f, --file=FILENAME output file name\n"
- " -F, --format {c|t|p} output file format (custom, tar, plain text)\n"
- " -h, --host=HOSTNAME database server host name\n"
- " -i, --ignore-version proceed even when server version mismatches\n"
- " pg_dump version\n"
- " -n, --no-quotes suppress most quotes around identifiers\n"
- " -N, --quotes enable most quotes around identifiers\n"
- " -o, --oids include oids in dump\n"
- " -O, --no-owner do not output \\connect commands in plain\n"
- " text format\n"
- " -p, --port=PORT database server port number\n"
- " -R, --no-reconnect disable ALL reconnections to the database in\n"
- " plain text format\n"
- " -s, --schema-only dump only the schema, no data\n"
- " -S, --superuser=NAME specify the superuser user name to use in\n"
- " plain text format\n"
- " -t, --table=TABLE dump this table only (* for all)\n"
+ " -b, --blobs include large objects in dump\n"
+ " -c, --clean clean (drop) schema prior to create\n"
+ " -C, --create include commands to create database in dump\n"
+ " -d, --inserts dump data as INSERT, rather than COPY, commands\n"
+ " -D, --column-inserts dump data as INSERT commands with column names\n"
+ " -f, --file=FILENAME output file name\n"
+ " -F, --format {c|t|p} output file format (custom, tar, plain text)\n"
+ " -h, --host=HOSTNAME database server host name\n"
+ " -i, --ignore-version proceed even when server version mismatches\n"
+ " pg_dump version\n"
+ " -n, --no-quotes suppress most quotes around identifiers\n"
+ " -N, --quotes enable most quotes around identifiers\n"
+ " -o, --oids include oids in dump\n"
+ " -O, --no-owner do not output \\connect commands in plain\n"
+ " text format\n"
+ " -p, --port=PORT database server port number\n"
+ " -R, --no-reconnect disable ALL reconnections to the database in\n"
+ " plain text format\n"
+ " -s, --schema-only dump only the schema, no data\n"
+ " -S, --superuser=NAME specify the superuser user name to use in\n"
+ " plain text format\n"
+ " -t, --table=TABLE dump this table only (* for all)\n"
" -U, --username=NAME connect as specified database user\n"
- " -v, --verbose verbose mode\n"
- " -W, --password force password prompt (should happen automatically)\n"
- " -x, --no-privileges do not dump privileges (grant/revoke)\n"
- " -X use-set-session-authorization, --use-set-session-authorization\n"
- " output SET SESSION AUTHORIZATION commands rather\n"
- " than \\connect commands\n"
- " -Z, --compress {0-9} compression level for compressed formats\n"
- ));
+ " -v, --verbose verbose mode\n"
+ " -W, --password force password prompt (should happen automatically)\n"
+ " -x, --no-privileges do not dump privileges (grant/revoke)\n"
+ " -X use-set-session-authorization, --use-set-session-authorization\n"
+ " output SET SESSION AUTHORIZATION commands rather\n"
+ " than \\connect commands\n"
+ " -Z, --compress {0-9} compression level for compressed formats\n"
+ ));
#else
puts(gettext(
" -a dump only the data, not the schema\n"
- " -b include large objects in dump\n"
- " -c clean (drop) schema prior to create\n"
- " -C include commands to create database in dump\n"
- " -d dump data as INSERT, rather than COPY, commands\n"
- " -D dump data as INSERT commands with column names\n"
- " -f FILENAME output file name\n"
- " -F {c|t|p} output file format (custom, tar, plain text)\n"
- " -h HOSTNAME database server host name\n"
- " -i proceed even when server version mismatches\n"
- " pg_dump version\n"
- " -n suppress most quotes around identifiers\n"
- " -N enable most quotes around identifiers\n"
- " -o include oids in dump\n"
- " -O do not output \\connect commands in plain\n"
- " text format\n"
- " -p PORT database server port number\n"
- " -R disable ALL reconnections to the database in\n"
- " plain text format\n"
- " -s dump only the schema, no data\n"
- " -S NAME specify the superuser user name to use in\n"
- " plain text format\n"
- " -t TABLE dump this table only (* for all)\n"
+ " -b include large objects in dump\n"
+ " -c clean (drop) schema prior to create\n"
+ " -C include commands to create database in dump\n"
+ " -d dump data as INSERT, rather than COPY, commands\n"
+ " -D dump data as INSERT commands with column names\n"
+ " -f FILENAME output file name\n"
+ " -F {c|t|p} output file format (custom, tar, plain text)\n"
+ " -h HOSTNAME database server host name\n"
+ " -i proceed even when server version mismatches\n"
+ " pg_dump version\n"
+ " -n suppress most quotes around identifiers\n"
+ " -N enable most quotes around identifiers\n"
+ " -o include oids in dump\n"
+ " -O do not output \\connect commands in plain\n"
+ " text format\n"
+ " -p PORT database server port number\n"
+ " -R disable ALL reconnections to the database in\n"
+ " plain text format\n"
+ " -s dump only the schema, no data\n"
+ " -S NAME specify the superuser user name to use in\n"
+ " plain text format\n"
+ " -t TABLE dump this table only (* for all)\n"
" -U NAME connect as specified database user\n"
- " -v verbose mode\n"
- " -W force password prompt (should happen automatically)\n"
- " -x do not dump privileges (grant/revoke)\n"
- " -X use-set-session-authorization\n"
- " output SET SESSION AUTHORIZATION commands rather\n"
- " than \\connect commands\n"
- " -Z {0-9} compression level for compressed formats\n"
- ));
+ " -v verbose mode\n"
+ " -W force password prompt (should happen automatically)\n"
+ " -x do not dump privileges (grant/revoke)\n"
+ " -X use-set-session-authorization\n"
+ " output SET SESSION AUTHORIZATION commands rather\n"
+ " than \\connect commands\n"
+ " -Z {0-9} compression level for compressed formats\n"
+ ));
#endif
puts(gettext("If no database name is not supplied, then the PGDATABASE environment\n"
"variable value is used.\n\n"
if (oids && hasoids)
{
-
/*
* archprintf(fout, "COPY %s WITH OIDS FROM stdin;\n",
* fmtId(classname, force_quotes));
}
else
{
-
/*
* archprintf(fout, "COPY %s FROM stdin;\n", fmtId(classname,
* force_quotes));
{
write_msg(NULL, "SQL command to dump the contents of table \"%s\" executed abnormally.\n",
classname);
- write_msg(NULL, "The server returned status %d when %d was expected.\n",
+ write_msg(NULL, "The server returned status %d when %d was expected.\n",
PQresultStatus(res), PGRES_COPY_OUT);
write_msg(NULL, "The command was: %s\n", query);
exit_nicely();
int field;
if (fout->remoteVersion >= 70100)
- {
appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR SELECT * FROM ONLY %s", fmtId(classname, force_quotes));
- } else {
+ else
appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR SELECT * FROM %s", fmtId(classname, force_quotes));
- }
res = PQexec(g_conn, q->data);
if (!res ||
write_msg(NULL, "The command was: %s\n", q->data);
exit_nicely();
}
-
- do {
+
+ do
+ {
PQclear(res);
res = PQexec(g_conn, "FETCH 100 FROM _pg_dump_cursor");
{
case INT2OID:
case INT4OID:
- case OIDOID: /* int types */
+ case OIDOID: /* int types */
case FLOAT4OID:
- case FLOAT8OID:/* float types */
+ case FLOAT8OID: /* float types */
/* These types are printed without quotes */
archprintf(fout, "%s",
PQgetvalue(res, tuple, field));
PQgetvalue(res, tuple, field));
break;
default:
-
+
/*
* All other types are printed as string literals,
- * with appropriate escaping of special characters.
+ * with appropriate escaping of special
+ * characters.
*/
resetPQExpBuffer(q);
formatStringLiteral(q, PQgetvalue(res, tuple, field), CONV_ALL);
archprintf(fout, ");\n");
}
- } while( PQntuples(res) > 0 );
+ } while (PQntuples(res) > 0);
PQclear(res);
res = PQexec(g_conn, "CLOSE _pg_dump_cursor");
|| (ch != '\n' && ch != '\t')
))
{
-
/*
* generate octal escape for control chars other than
* whitespace
static int
-parse_version(const char* versionString)
+parse_version(const char *versionString)
{
int cnt;
- int vmaj, vmin, vrev;
+ int vmaj,
+ vmin,
+ vrev;
cnt = sscanf(versionString, "%d.%d.%d", &vmaj, &vmin, &vrev);
{"help", no_argument, NULL, '?'},
{"version", no_argument, NULL, 'V'},
- /* the following options don't have an equivalent short option
- letter, but are available as '-X long-name' */
+ /*
+ * the following options don't have an equivalent short option
+ * letter, but are available as '-X long-name'
+ */
{"use-set-session-authorization", no_argument, &use_setsessauth, 1}
};
int optindex;
-
#endif
#ifdef ENABLE_NLS
break;
/*
- * Option letters were getting scarce, so I invented
- * this new scheme: '-X feature' turns on some
- * feature. Compare to the -f option in GCC. You
- * should also add an equivalent GNU-style option
- * --feature. Features that require arguments should
- * use '-X feature=foo'.
+ * Option letters were getting scarce, so I invented this
+ * new scheme: '-X feature' turns on some feature.
+ * Compare to the -f option in GCC. You should also add
+ * an equivalent GNU-style option --feature. Features
+ * that require arguments should use '-X feature=foo'.
*/
case 'X':
- if (strcmp(optarg, "use-set-session-authorization")==0)
+ if (strcmp(optarg, "use-set-session-authorization") == 0)
use_setsessauth = 1;
else
{
case '-':
fprintf(stderr,
gettext("%s was compiled without support for long options.\n"
- "Use --help for help on invocation options.\n"),
+ "Use --help for help on invocation options.\n"),
progname);
exit(1);
break;
if (optind < (argc - 1))
{
fprintf(stderr,
- gettext("%s: too many command line options (first is '%s')\n"
- "Try '%s --help' for more information.\n"),
+ gettext("%s: too many command line options (first is '%s')\n"
+ "Try '%s --help' for more information.\n"),
progname, argv[optind + 1], progname);
exit(1);
}
* Open the database using the Archiver, so it knows about it. Errors
* mean death.
*/
- g_fout->minRemoteVersion = 70000; /* we can handle back to 7.0 */
+ g_fout->minRemoteVersion = 70000; /* we can handle back to 7.0 */
g_fout->maxRemoteVersion = parse_version(PG_VERSION);
g_conn = ConnectDatabase(g_fout, dbname, pghost, pgport, username, force_password, ignore_version);
MoveToEnd(g_fout, "TRIGGER");
MoveToEnd(g_fout, "RULE");
MoveToEnd(g_fout, "SEQUENCE SET");
+
/*
* Moving all comments to end is annoying, but must do it for comments
* on stuff we just moved, and we don't seem to have quite enough
else
ropt->compression = compressLevel;
- ropt->suppressDumpWarnings = true; /* We've already shown them */
+ ropt->suppressDumpWarnings = true; /* We've already shown
+ * them */
RestoreArchive(g_fout, ropt);
}
/* Cursor to get all BLOB tables */
if (AH->remoteVersion >= 70100)
- {
appendPQExpBuffer(oidQry, "Declare blobOid Cursor for SELECT DISTINCT loid FROM pg_largeobject");
- } else {
+ else
appendPQExpBuffer(oidQry, "Declare blobOid Cursor for SELECT oid from pg_class where relkind = 'l'");
- }
res = PQexec(g_conn, oidQry->data);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
* numTypes is set to the number of types read in
*
*/
-TypeInfo *
+TypeInfo *
getTypes(int *numTypes)
{
PGresult *res;
if (g_fout->remoteVersion < 70100)
{
appendPQExpBuffer(query, "SELECT pg_type.oid, typowner, typname, typlen, typprtlen, "
- "typinput, typoutput, typreceive, typsend, typelem, typdelim, "
- "typdefault, typrelid, typalign, 'p'::char as typstorage, typbyval, typisdefined, "
- "(select usename from pg_user where typowner = usesysid) as usename, "
- "typname as typedefn "
- "from pg_type");
- } else {
+ "typinput, typoutput, typreceive, typsend, typelem, typdelim, "
+ "typdefault, typrelid, typalign, 'p'::char as typstorage, typbyval, typisdefined, "
+ "(select usename from pg_user where typowner = usesysid) as usename, "
+ "typname as typedefn "
+ "from pg_type");
+ }
+ else
+ {
appendPQExpBuffer(query, "SELECT pg_type.oid, typowner, typname, typlen, typprtlen, "
- "typinput, typoutput, typreceive, typsend, typelem, typdelim, "
- "typdefault, typrelid, typalign, typstorage, typbyval, typisdefined, "
- "(select usename from pg_user where typowner = usesysid) as usename, "
- "format_type(pg_type.oid, NULL) as typedefn "
- "from pg_type");
+ "typinput, typoutput, typreceive, typsend, typelem, typdelim, "
+ "typdefault, typrelid, typalign, typstorage, typbyval, typisdefined, "
+ "(select usename from pg_user where typowner = usesysid) as usename, "
+ "format_type(pg_type.oid, NULL) as typedefn "
+ "from pg_type");
}
res = PQexec(g_conn, query->data);
*
* numOprs is set to the number of operators read in
*/
-OprInfo *
+OprInfo *
getOperators(int *numOprs)
{
PGresult *res;
*
* numAggs is set to the number of aggregates read in
*/
-AggInfo *
+AggInfo *
getAggregates(int *numAggs)
{
PGresult *res;
if (g_fout->remoteVersion < 70100)
{
appendPQExpBuffer(query, "SELECT pg_aggregate.oid, aggname, aggtransfn1 as aggtransfn, "
- "aggfinalfn, aggtranstype1 as aggtranstype, aggbasetype, "
- "agginitval1 as agginitval, "
- "(aggtransfn2 = 0 and aggtranstype2 = 0 and agginitval2 is null) as convertok, "
- "(select usename from pg_user where aggowner = usesysid) as usename "
- "from pg_aggregate");
- } else {
+ "aggfinalfn, aggtranstype1 as aggtranstype, aggbasetype, "
+ "agginitval1 as agginitval, "
+ "(aggtransfn2 = 0 and aggtranstype2 = 0 and agginitval2 is null) as convertok, "
+ "(select usename from pg_user where aggowner = usesysid) as usename "
+ "from pg_aggregate");
+ }
+ else
+ {
appendPQExpBuffer(query, "SELECT pg_aggregate.oid, aggname, aggtransfn, "
- "aggfinalfn, aggtranstype, aggbasetype, "
- "agginitval, "
- "'t'::boolean as convertok, "
- "(select usename from pg_user where aggowner = usesysid) as usename "
- "from pg_aggregate");
+ "aggfinalfn, aggtranstype, aggbasetype, "
+ "agginitval, "
+ "'t'::boolean as convertok, "
+ "(select usename from pg_user where aggowner = usesysid) as usename "
+ "from pg_aggregate");
}
res = PQexec(g_conn, query->data);
*
*
*/
-FuncInfo *
+FuncInfo *
getFuncs(int *numFuncs)
{
PGresult *res;
{
appendPQExpBuffer(query,
"SELECT pg_proc.oid, proname, prolang, pronargs, prorettype, "
- "proretset, proargtypes, prosrc, probin, "
- "(select usename from pg_user where proowner = usesysid) as usename, "
- "proiscachable, 'f'::boolean as proisstrict "
- "from pg_proc "
- "where pg_proc.oid > '%u'::oid",
- g_last_builtin_oid);
- } else {
+ "proretset, proargtypes, prosrc, probin, "
+ "(select usename from pg_user where proowner = usesysid) as usename, "
+ "proiscachable, 'f'::boolean as proisstrict "
+ "from pg_proc "
+ "where pg_proc.oid > '%u'::oid",
+ g_last_builtin_oid);
+ }
+ else
+ {
appendPQExpBuffer(query,
"SELECT pg_proc.oid, proname, prolang, pronargs, prorettype, "
- "proretset, proargtypes, prosrc, probin, "
- "(select usename from pg_user where proowner = usesysid) as usename, "
- "proiscachable, proisstrict "
- "from pg_proc "
- "where pg_proc.oid > '%u'::oid",
- g_last_builtin_oid);
+ "proretset, proargtypes, prosrc, probin, "
+ "(select usename from pg_user where proowner = usesysid) as usename, "
+ "proiscachable, proisstrict "
+ "from pg_proc "
+ "where pg_proc.oid > '%u'::oid",
+ g_last_builtin_oid);
}
res = PQexec(g_conn, query->data);
*
* numTables is set to the number of tables read in
*/
-TableInfo *
+TableInfo *
getTables(int *numTables, FuncInfo *finfo, int numFuncs)
{
PGresult *res;
if (g_fout->remoteVersion >= 70200)
{
appendPQExpBuffer(query,
- "SELECT pg_class.oid, relname, relacl, relkind, "
+ "SELECT pg_class.oid, relname, relacl, relkind, "
"(select usename from pg_user where relowner = usesysid) as usename, "
- "relchecks, reltriggers, relhasindex, relhasoids "
+ "relchecks, reltriggers, relhasindex, relhasoids "
"from pg_class "
"where relname !~ '^pg_' "
"and relkind in ('%c', '%c', '%c') "
"order by oid",
- RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
+ RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
}
else if (g_fout->remoteVersion >= 70100)
{
/* all tables have oids in 7.1 */
appendPQExpBuffer(query,
- "SELECT pg_class.oid, relname, relacl, relkind, "
+ "SELECT pg_class.oid, relname, relacl, relkind, "
"(select usename from pg_user where relowner = usesysid) as usename, "
- "relchecks, reltriggers, relhasindex, 't'::bool as relhasoids "
+ "relchecks, reltriggers, relhasindex, 't'::bool as relhasoids "
"from pg_class "
"where relname !~ '^pg_' "
"and relkind in ('%c', '%c', '%c') "
"order by oid",
- RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
- } else {
+ RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
+ }
+ else
+ {
/*
* Before 7.1, view relkind was not set to 'v', so we must check
* if we have a view by looking for a rule in pg_rewrite.
appendPQExpBuffer(query,
"SELECT c.oid, relname, relacl, "
"CASE WHEN relhasrules and relkind = 'r' "
- " and EXISTS(SELECT rulename FROM pg_rewrite r WHERE "
- " r.ev_class = c.oid AND r.ev_type = '1') "
+ " and EXISTS(SELECT rulename FROM pg_rewrite r WHERE "
+ " r.ev_class = c.oid AND r.ev_type = '1') "
"THEN '%c'::\"char\" "
"ELSE relkind END AS relkind,"
"(select usename from pg_user where relowner = usesysid) as usename, "
- "relchecks, reltriggers, relhasindex, 't'::bool as relhasoids "
+ "relchecks, reltriggers, relhasindex, 't'::bool as relhasoids "
"from pg_class c "
"where relname !~ '^pg_' "
"and relkind in ('%c', '%c', '%c') "
"order by oid",
RELKIND_VIEW,
- RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
+ RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
}
res = PQexec(g_conn, query->data);
resetPQExpBuffer(query);
appendPQExpBuffer(query, "SELECT definition as viewdef, ");
- /* XXX 7.2 - replace with att from pg_views or some other generic source */
+
+ /*
+ * XXX 7.2 - replace with att from pg_views or some other
+ * generic source
+ */
appendPQExpBuffer(query, "(select oid from pg_rewrite where "
- " rulename=('_RET' || viewname)::name) as view_oid"
- " from pg_views where viewname = ");
+ " rulename=('_RET' || viewname)::name) as view_oid"
+ " from pg_views where viewname = ");
formatStringLiteral(query, tblinfo[i].relname, CONV_ALL);
appendPQExpBuffer(query, ";");
tblinfo[i].relname);
else
write_msg(NULL, "query to obtain definition of view \"%s\" returned more than one definition\n",
- tblinfo[i].relname);
+ tblinfo[i].relname);
exit_nicely();
}
*
* Exclude inherited CHECKs from CHECK constraints total. If a
* constraint matches by name and condition with a constraint
- * belonging to a parent class (OR conditions match and both
- * names start with '$', we assume it was inherited.
+ * belonging to a parent class (OR conditions match and both names
+ * start with '$', we assume it was inherited.
*/
if (tblinfo[i].ncheck > 0)
{
appendPQExpBuffer(query, "SELECT rcname, rcsrc from pg_relcheck "
" where rcrelid = '%s'::oid "
" and not exists "
- " (select * from pg_relcheck as c, pg_inherits as i "
- " where i.inhrelid = pg_relcheck.rcrelid "
+ " (select * from pg_relcheck as c, pg_inherits as i "
+ " where i.inhrelid = pg_relcheck.rcrelid "
" and (c.rcname = pg_relcheck.rcname "
" or ( c.rcname[0] = '$' "
- " and pg_relcheck.rcname[0] = '$')"
+ " and pg_relcheck.rcname[0] = '$')"
" )"
" and c.rcsrc = pg_relcheck.rcsrc "
" and c.rcrelid = i.inhparent) "
exit_nicely();
}
- /* Set ncheck to the number of *non-inherited* CHECK constraints */
+ /*
+ * Set ncheck to the number of *non-inherited* CHECK
+ * constraints
+ */
tblinfo[i].ncheck = ntups2;
i_rcname = PQfnumber(res2, "rcname");
if (PQntuples(res2) > 1)
{
write_msg(NULL, "query to obtain primary key of table \"%s\" produced more than one result\n",
- tblinfo[i].relname);
+ tblinfo[i].relname);
exit_nicely();
}
resetPQExpBuffer(query);
appendPQExpBuffer(query,
- "SELECT tgname, tgfoid, tgtype, tgnargs, tgargs, "
- "tgisconstraint, tgconstrname, tgdeferrable, "
- "tgconstrrelid, tginitdeferred, oid, "
- "(select relname from pg_class where oid = tgconstrrelid) "
- " as tgconstrrelname "
+ "SELECT tgname, tgfoid, tgtype, tgnargs, tgargs, "
+ "tgisconstraint, tgconstrname, tgdeferrable, "
+ "tgconstrrelid, tginitdeferred, oid, "
+ "(select relname from pg_class where oid = tgconstrrelid) "
+ " as tgconstrrelname "
"from pg_trigger "
"where tgrelid = '%s'::oid ",
tblinfo[i].oid);
{
tgconstrrelid = PQgetvalue(res2, i2, i_tgconstrrelid);
- if (strcmp(tgconstrrelid, "0") != 0) {
+ if (strcmp(tgconstrrelid, "0") != 0)
+ {
if (PQgetisnull(res2, i2, i_tgconstrrelname))
{
write_msg(NULL, "query produced NULL referenced table name for foreign key trigger \"%s\" on table \"%s\" (oid of table: %s)\n",
- tgname, tblinfo[i].relname, tgconstrrelid);
+ tgname, tblinfo[i].relname, tgconstrrelid);
exit_nicely();
}
appendPQExpBuffer(query, " FROM %s",
- fmtId(PQgetvalue(res2, i2, i_tgconstrrelname), force_quotes));
+ fmtId(PQgetvalue(res2, i2, i_tgconstrrelname), force_quotes));
}
if (!tgdeferrable)
appendPQExpBuffer(query, " NOT");
resetPQExpBuffer(query);
appendPQExpBuffer(query, "TRIGGER %s ",
- fmtId(tgname, force_quotes));
+ fmtId(tgname, force_quotes));
appendPQExpBuffer(query, "ON %s",
fmtId(tblinfo[i].relname, force_quotes));
tblinfo[i].triggers[i2].tgcomment = strdup(query->data);
*
* numInherits is set to the number of tables read in
*/
-InhInfo *
+InhInfo *
getInherits(int *numInherits)
{
PGresult *res;
{
/* Fake the LOJ below */
appendPQExpBuffer(q,
- " SELECT a.attnum, a.attname, t.typname, a.atttypmod, "
- " a.attnotnull, a.atthasdef, NULL as atttypedefn "
- " from pg_attribute a, pg_type t "
- " where a.attrelid = '%s'::oid "
- " and a.attnum > 0 "
- " and a.atttypid = t.oid "
- " UNION ALL SELECT a.attnum, a.attname, NULL as typname, a.atttypmod, "
- " a.attnotnull, a.atthasdef, NULL as atttypedefn "
- " from pg_attribute a "
- " where a.attrelid = '%s'::oid "
- " and a.attnum > 0 "
- " and Not Exists(Select * From pg_type t where a.atttypid = t.oid)"
- " order by attnum",
- tblinfo[i].oid, tblinfo[i].oid);
-
- } else {
+ " SELECT a.attnum, a.attname, t.typname, a.atttypmod, "
+ " a.attnotnull, a.atthasdef, NULL as atttypedefn "
+ " from pg_attribute a, pg_type t "
+ " where a.attrelid = '%s'::oid "
+ " and a.attnum > 0 "
+ " and a.atttypid = t.oid "
+ " UNION ALL SELECT a.attnum, a.attname, NULL as typname, a.atttypmod, "
+ " a.attnotnull, a.atthasdef, NULL as atttypedefn "
+ " from pg_attribute a "
+ " where a.attrelid = '%s'::oid "
+ " and a.attnum > 0 "
+ " and Not Exists(Select * From pg_type t where a.atttypid = t.oid)"
+ " order by attnum",
+ tblinfo[i].oid, tblinfo[i].oid);
+
+ }
+ else
+ {
appendPQExpBuffer(q, "SELECT a.attnum, a.attname, t.typname, a.atttypmod, "
- "a.attnotnull, a.atthasdef, format_type(a.atttypid, a.atttypmod) as atttypedefn "
- "from pg_attribute a LEFT OUTER JOIN pg_type t ON a.atttypid = t.oid "
- "where a.attrelid = '%s'::oid "
- "and a.attnum > 0 order by attnum",
- tblinfo[i].oid);
+ "a.attnotnull, a.atthasdef, format_type(a.atttypid, a.atttypmod) as atttypedefn "
+ "from pg_attribute a LEFT OUTER JOIN pg_type t ON a.atttypid = t.oid "
+ "where a.attrelid = '%s'::oid "
+ "and a.attnum > 0 order by attnum",
+ tblinfo[i].oid);
}
res = PQexec(g_conn, q->data);
if (PQgetisnull(res, j, i_typname))
{
write_msg(NULL, "query produced NULL name for data type of column %d of table %s\n",
- j+1, tblinfo[i].relname);
+ j + 1, tblinfo[i].relname);
exit_nicely();
}
*
*
*/
-IndInfo *
+IndInfo *
getIndexes(int *numIndexes)
{
int i;
appendPQExpBuffer(query,
"SELECT i.indexrelid as indexreloid, "
"i.indrelid as indreloid, "
- "t1.relname as indexrelname, t2.relname as indrelname, "
+ "t1.relname as indexrelname, t2.relname as indrelname, "
"pg_get_indexdef(i.indexrelid) as indexdef, "
"i.indisprimary, i.indkey "
"from pg_index i, pg_class t1, pg_class t2 "
- "WHERE t1.oid = i.indexrelid and t2.oid = i.indrelid "
+ "WHERE t1.oid = i.indexrelid and t2.oid = i.indrelid "
"and i.indexrelid > '%u'::oid "
"and t2.relname !~ '^pg_' ",
g_last_builtin_oid);
{
appendPQExpBuffer(query, "SELECT description FROM pg_description "
"WHERE objoid = '%s'::oid and classoid = "
- "(SELECT oid FROM pg_class where relname = '%s') "
+ "(SELECT oid FROM pg_class where relname = '%s') "
"and objsubid = %d",
oid, classname, subid);
}
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{
write_msg(NULL, "query to get comment on oid %s failed: %s",
- oid, PQerrorMessage(g_conn));
+ oid, PQerrorMessage(g_conn));
exit_nicely();
}
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{
write_msg(NULL, "query to get database oid failed: %s",
- PQerrorMessage(g_conn));
+ PQerrorMessage(g_conn));
exit_nicely();
}
(strcmp(tinfo[i].typinput, "array_in") == 0))
continue;
- deps = malloc(sizeof(char*) * 10);
+ deps = malloc(sizeof(char *) * 10);
depIdx = 0;
/*
else
appendPQExpBuffer(q, ");\n");
- (*deps)[depIdx++] = NULL; /* End of List */
+ (*deps)[depIdx++] = NULL; /* End of List */
ArchiveEntry(fout, tinfo[i].oid, tinfo[i].typname, "TYPE", deps,
q->data, delq->data, "", tinfo[i].usename, NULL, NULL);
PQresultStatus(res) != PGRES_TUPLES_OK)
{
write_msg(NULL, "query to obtain list of procedural languages failed: %s",
- PQerrorMessage(g_conn));
+ PQerrorMessage(g_conn));
exit_nicely();
}
ntups = PQntuples(res);
if (fidx >= numFuncs)
{
write_msg(NULL, "handler procedure for procedural language %s not found\n",
- PQgetvalue(res, i, i_lanname));
+ PQgetvalue(res, i, i_lanname));
exit_nicely();
}
finfo[i].proname);
write_msg(NULL, "reason: data type name of argument %d (oid %s) not found\n",
- j, finfo[i].argtypes[j]);
+ j, finfo[i].argtypes[j]);
goto done;
}
resetPQExpBuffer(delq);
appendPQExpBuffer(delq, "DROP OPERATOR %s (%s",
oprinfo[i].oprname,
- findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft,
- zeroAsNone));
+ findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft,
+ zeroAsNone));
appendPQExpBuffer(delq, ", %s);\n",
- findTypeByOid(tinfo, numTypes, oprinfo[i].oprright,
- zeroAsNone));
+ findTypeByOid(tinfo, numTypes, oprinfo[i].oprright,
+ zeroAsNone));
resetPQExpBuffer(q);
appendPQExpBuffer(q,
resetPQExpBuffer(details);
/* skip all the builtin oids */
- if ( oidle( atooid(agginfo[i].oid), g_last_builtin_oid) )
+ if (oidle(atooid(agginfo[i].oid), g_last_builtin_oid))
continue;
resetPQExpBuffer(aggSig);
resetPQExpBuffer(q);
appendPQExpBuffer(q, "-- WARNING: aggregate function %s could not be dumped correctly for this database version; ignored\n",
- aggSig->data);
+ aggSig->data);
ArchiveEntry(fout, agginfo[i].oid, aggSig->data, "WARNING", NULL,
- q->data, "" /* Del */, "", agginfo[i].usename, NULL, NULL);
+ q->data, "" /* Del */ , "", agginfo[i].usename, NULL, NULL);
continue;
}
appendPQExpBuffer(q, "-- WARNING: aggregate function \"%s\" (oid %s) not dumped\n", agginfo[i].aggname, agginfo[i].oid);
appendPQExpBuffer(q, "-- reason: aggbasetype (oid %s) not found\n", agginfo[i].aggbasetype);
ArchiveEntry(fout, agginfo[i].oid, aggSig->data, "WARNING", NULL,
- q->data, "" /* Del */, "", agginfo[i].usename, NULL, NULL);
+ q->data, "" /* Del */ , "", agginfo[i].usename, NULL, NULL);
continue;
}
appendPQExpBuffer(details, "BASETYPE = %s, ", name);
appendPQExpBuffer(q, "-- WARNING: aggregate function \"%s\" (oid %s) not dumped\n", agginfo[i].aggname, agginfo[i].oid);
appendPQExpBuffer(q, "-- reason: aggtranstype (oid %s) not found\n", agginfo[i].aggtranstype);
ArchiveEntry(fout, agginfo[i].oid, aggSig->data, "WARNING", NULL,
- q->data, "" /* Del */, "", agginfo[i].usename, NULL, NULL);
+ q->data, "" /* Del */ , "", agginfo[i].usename, NULL, NULL);
continue;
}
appendPQExpBuffer(details,
/* Scan comma-separated ACL items */
for (tok = strtok(aclbuf, ","); tok != NULL; tok = strtok(NULL, ","))
{
-
/*
* Token may start with '{' and/or '"'. Actually only the start
* of the string should have '{', but we don't verify that.
static void
_dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q)
{
- int32 tmp_typmod;
- int precision;
- int scale;
+ int32 tmp_typmod;
+ int precision;
+ int scale;
/* Show lengths on bpchar and varchar */
if (!strcmp(tblinfo[i].typnames[j], "bpchar"))
appendPQExpBuffer(q, "character");
if (len > 1)
appendPQExpBuffer(q, "(%d)",
- tblinfo[i].atttypmod[j] - VARHDRSZ);
+ tblinfo[i].atttypmod[j] - VARHDRSZ);
}
else if (!strcmp(tblinfo[i].typnames[j], "varchar"))
{
if (tblinfo[i].atttypmod[j] != -1)
{
appendPQExpBuffer(q, "(%d)",
- tblinfo[i].atttypmod[j] - VARHDRSZ);
+ tblinfo[i].atttypmod[j] - VARHDRSZ);
}
}
else if (!strcmp(tblinfo[i].typnames[j], "numeric"))
}
/*
- * char is an internal single-byte data type; Let's
- * make sure we force it through with quotes. - thomas
- * 1998-12-13
+ * char is an internal single-byte data type; Let's make sure we force
+ * it through with quotes. - thomas 1998-12-13
*/
else if (!strcmp(tblinfo[i].typnames[j], "char"))
{
appendPQExpBuffer(q, "%s",
- fmtId(tblinfo[i].typnames[j], true));
+ fmtId(tblinfo[i].typnames[j], true));
}
else
{
appendPQExpBuffer(q, "%s",
- fmtId(tblinfo[i].typnames[j], false));
+ fmtId(tblinfo[i].typnames[j], false));
}
}
objoid = tblinfo[i].viewoid;
appendPQExpBuffer(delq, "DROP VIEW %s;\n", fmtId(tblinfo[i].relname, force_quotes));
appendPQExpBuffer(q, "CREATE VIEW %s as %s\n", fmtId(tblinfo[i].relname, force_quotes), tblinfo[i].viewdef);
- commentDeps = malloc(sizeof(char*) * 2);
+ commentDeps = malloc(sizeof(char *) * 2);
(*commentDeps)[0] = strdup(objoid);
- (*commentDeps)[1] = NULL; /* end of list */
+ (*commentDeps)[1] = NULL; /* end of list */
}
else
{
appendPQExpBuffer(q, "%s ", fmtId(tblinfo[i].attnames[j], force_quotes));
if (g_fout->remoteVersion >= 70100)
- {
appendPQExpBuffer(q, "%s", tblinfo[i].atttypedefns[j]);
- } else {
+ else
_dumpTableAttr70(fout, tblinfo, i, j, q);
- }
/* Default value */
if (tblinfo[i].adef_expr[j] != NULL && tblinfo[i].inhAttrDef[j] == 0)
if (k >= numIndexes)
{
write_msg(NULL, "dumpTables(): failed sanity check, could not find index (%s) for primary key constraint\n",
- tblinfo[i].pkIndexOid);
+ tblinfo[i].pkIndexOid);
exit_nicely();
}
appendPQExpBuffer(q, ".");
appendPQExpBuffer(q, "%s", fmtId(tblinfo[i].attnames[j], force_quotes));
dumpComment(fout, q->data, tblinfo[i].oid,
- "pg_class", j+1, commentDeps);
+ "pg_class", j + 1, commentDeps);
}
/* Dump Table Comments */
getAttrName(int attrnum, TableInfo *tblInfo)
{
if (attrnum > 0 && attrnum <= tblInfo->numatts)
- return tblInfo->attnames[attrnum-1];
+ return tblInfo->attnames[attrnum - 1];
switch (attrnum)
{
case SelfItemPointerAttributeNumber:
return "tableoid";
}
write_msg(NULL, "getAttrName(): invalid column number %d for table %s\n",
- attrnum, tblInfo->relname);
+ attrnum, tblInfo->relname);
exit_nicely();
return NULL; /* keep compiler quiet */
}
if (tableInd < 0)
{
write_msg(NULL, "dumpIndexes(): failed sanity check, table %s was not found\n",
- indinfo[i].indrelname);
+ indinfo[i].indrelname);
exit_nicely();
}
if (strcmp(indinfo[i].indisprimary, "t") == 0)
{
#if 0
- /* PK: Enable this code when ALTER TABLE supports PK constraints. */
+
+ /*
+ * PK: Enable this code when ALTER TABLE supports PK
+ * constraints.
+ */
PQExpBuffer consDef = getPKconstraint(&tblinfo[tableInd], &indinfo[i]);
resetPQExpBuffer(q);
appendPQExpBuffer(q, "Alter Table %s Add %s;",
- fmtId(tblinfo[tableInd].relname, force_quotes),
+ fmtId(tblinfo[tableInd].relname, force_quotes),
consDef->data);
ArchiveEntry(fout, indinfo[i].oid, tblinfo[tableInd].primary_key_name,
appendPQExpBuffer(delq, "DROP INDEX %s;\n", id1->data);
/*
- * We make the index belong to the owner of its table, which
- * is not necessarily right but should answer 99% of the time.
- * Would have to add owner name to IndInfo to do it right.
+ * We make the index belong to the owner of its table, which is
+ * not necessarily right but should answer 99% of the time. Would
+ * have to add owner name to IndInfo to do it right.
*/
ArchiveEntry(fout, indinfo[i].indexreloid, id1->data,
"INDEX", NULL, q->data, delq->data,
if (m > 0)
{
-
/*
* Print out the tuples but only print tuples with at least 1
* field.
free(outVals);
}
}
-
#endif
/*
if (PQntuples(res) != 1)
{
write_msg(NULL, "query to get data of sequence \"%s\" returned %d rows (expected 1)\n",
- tbinfo.relname, PQntuples(res));
+ tbinfo.relname, PQntuples(res));
exit_nicely();
}
if (strcmp(PQgetvalue(res, 0, 0), tbinfo.relname) != 0)
{
write_msg(NULL, "query to get data of sequence \"%s\" returned name \"%s\"\n",
- tbinfo.relname, PQgetvalue(res, 0, 0));
+ tbinfo.relname, PQgetvalue(res, 0, 0));
exit_nicely();
}
* basic CREATE SEQUENCE statement (use last_val for start if called
* is false, else use min_val for start_val).
*
- * Add a 'SETVAL(seq, last_val, iscalled)' at restore-time iff
- * we load data
+ * Add a 'SETVAL(seq, last_val, iscalled)' at restore-time iff we load
+ * data
*/
if (!dataOnly)
PQresultStatus(res) != PGRES_TUPLES_OK)
{
write_msg(NULL, "query to get rules associated with table \"%s\" failed: %s",
- tblinfo[t].relname, PQerrorMessage(g_conn));
+ tblinfo[t].relname, PQerrorMessage(g_conn));
exit_nicely();
}
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_dump.h,v 1.73 2001/10/22 19:31:09 tgl Exp $
+ * $Id: pg_dump.h,v 1.74 2001/10/25 05:49:53 momjian Exp $
*
*
char *relacl;
char *viewdef;
char *viewoid; /* OID of view - should be >= oid of table
- * important because views may be constructed
- * manually from rules, and rule may ref things
- * created after the base table was created.
- */
+ * important because views may be
+ * constructed manually from rules, and
+ * rule may ref things created after the
+ * base table was created. */
bool sequence;
bool hasoids; /* does it have OIDs? */
int numatts; /* number of attributes */
int *inhAttrs; /* an array of flags, one for each
* attribute if the value is 1, then this
* attribute is an inherited attribute */
- int *inhAttrDef; /* Flags indicating if attrdef is inherited */
- int *inhNotNull; /* Flags indicating if NOT NULL in inherited */
+ int *inhAttrDef; /* Flags indicating if attrdef is
+ * inherited */
+ int *inhNotNull; /* Flags indicating if NOT NULL in
+ * inherited */
char **attnames; /* the attribute names */
char **atttypedefns; /* formatted column type definitions */
char **typnames; /* fill out attributes */
char *aggbasetype;
char *agginitval;
char *usename;
- int convertok; /* Flag to indicate of version convertsion is OK */
+ int convertok; /* Flag to indicate of version convertsion
+ * is OK */
} AggInfo;
typedef struct _oprInfo
char *oid;
char *oprname;
char *oprkind; /*----------
- * b = binary,
+ * b = binary,
* l = left unary
* r = right unary
*----------
typedef enum _OidOptions
{
- zeroAsOpaque = 1,
- zeroAsAny = 2,
- zeroAsStar = 4,
- zeroAsNone = 8,
- useBaseTypeName = 1024
+ zeroAsOpaque = 1,
+ zeroAsAny = 2,
+ zeroAsStar = 4,
+ zeroAsNone = 8,
+ useBaseTypeName = 1024
} OidOptions;
extern char *findTypeByOid(TypeInfo *tinfo, int numTypes, const char *oid, OidOptions opts);
TableInfo *tbinfo, int numTables, const char *tablename);
extern const char *fmtId(const char *identifier, bool force_quotes);
extern void exit_nicely(void);
-
#endif /* PG_DUMP_H */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.26 2001/09/04 03:20:29 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.27 2001/10/25 05:49:53 momjian Exp $
*
*
{"username", 1, NULL, 'U'},
{"verbose", 0, NULL, 'v'},
- /* the following options don't have an equivalent short option
- letter, but are available as '-X long-name' */
+ /*
+ * the following options don't have an equivalent short option
+ * letter, but are available as '-X long-name'
+ */
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
{NULL, 0, NULL, 0}
};
-#endif /* HAVE_GETOPT_LONG */
+#endif /* HAVE_GETOPT_LONG */
#ifdef ENABLE_NLS
break;
case 'X':
- if (strcmp(optarg, "use-set-session-authorization")==0)
+ if (strcmp(optarg, "use-set-session-authorization") == 0)
use_setsessauth = 1;
else
{
usage(const char *progname)
{
printf(gettext(
- "%s restores a PostgreSQL database from an archive created by pg_dump.\n\n"
- "Usage:\n %s [options] [file]\n\n"
- "Options:\n"),
+ "%s restores a PostgreSQL database from an archive created by pg_dump.\n\n"
+ "Usage:\n %s [options] [file]\n\n"
+ "Options:\n"),
progname, progname);
#ifdef HAVE_GETOPT_LONG
puts(gettext(
- " -a, --data-only restore only the data, no schema\n"
- " -c, --clean clean (drop) schema prior to create\n"
- " -C, --create issue commands to create the database\n"
- " -d, --dbname=NAME specify database name\n"
- " -f, --file=FILENAME TOC output file name (see -l)\n"
- " -F, --format={c|t} specify backup file format\n"
- " -h, --host=HOSTNAME server host name\n"
- " -i, --index=NAME restore named index\n"
- " -l, --list dump summarized TOC for of the archive\n"
- " -L, --use-list=FILENAME use specified table of contents for ordering\n"
- " output from this file\n"
- " -N, --orig-order restore in original dump order\n"
- " -o, --oid-order restore in oid order\n"
- " -O, --no-owner do not reconnect to database to match\n"
- " object owner\n"
- " -p, --port=PORT server port number\n"
- " -P, --function=NAME restore named function\n"
- " -r, --rearrange rearrange output to put indexes etc. at end\n"
- " -R, --no-reconnect disallow ALL reconnections to the database\n"
- " -s, --schema-only restore only the schema, no data\n"
- " -S, --superuser=NAME specify the superuser user name to use for\n"
- " disabling triggers\n"
- " -t, --table=NAME restore named table\n"
- " -T, --trigger=NAME restore named trigger\n"
+ " -a, --data-only restore only the data, no schema\n"
+ " -c, --clean clean (drop) schema prior to create\n"
+ " -C, --create issue commands to create the database\n"
+ " -d, --dbname=NAME specify database name\n"
+ " -f, --file=FILENAME TOC output file name (see -l)\n"
+ " -F, --format={c|t} specify backup file format\n"
+ " -h, --host=HOSTNAME server host name\n"
+ " -i, --index=NAME restore named index\n"
+ " -l, --list dump summarized TOC for of the archive\n"
+ " -L, --use-list=FILENAME use specified table of contents for ordering\n"
+ " output from this file\n"
+ " -N, --orig-order restore in original dump order\n"
+ " -o, --oid-order restore in oid order\n"
+ " -O, --no-owner do not reconnect to database to match\n"
+ " object owner\n"
+ " -p, --port=PORT server port number\n"
+ " -P, --function=NAME restore named function\n"
+ " -r, --rearrange rearrange output to put indexes etc. at end\n"
+ " -R, --no-reconnect disallow ALL reconnections to the database\n"
+ " -s, --schema-only restore only the schema, no data\n"
+ " -S, --superuser=NAME specify the superuser user name to use for\n"
+ " disabling triggers\n"
+ " -t, --table=NAME restore named table\n"
+ " -T, --trigger=NAME restore named trigger\n"
" -U, --username=NAME connect as specified database user\n"
- " -v, --verbose verbose mode\n"
- " -W, --password force password prompt (should happen automatically)\n"
- " -x, --no-privileges skip restoration of access privileges (grant/revoke)\n"
- " -X use-set-session-authorization, --use-set-session-authorization\n"
- " use SET SESSION AUTHORIZATION commands instead\n"
- " of reconnecting, if possible\n"
- ));
+ " -v, --verbose verbose mode\n"
+ " -W, --password force password prompt (should happen automatically)\n"
+ " -x, --no-privileges skip restoration of access privileges (grant/revoke)\n"
+ " -X use-set-session-authorization, --use-set-session-authorization\n"
+ " use SET SESSION AUTHORIZATION commands instead\n"
+ " of reconnecting, if possible\n"
+ ));
-#else /* not HAVE_GETOPT_LONG */
+#else /* not HAVE_GETOPT_LONG */
puts(gettext(
- " -a restore only the data, no schema\n"
- " -c clean (drop) schema prior to create\n"
- " -C issue commands to create the database\n"
- " -d NAME specify database name\n"
- " -f FILENAME TOC output file name (see -l)\n"
- " -F {c|t} specify backup file format\n"
- " -h HOSTNAME server host name\n"
- " -i NAME restore named index\n"
- " -l dump summarized TOC for this file\n"
- " -L FILENAME use specified table of contents for ordering\n"
- " output from this file\n"
- " -N restore in original dump order\n"
- " -o restore in oid order\n"
- " -O do not output reconnect to database to match\n"
- " object owner\n"
- " -p PORT server port number\n"
- " -P NAME restore named function\n"
- " -r rearrange output to put indexes etc. at end\n"
- " -R disallow ALL reconnections to the database\n"
- " -s restore only the schema, no data\n"
- " -S NAME specify the superuser user name to use for\n"
- " disabling triggers\n"
- " -t NAME restore named table\n"
- " -T NAME restore named trigger\n"
+ " -a restore only the data, no schema\n"
+ " -c clean (drop) schema prior to create\n"
+ " -C issue commands to create the database\n"
+ " -d NAME specify database name\n"
+ " -f FILENAME TOC output file name (see -l)\n"
+ " -F {c|t} specify backup file format\n"
+ " -h HOSTNAME server host name\n"
+ " -i NAME restore named index\n"
+ " -l dump summarized TOC for this file\n"
+ " -L FILENAME use specified table of contents for ordering\n"
+ " output from this file\n"
+ " -N restore in original dump order\n"
+ " -o restore in oid order\n"
+ " -O do not output reconnect to database to match\n"
+ " object owner\n"
+ " -p PORT server port number\n"
+ " -P NAME restore named function\n"
+ " -r rearrange output to put indexes etc. at end\n"
+ " -R disallow ALL reconnections to the database\n"
+ " -s restore only the schema, no data\n"
+ " -S NAME specify the superuser user name to use for\n"
+ " disabling triggers\n"
+ " -t NAME restore named table\n"
+ " -T NAME restore named trigger\n"
" -U NAME connect as specified database user\n"
- " -v verbose mode\n"
- " -W force password prompt (should happen automatically)\n"
- " -x skip restoration of access privileges (grant/revoke)\n"
- " -X use-set-session-authorization\n"
- " use SET SESSION AUTHORIZATION commands instead\n"
- " of reconnecting, if possible\n"
- ));
+ " -v verbose mode\n"
+ " -W force password prompt (should happen automatically)\n"
+ " -x skip restoration of access privileges (grant/revoke)\n"
+ " -X use-set-session-authorization\n"
+ " use SET SESSION AUTHORIZATION commands instead\n"
+ " of reconnecting, if possible\n"
+ ));
#endif
puts(gettext("If no input file name is supplied, then standard input is used.\n"));
puts(gettext("Report bugs to
."));
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.9 2001/09/06 04:57:29 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.10 2001/10/25 05:49:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int
main(int argc, char **argv)
{
- char *p;
- int enc;
- bool be_only = FALSE;
+ char *p;
+ int enc;
+ bool be_only = FALSE;
if (argc < 2)
{
usage();
exit(1);
}
-
- if (strcmp(argv[1], "-b")==0)
+
+ if (strcmp(argv[1], "-b") == 0)
{
if (argc < 3)
{
}
else
p = argv[1];
-
+
if (p && *p && isdigit((unsigned char) *p))
{
/*
* Encoding number to name
*/
- char *name;
-
+ char *name;
+
enc = atoi(p);
if ((name = (char *) pg_encoding_to_char(enc)))
printf("%d\n", enc);
}
exit(0);
- }
+ }
exit(1);
}
static void
usage()
{
- fprintf(stderr,
- "\nUsage: pg_encoding [options] encoding_name | encoding_number\n\n"
- "options:"
- " -b check if encoding is valid for backend\n\n"
- );
+ fprintf(stderr,
+ "\nUsage: pg_encoding [options] encoding_name | encoding_number\n\n"
+ "options:"
+ " -b check if encoding is valid for backend\n\n"
+ );
}
#include
#else
extern char *crypt(const char *, const char *);
-
#endif
/*
#ifdef HAVE_TERMIOS_H
struct termios t_orig,
t;
-
#endif
#ifdef HAVE_TERMIOS_H
#ifdef NEED_MATHERR
extern int matherr();
int *tclDummyMathPtr = (int *) matherr;
-
#endif
#ifdef NEED_MATHERR
extern int matherr();
int *tclDummyMathPtr = (int *) matherr;
-
#endif
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.60 2001/10/11 16:54:18 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.61 2001/10/25 05:49:53 momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
enum option_type
{
- OT_NORMAL, OT_SQLID, OT_FILEPIPE
+ OT_NORMAL, OT_SQLID, OT_FILEPIPE
};
static char *scan_option(char **string, enum option_type type, char *quote, bool semicolon);
static char *unescape(const unsigned char *source, size_t len);
if (status == CMD_UNKNOWN)
{
-
/*
- * If the command was not recognized, try to parse it as a one-letter
- * command with immediately following argument (a still-supported,
- * but no longer encouraged, syntax).
+ * If the command was not recognized, try to parse it as a
+ * one-letter command with immediately following argument (a
+ * still-supported, but no longer encouraged, syntax).
*/
char new_cmd[2];
/* use line for options, because my_line was clobbered above */
status = exec_command(new_cmd, line + 1, &continue_parse, query_buf);
- /* continue_parse must be relative to my_line for calculation below */
+ /*
+ * continue_parse must be relative to my_line for calculation
+ * below
+ */
continue_parse += my_line - line;
#if 0 /* turned out to be too annoying */
/* \cd */
else if (strcmp(cmd, "cd") == 0)
{
- char *opt = scan_option(&string, OT_NORMAL, NULL, true);
- char *dir;
+ char *opt = scan_option(&string, OT_NORMAL, NULL, true);
+ char *dir;
if (opt)
dir = opt;
exit(EXIT_FAILURE);
}
dir = pw->pw_dir;
-#else /* WIN32 */
- /* On Windows, 'cd' without arguments prints the current
- directory, so if someone wants to code this here
- instead... */
+#else /* WIN32 */
+
+ /*
+ * On Windows, 'cd' without arguments prints the current
+ * directory, so if someone wants to code this here instead...
+ */
dir = "/";
-#endif /* WIN32 */
+#endif /* WIN32 */
}
if (chdir(dir) == -1)
{
char *name;
bool show_verbose;
+
name = scan_option(&string, OT_SQLID, NULL, true);
show_verbose = strchr(cmd, '+') ? true : false;
break;
case 'u':
success = describeUsers(name);
- break;
+ break;
default:
status = CMD_UNKNOWN;
}
fout = pset.queryFout;
else
fout = stdout;
-
+
while ((value = scan_option(&string, OT_NORMAL, "ed, false)))
{
if (!quoted && strcmp(value, "-n") == 0)
}
else
{
-
/*
* Set variable to the concatenation of the arguments.
*/
switch (options_string[pos])
{
-
/*
* Double quoted string
*/
*string = options_string + jj + 1;
if (quote)
*quote = '"';
-
+
return return_val;
}
return_val[token_end] = 0;
/* Strip any trailing semi-colons for some types */
- if (semicolon) {
- int i;
- for (i = strlen(return_val)-1; i && return_val[i]==';'; i--);
- if (i
+ if (semicolon)
+ {
+ int i;
+
+ for (i = strlen(return_val) - 1; i && return_val[i] == ';'; i--);
+ if (i < strlen(return_val) - 1)
+ return_val[i + 1] = '\0';
}
if (type == OT_SQLID)
}
else
{
-
/*
* we don't want unpredictable things to happen in scripting
* mode
#ifndef WIN32
struct stat before,
after;
-
#endif
if (filename_arg)
{
switch (in)
{
- case PRINT_NOTHING:
+ case PRINT_NOTHING:
return "nothing";
break;
case PRINT_UNALIGNED:
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/command.h,v 1.10 2000/04/12 17:16:22 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.h,v 1.11 2001/10/25 05:49:53 momjian Exp $
*/
#ifndef COMMAND_H
#define COMMAND_H
typedef enum _backslashResult
{
- CMD_UNKNOWN = 0, /* not done parsing yet (internal only) */
- CMD_SEND, /* query complete; send off */
- CMD_SKIP_LINE, /* keep building query */
- CMD_TERMINATE, /* quit program */
- CMD_NEWEDIT, /* query buffer was changed (e.g., via \e) */
- CMD_ERROR /* the execution of the backslash command
+ CMD_UNKNOWN = 0,/* not done parsing yet (internal only) */
+ CMD_SEND, /* query complete; send off */
+ CMD_SKIP_LINE, /* keep building query */
+ CMD_TERMINATE, /* quit program */
+ CMD_NEWEDIT, /* query buffer was changed (e.g., via \e) */
+ CMD_ERROR /* the execution of the backslash command
* resulted in an error */
} backslashResult;
const char *value,
printQueryOpt *popt,
bool quiet);
-
#endif /* COMMAND_H */
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.36 2001/10/18 21:57:11 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.37 2001/10/25 05:49:53 momjian Exp $
*/
#include "postgres_fe.h"
{
int length;
char *destination;
- FILE *termin, *termout;
+ FILE *termin,
+ *termout;
+
#ifdef HAVE_TERMIOS_H
struct termios t_orig,
t;
prompt_state = true; /* disable SIGINT */
/*
- * Do not try to collapse these into one "w+" mode file.
- * Doesn't work on some platforms (eg, HPUX 10.20).
+ * Do not try to collapse these into one "w+" mode file. Doesn't work
+ * on some platforms (eg, HPUX 10.20).
*/
termin = fopen("/dev/tty", "r");
termout = fopen("/dev/tty", "w");
tcsetattr(fileno(termin), TCSAFLUSH, &t);
}
#endif
-
+
if (prompt)
{
fputs(gettext(prompt), termout);
}
errno = save_errno; /* just in case the write changed it */
}
-
#endif /* not WIN32 */
* This is the way to send "backdoor" queries (those not directly entered
* by the user). It is subject to -E but not -e.
*/
-PGresult *
+PGresult *
PSQLexec(const char *query)
{
PGresult *res;
case PGRES_COPY_IN:
if (pset.cur_cmd_interactive && !QUIET())
puts(gettext("Enter data to be copied followed by a newline.\n"
- "End with a backslash and a period on a line by itself."));
+ "End with a backslash and a period on a line by itself."));
success = handleCopyIn(pset.db, pset.cur_cmd_source,
pset.cur_cmd_interactive ? get_prompt(PROMPT_COPY) : NULL);
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.14 2001/10/03 21:58:28 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.15 2001/10/25 05:49:53 momjian Exp $
*/
#ifndef COMMON_H
#define COMMON_H
#include "pqsignal.h"
#include "libpq-fe.h"
-extern char *xstrdup(const char *string);
+extern char *xstrdup(const char *string);
-extern bool setQFout(const char *fname);
+extern bool setQFout(const char *fname);
-extern void psql_error(const char *fmt, ...)
+extern void
+psql_error(const char *fmt,...)
/* This lets gcc check the format string for consistency. */
__attribute__((format(printf, 1, 2)));
-extern void NoticeProcessor(void *arg, const char *message);
+extern void NoticeProcessor(void *arg, const char *message);
-extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
+extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
extern volatile bool cancel_pressed;
extern PGconn *cancelConn;
#ifndef WIN32
-extern void handle_sigint(SIGNAL_ARGS);
-
+extern void handle_sigint(SIGNAL_ARGS);
#endif /* not WIN32 */
-extern PGresult *PSQLexec(const char *query);
-
-extern bool SendQuery(const char *query);
+extern PGresult *PSQLexec(const char *query);
+extern bool SendQuery(const char *query);
#endif /* COMMON_H */
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/copy.h,v 1.9 2000/03/01 21:09:58 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/copy.h,v 1.10 2001/10/25 05:49:53 momjian Exp $
*/
#ifndef COPY_H
#define COPY_H
bool handleCopyOut(PGconn *conn, FILE *copystream);
bool handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt);
-
#endif
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.40 2001/10/06 14:41:17 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.41 2001/10/25 05:49:53 momjian Exp $
*/
#include "postgres_fe.h"
#include "describe.h"
" obj_description(a.oid, 'pg_aggregate') as \"%s\"\n"
"FROM pg_aggregate a\n",
_("Name"), _("(all types)"),
- _("Data type"), _("Description") );
+ _("Data type"), _("Description"));
if (name)
{
" p.proname as \"%s\",\n"
" oidvectortypes(p.proargtypes) as \"%s\"",
_("Result data type"), _("Name"),
- _("Argument data types") );
+ _("Argument data types"));
if (verbose)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
" p.prosrc as \"%s\",\n"
" obj_description(p.oid, 'pg_proc') as \"%s\"",
_("Owner"), _("Language"),
- _("Source code"), _("Description") );
+ _("Source code"), _("Description"));
if (!verbose)
strcat(buf,
snprintf(buf, sizeof(buf),
"SELECT format_type(t.oid, NULL) AS \"%s\",\n",
- _("Name") );
+ _("Name"));
if (verbose)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
" t.typname AS \"%s\",\n"
" THEN CAST('var' AS text)\n"
" ELSE CAST(t.typlen AS text)\n"
" END AS \"%s\",\n",
- _("Internal name"), _("Size") );
- snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
+ _("Internal name"), _("Size"));
+ snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
" obj_description(t.oid, 'pg_type') as \"%s\"\n",
- _("Description") );
+ _("Description"));
/*
* do not include array types (start with underscore), do not include
"FROM pg_proc p, pg_operator o\n"
"WHERE RegprocToOid(o.oprcode) = p.oid\n",
_("Name"), _("Left arg type"), _("Right arg type"),
- _("Result type"), _("Description") );
+ _("Result type"), _("Description"));
if (name)
{
strcat(buf, " AND o.oprname = '");
#endif
if (desc)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
- ",\n obj_description(d.oid, 'pg_database') as \"%s\"",
+ ",\n obj_description(d.oid, 'pg_database') as \"%s\"",
_("Description"));
strcat(buf,
- "\nFROM pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid\n"
+ "\nFROM pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid\n"
"ORDER BY 1;");
res = PSQLexec(buf);
"SELECT DISTINCT tt.name AS \"%s\", tt.object AS \"%s\", d.description AS \"%s\"\n"
"FROM (\n"
- /* Aggregate descriptions */
+ /* Aggregate descriptions */
" SELECT a.oid as oid, a.tableoid as tableoid,\n"
- " CAST(a.aggname AS text) as name, CAST('%s' AS text) as object\n"
+ " CAST(a.aggname AS text) as name, CAST('%s' AS text) as object\n"
" FROM pg_aggregate a\n"
- /* Function descriptions (except in/outs for datatypes) */
+ /* Function descriptions (except in/outs for datatypes) */
"UNION ALL\n"
" SELECT p.oid as oid, p.tableoid as tableoid,\n"
- " CAST(p.proname AS text) as name, CAST('%s' AS text) as object\n"
+ " CAST(p.proname AS text) as name, CAST('%s' AS text) as object\n"
" FROM pg_proc p\n"
- " WHERE p.pronargs = 0 or oidvectortypes(p.proargtypes) <> ''\n"
+ " WHERE p.pronargs = 0 or oidvectortypes(p.proargtypes) <> ''\n"
- /* Operator descriptions (must get comment via associated function) */
+ /* Operator descriptions (must get comment via associated function) */
"UNION ALL\n"
" SELECT RegprocToOid(o.oprcode) as oid,\n"
" (SELECT oid FROM pg_class WHERE relname = 'pg_proc') as tableoid,\n"
- " CAST(o.oprname AS text) as name, CAST('%s' AS text) as object\n"
+ " CAST(o.oprname AS text) as name, CAST('%s' AS text) as object\n"
" FROM pg_operator o\n"
- /* Type description */
+ /* Type description */
"UNION ALL\n"
" SELECT t.oid as oid, t.tableoid as tableoid,\n"
- " format_type(t.oid, NULL) as name, CAST('%s' AS text) as object\n"
+ " format_type(t.oid, NULL) as name, CAST('%s' AS text) as object\n"
" FROM pg_type t\n"
- /* Relation (tables, views, indexes, sequences) descriptions */
+ /* Relation (tables, views, indexes, sequences) descriptions */
"UNION ALL\n"
" SELECT c.oid as oid, c.tableoid as tableoid,\n"
" CAST(c.relname AS text) as name,\n"
" AS text) as object\n"
" FROM pg_class c\n"
- /* Rule description (ignore rules for views) */
+ /* Rule description (ignore rules for views) */
"UNION ALL\n"
" SELECT r.oid as oid, r.tableoid as tableoid,\n"
- " CAST(r.rulename AS text) as name, CAST('%s' AS text) as object\n"
+ " CAST(r.rulename AS text) as name, CAST('%s' AS text) as object\n"
" FROM pg_rewrite r\n"
" WHERE r.rulename !~ '^_RET'\n"
- /* Trigger description */
+ /* Trigger description */
"UNION ALL\n"
" SELECT t.oid as oid, t.tableoid as tableoid,\n"
- " CAST(t.tgname AS text) as name, CAST('%s' AS text) as object\n"
+ " CAST(t.tgname AS text) as name, CAST('%s' AS text) as object\n"
" FROM pg_trigger t\n"
") AS tt,\n"
error = true;
else
{
- char *indisunique = PQgetvalue(result, 0, 0);
- char *indisprimary = PQgetvalue(result, 0, 1);
- char *indamname = PQgetvalue(result, 0, 2);
- char *indpred = PQgetvalue(result, 0, 3);
+ char *indisunique = PQgetvalue(result, 0, 0);
+ char *indisprimary = PQgetvalue(result, 0, 1);
+ char *indamname = PQgetvalue(result, 0, 2);
+ char *indpred = PQgetvalue(result, 0, 3);
footers = xmalloc(3 * sizeof(*footers));
/* XXX This construction is poorly internationalized. */
else if (tableinfo.relkind == 'r')
{
/* Footer information about a table */
- PGresult *result1 = NULL,
- *result2 = NULL,
- *result3 = NULL,
- *result4 = NULL,
- *result5 = NULL,
- *result6 = NULL;
+ PGresult *result1 = NULL,
+ *result2 = NULL,
+ *result3 = NULL,
+ *result4 = NULL,
+ *result5 = NULL,
+ *result6 = NULL;
int index_count = 0,
- primary_count = 0,
- unique_count = 0,
- constr_count = 0,
- rule_count = 0,
- trigger_count = 0;
+ primary_count = 0,
+ unique_count = 0,
+ constr_count = 0,
+ rule_count = 0,
+ trigger_count = 0;
int count_footers = 0;
/* count indexes */
sprintf(buf, "SELECT c2.relname\n"
"FROM pg_class c, pg_class c2, pg_index i\n"
"WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
- "AND NOT i.indisunique ORDER BY c2.relname",
+ "AND NOT i.indisunique ORDER BY c2.relname",
name);
result1 = PSQLexec(buf);
if (!result1)
sprintf(buf, "SELECT c2.relname\n"
"FROM pg_class c, pg_class c2, pg_index i\n"
"WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
- "AND i.indisprimary AND i.indisunique ORDER BY c2.relname",
+ "AND i.indisprimary AND i.indisunique ORDER BY c2.relname",
name);
result5 = PSQLexec(buf);
if (!result5)
sprintf(buf, "SELECT c2.relname\n"
"FROM pg_class c, pg_class c2, pg_index i\n"
"WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
- "AND NOT i.indisprimary AND i.indisunique ORDER BY c2.relname",
+ "AND NOT i.indisprimary AND i.indisunique ORDER BY c2.relname",
name);
result6 = PSQLexec(buf);
if (!result6)
}
footers = xmalloc((index_count + primary_count + unique_count +
- constr_count + rule_count + trigger_count + 1)
- * sizeof(*footers));
+ constr_count + rule_count + trigger_count + 1)
+ * sizeof(*footers));
/* print indexes */
for (i = 0; i < index_count; i++)
{
- char *s = _("Indexes");
+ char *s = _("Indexes");
if (i == 0)
snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result1, i, 0));
else
- snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result1, i, 0));
+ snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result1, i, 0));
if (i < index_count - 1)
strcat(buf, ",");
/* print primary keys */
for (i = 0; i < primary_count; i++)
{
- char *s = _("Primary key");
+ char *s = _("Primary key");
if (i == 0)
snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result5, i, 0));
else
- snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result5, i, 0));
+ snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result5, i, 0));
if (i < primary_count - 1)
strcat(buf, ",");
/* print unique constraints */
for (i = 0; i < unique_count; i++)
{
- char *s = _("Unique keys");
+ char *s = _("Unique keys");
if (i == 0)
snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result6, i, 0));
else
- snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result6, i, 0));
+ snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result6, i, 0));
if (i < unique_count - 1)
strcat(buf, ",");
/* print constraints */
for (i = 0; i < constr_count; i++)
{
- char *s = _("Check constraints");
+ char *s = _("Check constraints");
if (i == 0)
snprintf(buf, sizeof(buf), _("%s: \"%s\" %s"), s,
- PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0));
+ PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0));
else
- snprintf(buf, sizeof(buf), _("%*s \"%s\" %s"), (int)strlen(s), "",
- PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0));
+ snprintf(buf, sizeof(buf), _("%*s \"%s\" %s"), (int) strlen(s), "",
+ PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0));
footers[count_footers++] = xstrdup(buf);
}
/* print rules */
for (i = 0; i < rule_count; i++)
{
- char *s = _("Rules");
+ char *s = _("Rules");
if (i == 0)
snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result3, i, 0));
else
- snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result3, i, 0));
+ snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result3, i, 0));
if (i < rule_count - 1)
strcat(buf, ",");
/* print triggers */
for (i = 0; i < trigger_count; i++)
{
- char *s = _("Triggers");
+ char *s = _("Triggers");
if (i == 0)
snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result4, i, 0));
else
- snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result4, i, 0));
+ snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result4, i, 0));
if (i < trigger_count - 1)
strcat(buf, ",");
*/
bool
-describeUsers (const char *name)
+describeUsers(const char *name)
{
char buf[384 + REGEXP_CUTOFF];
PGresult *res;
printQueryOpt myopt = pset.popt;
-
+
snprintf(buf, sizeof(buf),
"SELECT u.usename AS \"%s\",\n"
" u.usesysid AS \"%s\",\n"
- " CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('%s' AS text)\n"
+ " CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('%s' AS text)\n"
" WHEN u.usesuper THEN CAST('%s' AS text)\n"
" WHEN u.usecreatedb THEN CAST('%s' AS text)\n"
" ELSE CAST('' AS text)\n"
_("User name"), _("User ID"),
_("superuser, create database"),
_("superuser"), _("create database"),
- _("Attributes") );
+ _("Attributes"));
if (name)
{
strcat(buf, "WHERE u.usename ~ '^");
",\n obj_description(c.oid, 'pg_class') as \"%s\"",
_("Description"));
strcat(buf,
- "\nFROM pg_class c LEFT JOIN pg_user u ON c.relowner = u.usesysid\n"
+ "\nFROM pg_class c LEFT JOIN pg_user u ON c.relowner = u.usesysid\n"
"WHERE c.relkind IN (");
if (showTables)
strcat(buf, "'r',");
strcat(buf, "'S',");
if (showSystem && showTables)
strcat(buf, "'s',");
- strcat(buf, "''"); /* dummy */
+ strcat(buf, "''"); /* dummy */
strcat(buf, ")\n");
if (showSystem)
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.10 2001/05/09 17:29:10 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.11 2001/10/25 05:49:53 momjian Exp $
*/
#ifndef DESCRIBE_H
#define DESCRIBE_H
bool describeOperators(const char *name);
/* \du */
-bool describeUsers(const char *name);
+bool describeUsers(const char *name);
/* \z (or \dp) */
bool permissionsList(const char *name);
/* \dt, \di, \ds, \dS, etc. */
bool listTables(const char *infotype, const char *name, bool desc);
-
#endif /* DESCRIBE_H */
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.41 2001/06/11 18:23:33 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.42 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "help.h"
#ifndef WIN32
struct passwd *pw = NULL;
-
#endif
/* Find default user, in case we need it. */
puts(_(" -X Do not read startup file (~/.psqlrc)"));
puts(_(
- "\nFor more information, type \"\\?\" (for internal commands) or \"\\help\"\n"
- "(for SQL commands) from within psql, or consult the psql section in\n"
- "the PostgreSQL documentation.\n\n"
+ "\nFor more information, type \"\\?\" (for internal commands) or \"\\help\"\n"
+ "(for SQL commands) from within psql, or consult the psql section in\n"
+ "the PostgreSQL documentation.\n\n"
}
int ws_row;
int ws_col;
};
-
#endif
void
/* if you add/remove a line here, change the row test above */
fprintf(fout, _(" \\a toggle between unaligned and aligned output mode\n"));
fprintf(fout, _(" \\c[onnect] [DBNAME|- [USER]]\n"
- " connect to new database (currently \"%s\")\n"),
+ " connect to new database (currently \"%s\")\n"),
PQdb(pset.db));
fprintf(fout, _(" \\C TITLE set table title\n"));
fprintf(fout, _(" \\cd [DIRNAME] change the current working directory\n"));
"PARTICULAR PURPOSE.THE SOFTWARE PROVIDED HEREUNDER IS ON AN \"AS IS\" BASIS,\n"
"AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,\n"
"SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
- );
+ );
}
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/help.h,v 1.6 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/help.h,v 1.7 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef HELP_H
#define HELP_H
void helpSQL(const char *topic);
void print_copyright(void);
-
#endif
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.17 2001/09/11 23:08:07 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.18 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "input.h"
/* (of course there is no runtime command for doing that :) */
#ifdef USE_READLINE
static bool useReadline;
-
#endif
#ifdef USE_HISTORY
static bool useHistory;
-
#endif
#ifdef HAVE_ATEXIT
-static void finishInput(void);
+static void finishInput(void);
+
#else
/* designed for use with on_exit() */
-static void finishInput(int, void*);
+static void finishInput(int, void *);
#endif
#ifdef USE_HISTORY
const char *var;
static char *prev_hist = NULL;
-
#endif
#ifdef USE_READLINE
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.12 2001/09/11 23:08:07 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.13 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef INPUT_H
#define INPUT_H
void initializeInput(int flags);
bool saveHistory(char *fname);
-
#endif /* INPUT_H */
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.17 2001/10/04 22:39:34 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.18 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "large_obj.h"
/* XXX ought to replace this with some kind of COMMENT command */
if (comment_arg && pset.issuper)
{
- char *cmdbuf;
- char *bufptr;
- int slen = strlen(comment_arg);
+ char *cmdbuf;
+ char *bufptr;
+ int slen = strlen(comment_arg);
cmdbuf = malloc(slen * 2 + 256);
if (!cmdbuf)
}
sprintf(cmdbuf,
"INSERT INTO pg_description VALUES ('%u', "
- "(SELECT oid FROM pg_class WHERE relname = 'pg_largeobject'),"
+ "(SELECT oid FROM pg_class WHERE relname = 'pg_largeobject'),"
" 0, '", loid);
bufptr = cmdbuf + strlen(cmdbuf);
for (i = 0; i < slen; i++)
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.h,v 1.8 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.h,v 1.9 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef LARGE_OBJ_H
#define LARGE_OBJ_H
bool do_lo_import(const char *filename_arg, const char *comment_arg);
bool do_lo_unlink(const char *loid_arg);
bool do_lo_list(void);
-
#endif /* LARGE_OBJ_H */
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.40 2001/06/02 18:25:18 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.41 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "mainloop.h"
{
if (!pset.cur_cmd_interactive)
{
-
/*
* You get here if you stopped a script with Ctrl-C and a
* query cancel was issued. In that case we don't do the
}
}
- /* establish the control-C handler only after main_loop_jmp is ready */
- pqsignal(SIGINT, handle_sigint); /* control-C => cancel */
-
+ /*
+ * establish the control-C handler only after main_loop_jmp is
+ * ready
+ */
+ pqsignal(SIGINT, handle_sigint); /* control-C => cancel */
#endif /* not WIN32 */
if (slashCmdStatus == CMD_NEWEDIT)
{
-
/*
* just returned from editing the line? then just copy to the
* input buffer
line = new;
len = strlen(new);
- goto rescan;/* reparse the just substituted */
+ goto rescan; /* reparse the just substituted */
}
else
{
/* is there anything else on the line? */
if (line[query_start + strspn(line + query_start, " \t\n\r")] != '\0')
{
-
/*
* insert a cosmetic newline, if this is not the first
* line in the buffer
/* is there anything else on the line for the command? */
if (line[query_start + strspn(line + query_start, " \t\n\r")] != '\0')
{
-
/*
* insert a cosmetic newline, if this is not the first
* line in the buffer
/*
* Reset SIGINT handler because main_loop_jmp will be invalid as soon
* as we exit this routine. If there is an outer MainLoop instance,
- * it will re-enable ^C catching as soon as it gets back to the top
- * of its loop and resets main_loop_jmp to point to itself.
+ * it will re-enable ^C catching as soon as it gets back to the top of
+ * its loop and resets main_loop_jmp to point to itself.
*/
#ifndef WIN32
pqsignal(SIGINT, SIG_DFL);
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.h,v 1.10 2001/02/10 02:31:28 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.h,v 1.11 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef MAINLOOP_H
#define MAINLOOP_H
#include
extern sigjmp_buf main_loop_jmp;
-
#endif
int MainLoop(FILE *source);
-
#endif /* MAINLOOP_H */
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.1 2001/10/15 01:25:10 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.2 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
* original available at : http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
*/
-struct mbinterval {
+struct mbinterval
+{
unsigned short first;
unsigned short last;
};
/* auxiliary function for binary search in interval table */
static int
-mbbisearch(pg_wchar ucs, const struct mbinterval *table, int max)
+mbbisearch(pg_wchar ucs, const struct mbinterval * table, int max)
{
- int min = 0;
- int mid;
+ int min = 0;
+ int mid;
if (ucs < table[0].first || ucs > table[max].last)
return 0;
- while (max >= min) {
+ while (max >= min)
+ {
mid = (min + max) / 2;
if (ucs > table[mid].last)
min = mid + 1;
/* The following functions define the column width of an ISO 10646
* character as follows:
*
- * - The null character (U+0000) has a column width of 0.
+ * - The null character (U+0000) has a column width of 0.
*
- * - Other C0/C1 control characters and DEL will lead to a return
- * value of -1.
+ * - Other C0/C1 control characters and DEL will lead to a return
+ * value of -1.
*
- * - Non-spacing and enclosing combining characters (general
- * category code Mn or Me in the Unicode database) have a
- * column width of 0.
+ * - Non-spacing and enclosing combining characters (general
+ * category code Mn or Me in the Unicode database) have a
+ * column width of 0.
*
- * - Other format characters (general category code Cf in the Unicode
- * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
+ * - Other format characters (general category code Cf in the Unicode
+ * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
*
- * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
- * have a column width of 0.
+ * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
+ * have a column width of 0.
*
- * - Spacing characters in the East Asian Wide (W) or East Asian
- * FullWidth (F) category as defined in Unicode Technical
- * Report #11 have a column width of 2.
+ * - Spacing characters in the East Asian Wide (W) or East Asian
+ * FullWidth (F) category as defined in Unicode Technical
+ * Report #11 have a column width of 2.
*
- * - All remaining characters (including all printable
- * ISO 8859-1 and WGL4 characters, Unicode control characters,
- * etc.) have a column width of 1.
+ * - All remaining characters (including all printable
+ * ISO 8859-1 and WGL4 characters, Unicode control characters,
+ * etc.) have a column width of 1.
*
* This implementation assumes that wchar_t characters are encoded
* in ISO 10646.
{
/* sorted list of non-overlapping intervals of non-spacing characters */
static const struct mbinterval combining[] = {
- { 0x0300, 0x034E }, { 0x0360, 0x0362 }, { 0x0483, 0x0486 },
- { 0x0488, 0x0489 }, { 0x0591, 0x05A1 }, { 0x05A3, 0x05B9 },
- { 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
- { 0x05C4, 0x05C4 }, { 0x064B, 0x0655 }, { 0x0670, 0x0670 },
- { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED },
- { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A },
- { 0x07A6, 0x07B0 }, { 0x0901, 0x0902 }, { 0x093C, 0x093C },
- { 0x0941, 0x0948 }, { 0x094D, 0x094D }, { 0x0951, 0x0954 },
- { 0x0962, 0x0963 }, { 0x0981, 0x0981 }, { 0x09BC, 0x09BC },
- { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 },
- { 0x0A02, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 },
- { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 },
- { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 },
- { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, { 0x0B01, 0x0B01 },
- { 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 },
- { 0x0B4D, 0x0B4D }, { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 },
- { 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 },
- { 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 },
- { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD },
- { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA },
- { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 },
- { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 },
- { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD },
- { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 },
- { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 },
- { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC },
- { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1032 },
- { 0x1036, 0x1037 }, { 0x1039, 0x1039 }, { 0x1058, 0x1059 },
- { 0x1160, 0x11FF }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 },
- { 0x17C9, 0x17D3 }, { 0x180B, 0x180E }, { 0x18A9, 0x18A9 },
- { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x206A, 0x206F },
- { 0x20D0, 0x20E3 }, { 0x302A, 0x302F }, { 0x3099, 0x309A },
- { 0xFB1E, 0xFB1E }, { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF },
- { 0xFFF9, 0xFFFB }
+ {0x0300, 0x034E}, {0x0360, 0x0362}, {0x0483, 0x0486},
+ {0x0488, 0x0489}, {0x0591, 0x05A1}, {0x05A3, 0x05B9},
+ {0x05BB, 0x05BD}, {0x05BF, 0x05BF}, {0x05C1, 0x05C2},
+ {0x05C4, 0x05C4}, {0x064B, 0x0655}, {0x0670, 0x0670},
+ {0x06D6, 0x06E4}, {0x06E7, 0x06E8}, {0x06EA, 0x06ED},
+ {0x070F, 0x070F}, {0x0711, 0x0711}, {0x0730, 0x074A},
+ {0x07A6, 0x07B0}, {0x0901, 0x0902}, {0x093C, 0x093C},
+ {0x0941, 0x0948}, {0x094D, 0x094D}, {0x0951, 0x0954},
+ {0x0962, 0x0963}, {0x0981, 0x0981}, {0x09BC, 0x09BC},
+ {0x09C1, 0x09C4}, {0x09CD, 0x09CD}, {0x09E2, 0x09E3},
+ {0x0A02, 0x0A02}, {0x0A3C, 0x0A3C}, {0x0A41, 0x0A42},
+ {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A70, 0x0A71},
+ {0x0A81, 0x0A82}, {0x0ABC, 0x0ABC}, {0x0AC1, 0x0AC5},
+ {0x0AC7, 0x0AC8}, {0x0ACD, 0x0ACD}, {0x0B01, 0x0B01},
+ {0x0B3C, 0x0B3C}, {0x0B3F, 0x0B3F}, {0x0B41, 0x0B43},
+ {0x0B4D, 0x0B4D}, {0x0B56, 0x0B56}, {0x0B82, 0x0B82},
+ {0x0BC0, 0x0BC0}, {0x0BCD, 0x0BCD}, {0x0C3E, 0x0C40},
+ {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D}, {0x0C55, 0x0C56},
+ {0x0CBF, 0x0CBF}, {0x0CC6, 0x0CC6}, {0x0CCC, 0x0CCD},
+ {0x0D41, 0x0D43}, {0x0D4D, 0x0D4D}, {0x0DCA, 0x0DCA},
+ {0x0DD2, 0x0DD4}, {0x0DD6, 0x0DD6}, {0x0E31, 0x0E31},
+ {0x0E34, 0x0E3A}, {0x0E47, 0x0E4E}, {0x0EB1, 0x0EB1},
+ {0x0EB4, 0x0EB9}, {0x0EBB, 0x0EBC}, {0x0EC8, 0x0ECD},
+ {0x0F18, 0x0F19}, {0x0F35, 0x0F35}, {0x0F37, 0x0F37},
+ {0x0F39, 0x0F39}, {0x0F71, 0x0F7E}, {0x0F80, 0x0F84},
+ {0x0F86, 0x0F87}, {0x0F90, 0x0F97}, {0x0F99, 0x0FBC},
+ {0x0FC6, 0x0FC6}, {0x102D, 0x1030}, {0x1032, 0x1032},
+ {0x1036, 0x1037}, {0x1039, 0x1039}, {0x1058, 0x1059},
+ {0x1160, 0x11FF}, {0x17B7, 0x17BD}, {0x17C6, 0x17C6},
+ {0x17C9, 0x17D3}, {0x180B, 0x180E}, {0x18A9, 0x18A9},
+ {0x200B, 0x200F}, {0x202A, 0x202E}, {0x206A, 0x206F},
+ {0x20D0, 0x20E3}, {0x302A, 0x302F}, {0x3099, 0x309A},
+ {0xFB1E, 0xFB1E}, {0xFE20, 0xFE23}, {0xFEFF, 0xFEFF},
+ {0xFFF9, 0xFFFB}
};
/* test for 8-bit control characters */
- if (ucs == 0) {
+ if (ucs == 0)
return 0;
- }
- if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0) || ucs > 0x0010ffff) {
+ if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0) || ucs > 0x0010ffff)
return -1;
- }
/* binary search in table of non-spacing characters */
if (mbbisearch(ucs, combining,
- sizeof(combining) / sizeof(struct mbinterval) - 1)) {
+ sizeof(combining) / sizeof(struct mbinterval) - 1))
return 0;
- }
- /* if we arrive here, ucs is not a combining or C0/C1 control character */
+ /*
+ * if we arrive here, ucs is not a combining or C0/C1 control
+ * character
+ */
- return 1 +
+ return 1 +
(ucs >= 0x1100 &&
- (ucs <= 0x115f || /* Hangul Jamo init. consonants */
+ (ucs <= 0x115f || /* Hangul Jamo init. consonants */
(ucs >= 0x2e80 && ucs <= 0xa4cf && (ucs & ~0x0011) != 0x300a &&
- ucs != 0x303f) || /* CJK ... Yi */
- (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
- (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */
- (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
- (ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */
+ ucs != 0x303f) || /* CJK ... Yi */
+ (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
+ (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility
+ * Ideographs */
+ (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
+ (ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */
(ucs >= 0xffe0 && ucs <= 0xffe6) ||
(ucs >= 0x20000 && ucs <= 0x2ffff)));
}
pg_wchar
utf2ucs(const unsigned char *c)
{
- /* one char version of pg_utf2wchar_with_len.
- * no control here, c must point to a large enough string
+ /*
+ * one char version of pg_utf2wchar_with_len. no control here, c must
+ * point to a large enough string
*/
- if ((*c & 0x80) == 0) {
- return (pg_wchar)c[0];
- }
- else if ((*c & 0xe0) == 0xc0) {
- return (pg_wchar)(((c[0] & 0x1f) << 6) |
- (c[1] & 0x3f));
+ if ((*c & 0x80) == 0)
+ return (pg_wchar) c[0];
+ else if ((*c & 0xe0) == 0xc0)
+ {
+ return (pg_wchar) (((c[0] & 0x1f) << 6) |
+ (c[1] & 0x3f));
}
- else if ((*c & 0xf0) == 0xe0) {
- return (pg_wchar)(((c[0] & 0x0f) << 12) |
- ((c[1] & 0x3f) << 6) |
- (c[2] & 0x3f));
+ else if ((*c & 0xf0) == 0xe0)
+ {
+ return (pg_wchar) (((c[0] & 0x0f) << 12) |
+ ((c[1] & 0x3f) << 6) |
+ (c[2] & 0x3f));
}
- else if ((*c & 0xf0) == 0xf0) {
- return (pg_wchar)(((c[0] & 0x07) << 18) |
- ((c[1] & 0x3f) << 12) |
- ((c[2] & 0x3f) << 6) |
- (c[3] & 0x3f));
+ else if ((*c & 0xf0) == 0xf0)
+ {
+ return (pg_wchar) (((c[0] & 0x07) << 18) |
+ ((c[1] & 0x3f) << 12) |
+ ((c[2] & 0x3f) << 6) |
+ (c[3] & 0x3f));
}
- else {
+ else
+ {
/* that is an invalid code on purpose */
return 0xffffffff;
}
static int
mb_utf_wcswidth(unsigned char *pwcs, int len)
{
- int w, l = 0;
- int width = 0;
+ int w,
+ l = 0;
+ int width = 0;
- for (;*pwcs && len > 0; pwcs+=l) {
+ for (; *pwcs && len > 0; pwcs += l)
+ {
l = pg_utf_mblen(pwcs);
- if ((len < l) || ((w = ucs_wcwidth(utf2ucs(pwcs))) < 0)) {
+ if ((len < l) || ((w = ucs_wcwidth(utf2ucs(pwcs))) < 0))
return width;
- }
len -= l;
width += w;
}
static int
utf_charcheck(const unsigned char *c)
{
- /* Unicode 3.1 compliant validation :
- * for each category, it checks the combination of each byte to make sur
- * it maps to a valid range. It also returns -1 for the following UCS values:
- * ucs > 0x10ffff
- * ucs & 0xfffe = 0xfffe
- * 0xfdd0 < ucs < 0xfdef
- * ucs & 0xdb00 = 0xd800 (surrogates)
+ /*
+ * Unicode 3.1 compliant validation : for each category, it checks the
+ * combination of each byte to make sur it maps to a valid range. It
+ * also returns -1 for the following UCS values: ucs > 0x10ffff ucs &
+ * 0xfffe = 0xfffe 0xfdd0 < ucs < 0xfdef ucs & 0xdb00 = 0xd800
+ * (surrogates)
*/
- if ((*c & 0x80) == 0) {
+ if ((*c & 0x80) == 0)
return 1;
- }
- else if ((*c & 0xe0) == 0xc0) {
+ else if ((*c & 0xe0) == 0xc0)
+ {
/* two-byte char */
- if(((c[1] & 0xc0) == 0x80) && ((c[0] & 0x1f) > 0x01)) {
+ if (((c[1] & 0xc0) == 0x80) && ((c[0] & 0x1f) > 0x01))
return 2;
- }
return -1;
}
- else if ((*c & 0xf0) == 0xe0) {
+ else if ((*c & 0xf0) == 0xe0)
+ {
/* three-byte char */
if (((c[1] & 0xc0) == 0x80) &&
(((c[0] & 0x0f) != 0x00) || ((c[1] & 0x20) == 0x20)) &&
- ((c[2] & 0xc0) == 0x80)) {
- int z = c[0] & 0x0f;
- int yx = ((c[1] & 0x3f) << 6) | (c[0] & 0x3f);
- int lx = yx & 0x7f;
+ ((c[2] & 0xc0) == 0x80))
+ {
+ int z = c[0] & 0x0f;
+ int yx = ((c[1] & 0x3f) << 6) | (c[0] & 0x3f);
+ int lx = yx & 0x7f;
/* check 0xfffe/0xffff, 0xfdd0..0xfedf range, surrogates */
if (((z == 0x0f) &&
(((yx & 0xffe) == 0xffe) ||
- (((yx & 0xf80) == 0xd80) && (lx >= 0x30) && (lx <= 0x4f)))) ||
- ((z == 0x0d) && ((yx & 0xb00) == 0x800))) {
+ (((yx & 0xf80) == 0xd80) && (lx >= 0x30) && (lx <= 0x4f)))) ||
+ ((z == 0x0d) && ((yx & 0xb00) == 0x800)))
return -1;
- }
return 3;
}
return -1;
}
- else if ((*c & 0xf8) == 0xf0) {
- int u = ((c[0] & 0x07) << 2) | ((c[1] & 0x30) >> 4);
+ else if ((*c & 0xf8) == 0xf0)
+ {
+ int u = ((c[0] & 0x07) << 2) | ((c[1] & 0x30) >> 4);
/* four-byte char */
if (((c[1] & 0xc0) == 0x80) &&
(u > 0x00) && (u <= 0x10) &&
- ((c[2] & 0xc0) == 0x80) && ((c[3] & 0xc0) == 0x80)) {
+ ((c[2] & 0xc0) == 0x80) && ((c[3] & 0xc0) == 0x80))
+ {
/* test for 0xzzzzfffe/0xzzzzfffff */
if (((c[1] & 0x0f) == 0x0f) && ((c[2] & 0x3f) == 0x3f) &&
- ((c[3] & 0x3e) == 0x3e)) {
+ ((c[3] & 0x3e) == 0x3e))
return -1;
- }
return 4;
}
return -1;
}
return -1;
}
-
+
static unsigned char *
mb_utf_validate(unsigned char *pwcs)
{
- int l = 0;
+ int l = 0;
unsigned char *p = pwcs;
unsigned char *p0 = pwcs;
- while( *pwcs ) {
- if ((l = utf_charcheck(pwcs)) > 0) {
- if (p != pwcs) {
- int i;
- for( i = 0; i < l; i++) {
+ while (*pwcs)
+ {
+ if ((l = utf_charcheck(pwcs)) > 0)
+ {
+ if (p != pwcs)
+ {
+ int i;
+
+ for (i = 0; i < l; i++)
*p++ = *pwcs++;
- }
}
- else {
+ else
+ {
pwcs += l;
p += l;
}
}
- else {
+ else
+ {
/* we skip the char */
pwcs++;
}
}
- if (p != pwcs) {
+ if (p != pwcs)
*p = '\0';
- }
return p0;
}
*/
int
-pg_wcswidth(unsigned char *pwcs, int len) {
- if (pset.encoding == PG_UTF8) {
+pg_wcswidth(unsigned char *pwcs, int len)
+{
+ if (pset.encoding == PG_UTF8)
return mb_utf_wcswidth(pwcs, len);
- }
- else {
- /* obviously, other encodings may want to fix this, but I don't know them
- * myself, unfortunately.
+ else
+ {
+ /*
+ * obviously, other encodings may want to fix this, but I don't
+ * know them myself, unfortunately.
*/
return len;
}
}
unsigned char *
-mbvalidate(unsigned char *pwcs) {
- if (pset.encoding == PG_UTF8) {
+mbvalidate(unsigned char *pwcs)
+{
+ if (pset.encoding == PG_UTF8)
return mb_utf_validate(pwcs);
- }
- else {
- /* other encodings needing validation should add their own routines here
+ else
+ {
+ /*
+ * other encodings needing validation should add their own
+ * routines here
*/
return pwcs;
}
}
-#else /* !MULTIBYTE */
+
+#else /* !MULTIBYTE */
/* in single-byte environment, all cells take 1 column */
-int pg_wcswidth(unsigned char *pwcs, int len) {
+int
+pg_wcswidth(unsigned char *pwcs, int len)
+{
return len;
}
#endif
-
-
-/* $Id: mbprint.h,v 1.1 2001/10/15 04:52:59 ishii Exp $ */
+/* $Id: mbprint.h,v 1.2 2001/10/25 05:49:54 momjian Exp $ */
#ifndef MBPRINT_H
#define MBPRINT_H
#include "mb/pg_wchar.h"
-pg_wchar utf2ucs(const unsigned char *c);
+pg_wchar utf2ucs(const unsigned char *c);
unsigned char *mbvalidate(unsigned char *pwcs);
-#endif /* MULTIBYTE */
-
-int pg_wcswidth(unsigned char *pwcs, int len);
-
-#endif /* MBPRINT_H */
+#endif /* MULTIBYTE */
+int pg_wcswidth(unsigned char *pwcs, int len);
+#endif /* MBPRINT_H */
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.22 2001/10/15 01:25:10 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.23 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "print.h"
#ifdef MULTIBYTE
unsigned int cell_count = 0;
- unsigned int *head_w, *cell_w;
+ unsigned int *head_w,
+ *cell_w;
#endif
unsigned int i,
#ifdef MULTIBYTE
head_w = calloc(col_count, sizeof(*head_w));
- if (!head_w) {
- perror("calloc");
- exit(EXIT_FAILURE);
+ if (!head_w)
+ {
+ perror("calloc");
+ exit(EXIT_FAILURE);
}
/* count rows */
- for (ptr = cells; *ptr; ptr++) {
- cell_count++;
- }
+ for (ptr = cells; *ptr; ptr++)
+ cell_count++;
cell_w = calloc(cell_count, sizeof(*cell_w));
- if (!cell_w) {
- perror("calloc");
- exit(EXIT_FAILURE);
+ if (!cell_w)
+ {
+ perror("calloc");
+ exit(EXIT_FAILURE);
}
#endif
-
+
/* calc column widths */
- for (i = 0; i < col_count; i++) {
- if ((tmp = pg_wcswidth((unsigned char *)headers[i], strlen(headers[i]))) > widths[i]) {
+ for (i = 0; i < col_count; i++)
+ {
+ if ((tmp = pg_wcswidth((unsigned char *) headers[i], strlen(headers[i]))) > widths[i])
widths[i] = tmp;
- }
#ifdef MULTIBYTE
head_w[i] = tmp;
#endif
}
- for (i = 0, ptr = cells; *ptr; ptr++, i++) {
- if ((tmp = pg_wcswidth((unsigned char *)*ptr, strlen(*ptr))) > widths[i % col_count]) {
+ for (i = 0, ptr = cells; *ptr; ptr++, i++)
+ {
+ if ((tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr))) > widths[i % col_count])
widths[i % col_count] = tmp;
- }
#ifdef MULTIBYTE
cell_w[i] = tmp;
#endif
total_w += widths[i];
/* print title */
- if (title && !opt_barebones) {
- int tlen;
- if ((tlen = pg_wcswidth((unsigned char *)title, strlen(title))) >= total_w) {
+ if (title && !opt_barebones)
+ {
+ int tlen;
+
+ if ((tlen = pg_wcswidth((unsigned char *) title, strlen(title))) >= total_w)
fprintf(fout, "%s\n", title);
- }
- else {
+ else
fprintf(fout, "%-*s%s\n", (int) (total_w - tlen) / 2, "", title);
- }
}
/* print headers */
for (i = 0; i < col_count; i++)
{
- int nbspace;
+ int nbspace;
+
#ifdef MULTIBYTE
- nbspace = widths[i] - head_w[i];
+ nbspace = widths[i] - head_w[i];
#else
- nbspace = widths[i] - strlen(headers[i]);
+ nbspace = widths[i] - strlen(headers[i]);
#endif
/* centered */
- fprintf(fout, "%-*s%s%-*s",
- nbspace / 2, "", headers[i], (nbspace+1) / 2, "");
+ fprintf(fout, "%-*s%s%-*s",
+ nbspace / 2, "", headers[i], (nbspace + 1) / 2, "");
if (i < col_count - 1)
{
}
/* content */
- if (opt_align[(i) % col_count] == 'r') {
+ if (opt_align[(i) % col_count] == 'r')
+ {
#ifdef MULTIBYTE
- fprintf(fout, "%*s%s",
- widths[i % col_count] - cell_w[i], "", cells[i] );
+ fprintf(fout, "%*s%s",
+ widths[i % col_count] - cell_w[i], "", cells[i]);
#else
fprintf(fout, "%*s", widths[i % col_count], cells[i]);
#endif
{
if ((i + 1) % col_count == 0 && opt_border != 2)
fputs(cells[i], fout);
- else {
+ else
+ {
#ifdef MULTIBYTE
- fprintf(fout, "%-s%*s", cells[i],
- widths[i % col_count] - cell_w[i], "" );
+ fprintf(fout, "%-s%*s", cells[i],
+ widths[i % col_count] - cell_w[i], "");
#else
fprintf(fout, "%-*s", widths[i % col_count], cells[i]);
#endif
hwidth = 0,
dwidth = 0;
char *divider;
+
#ifdef MULTIBYTE
unsigned int cell_count = 0;
- unsigned int *cell_w,*head_w;
+ unsigned int *cell_w,
+ *head_w;
#endif
if (cells[0] == NULL)
#ifdef MULTIBYTE
/* pre-count headers */
- for (ptr = headers; *ptr; ptr++) {
- col_count++;
- }
+ for (ptr = headers; *ptr; ptr++)
+ col_count++;
head_w = calloc(col_count, sizeof(*head_w));
- if (!head_w) {
- perror("calloc");
- exit(EXIT_FAILURE);
+ if (!head_w)
+ {
+ perror("calloc");
+ exit(EXIT_FAILURE);
}
for (i = 0; i < col_count; i++)
{
- if ((tmp = pg_wcswidth((unsigned char *)headers[i], strlen(headers[i]))) > hwidth)
+ if ((tmp = pg_wcswidth((unsigned char *) headers[i], strlen(headers[i]))) > hwidth)
hwidth = tmp;
head_w[i] = tmp;
}
- for (ptr = cells; *ptr; ptr++) {
- cell_count++;
- }
+ for (ptr = cells; *ptr; ptr++)
+ cell_count++;
cell_w = calloc(cell_count, sizeof(*cell_w));
- if (!cell_w) {
- perror("calloc");
- exit(EXIT_FAILURE);
- }
+ if (!cell_w)
+ {
+ perror("calloc");
+ exit(EXIT_FAILURE);
+ }
/* find longest data cell */
- for (i = 0, ptr = cells; *ptr; ptr++, i++) {
- if ((tmp = pg_wcswidth((unsigned char *)*ptr, strlen(*ptr))) > dwidth) {
+ for (i = 0, ptr = cells; *ptr; ptr++, i++)
+ {
+ if ((tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr))) > dwidth)
dwidth = tmp;
- }
- cell_w[i] = tmp;
+ cell_w[i] = tmp;
}
#else
/* count columns and find longest header */
}
/* find longest data cell */
- for (ptr = cells; *ptr; ptr++) {
+ for (ptr = cells; *ptr; ptr++)
+ {
if ((tmp = strlen(*ptr)) > dwidth)
dwidth = tmp;
}
if (opt_border < 2)
fprintf(fout, "%s\n", *ptr);
- else {
+ else
+ {
#ifdef MULTIBYTE
fprintf(fout, "%-s%*s |\n", *ptr, dwidth - cell_w[i], "");
#else
exit(EXIT_FAILURE);
}
- for (i = 0; i < nfields; i++) {
+ for (i = 0; i < nfields; i++)
+ {
#ifdef MULTIBYTE
headers[i] = mbvalidate(PQfname(result, i));
#else
{
if (PQgetisnull(result, i / nfields, i % nfields))
cells[i] = opt->nullPrint ? opt->nullPrint : "";
- else {
+ else
+ {
#ifdef MULTIBYTE
cells[i] = mbvalidate(PQgetvalue(result, i / nfields, i % nfields));
#else
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/print.h,v 1.9 2001/05/12 19:44:46 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/print.h,v 1.10 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef PRINT_H
#define PRINT_H
enum printFormat
{
- PRINT_NOTHING = 0, /* to make sure someone initializes this */
- PRINT_UNALIGNED,
- PRINT_ALIGNED,
- PRINT_HTML,
- PRINT_LATEX
+ PRINT_NOTHING = 0, /* to make sure someone
+ * initializes this */
+ PRINT_UNALIGNED,
+ PRINT_ALIGNED,
+ PRINT_HTML,
+ PRINT_LATEX
/* add your favourite output format here ... */
};
char *title; /* override title */
char **footers; /* override footer (default is "(xx
* rows)") */
- bool default_footer; /* print default footer if footers==NULL */
+ bool default_footer; /* print default footer if footers==NULL */
} printQueryOpt;
/*
* It calls the printTable above with all the things set straight.
*/
void
-printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout);
-
+ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout);
#endif /* PRINT_H */
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.21 2001/08/24 19:59:54 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.22 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "prompt.h"
*
* Defined interpolations are:
* %M - database server "hostname.domainname", "[local]" for AF_UNIX
- * sockets, "[local:/dir/name]" if not default
+ * sockets, "[local:/dir/name]" if not default
* %m - like %M, but hostname only (before first dot), or always "[local]"
* %> - database server port number
* %n - database user name
case 'm':
if (pset.db)
{
- const char * host = PQhost(pset.db);
+ const char *host = PQhost(pset.db);
/* INET socket */
if (host && host[0] && host[0] != '/')
else
{
if (!host
- || strcmp(host, DEFAULT_PGSOCKET_DIR)==0
+ || strcmp(host, DEFAULT_PGSOCKET_DIR) == 0
|| *p == 'm')
strncpy(buf, "[local]", MAX_PROMPT_SIZE);
else
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/prompt.h,v 1.8 2000/04/12 17:16:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/prompt.h,v 1.9 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef PROMPT_H
#define PROMPT_H
typedef enum _promptStatus
{
- PROMPT_READY,
- PROMPT_CONTINUE,
- PROMPT_COMMENT,
- PROMPT_SINGLEQUOTE,
- PROMPT_DOUBLEQUOTE,
- PROMPT_PAREN,
- PROMPT_COPY
+ PROMPT_READY,
+ PROMPT_CONTINUE,
+ PROMPT_COMMENT,
+ PROMPT_SINGLEQUOTE,
+ PROMPT_DOUBLEQUOTE,
+ PROMPT_PAREN,
+ PROMPT_COPY
} promptStatus_t;
char *get_prompt(promptStatus_t status);
-
#endif /* PROMPT_H */
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/settings.h,v 1.10 2000/04/12 17:16:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/settings.h,v 1.11 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef SETTINGS_H
#define SETTINGS_H
#define EXIT_BADCONN 2
#define EXIT_USER 3
-
#endif
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.51 2001/06/30 17:26:12 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.52 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
*/
enum _actions
{
- ACT_NOTHING = 0,
- ACT_SINGLE_SLASH,
- ACT_LIST_DB,
- ACT_SINGLE_QUERY,
- ACT_FILE
+ ACT_NOTHING = 0,
+ ACT_SINGLE_SLASH,
+ ACT_LIST_DB,
+ ACT_SINGLE_QUERY,
+ ACT_FILE
};
struct adhoc_opts
#ifdef USE_SSL
static void
printSSLInfo(void);
-
#endif
if (options.username)
{
-
/*
* The \001 is a hack to support the deprecated -u option which
* issues a username prompt. The recommended option is -U followed
/*
* process file given by -f
*/
- if (options.action == ACT_FILE && strcmp(options.action_string, "-")!=0)
+ if (options.action == ACT_FILE && strcmp(options.action_string, "-") != 0)
{
if (!options.no_psqlrc)
process_psqlrc();
printf(gettext("Welcome to %s, the PostgreSQL interactive terminal.\n\n"
"Type: \\copyright for distribution terms\n"
" \\h for help with SQL commands\n"
- " \\? for help on internal slash commands\n"
- " \\g or terminate with semicolon to execute query\n"
+ " \\? for help on internal slash commands\n"
+ " \\g or terminate with semicolon to execute query\n"
" \\q to quit\n\n"),
pset.progname);
#ifdef USE_SSL
process_psqlrc();
if (!pset.notty)
initializeInput(options.no_readline ? 0 : 1);
- if (options.action_string) /* -f - was used */
+ if (options.action_string) /* -f - was used */
pset.inputfile = "";
successResult = MainLoop(stdin);
}
/* And it requires progname to be set */
char *__progname = "psql";
-
#endif
static void
};
int optindex;
-
#endif /* HAVE_GETOPT_LONG */
extern char *optarg;
case '-':
fprintf(stderr,
gettext("%s was compiled without support for long options.\n"
- "Use --help for help on invocation options.\n"),
+ "Use --help for help on invocation options.\n"),
pset.progname);
exit(EXIT_FAILURE);
break;
puts(gettext("Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group\n"
"Portions Copyright (c) 1996, Regents of the University of California\n"
- "Read the file COPYRIGHT or use the command \\copyright to see the\n"
+ "Read the file COPYRIGHT or use the command \\copyright to see the\n"
"usage and distribution terms."));
}
printf(gettext("SSL connection (cipher: %s, bits: %i)\n\n"),
SSL_get_cipher(ssl), sslbits);
}
-
#endif
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.h,v 1.14 2000/02/07 23:10:07 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.h,v 1.15 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef STRINGUTILS_H
#define STRINGUTILS_H
char *was_quoted,
unsigned int *token_pos,
int encoding);
-
#endif /* STRINGUTILS_H */
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.38 2001/09/21 03:32:36 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.39 2001/10/25 05:49:54 momjian Exp $
*/
/*----------------------------------------------------------------------
initialize_readline(void)
{
rl_readline_name = pset.progname;
- rl_attempted_completion_function = (void *)psql_completion;
+ rl_attempted_completion_function = (void *) psql_completion;
rl_basic_word_break_characters = "\t\n@$><=;|&{( ";
/* Complete INSERT INTO with table names */
else if (strcasecmp(prev2_wd, "INSERT") == 0 && strcasecmp(prev_wd, "INTO") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_tables);
- /* Complete INSERT INTO
with "VALUES" or "SELECT" or "DEFAULT VALUES" */
+
+ /*
+ * Complete INSERT INTO
with "VALUES" or "SELECT" or "DEFAULT
+ * VALUES"
+ */
else if (strcasecmp(prev3_wd, "INSERT") == 0 && strcasecmp(prev2_wd, "INTO") == 0)
{
char *list_INSERT[] = {"DEFAULT VALUES", "SELECT", "VALUES", NULL};
/* Complete SET SESSION with AUTHORIZATION or CHARACTERISTICS... */
else if (strcasecmp(prev2_wd, "SET") == 0 && strcasecmp(prev_wd, "SESSION") == 0)
{
- char *my_list[] = {"AUTHORIZATION",
- "CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL",
- NULL};
+ char *my_list[] = {"AUTHORIZATION",
+ "CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL",
+ NULL};
COMPLETE_WITH_LIST(my_list);
}
/* Complete SET SESSION AUTHORIZATION with username */
- else if (strcasecmp(prev3_wd, "SET") == 0
+ else if (strcasecmp(prev3_wd, "SET") == 0
&& strcasecmp(prev2_wd, "SESSION") == 0
&& strcasecmp(prev_wd, "AUTHORIZATION") == 0)
- {
COMPLETE_WITH_QUERY(Query_for_list_of_users);
- }
/* Complete SET with "TO" */
else if (strcasecmp(prev2_wd, "SET") == 0 &&
strcasecmp(prev4_wd, "UPDATE") != 0)
COMPLETE_WITH_LIST(my_list);
}
else if (strcmp(prev_wd, "\\cd") == 0 ||
- strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 ||
+ strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 ||
strcmp(prev_wd, "\\g") == 0 ||
strcmp(prev_wd, "\\i") == 0 || strcmp(prev_wd, "\\include") == 0 ||
- strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 ||
+ strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 ||
strcmp(prev_wd, "\\s") == 0 ||
- strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0
+ strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0
)
matches = completion_matches(text, filename_completion_function);
return s;
}
-
#endif /* 0 */
-
#endif /* USE_READLINE */
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.h,v 1.6 2001/02/10 02:31:28 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.h,v 1.7 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef TAB_COMPLETE_H
#define TAB_COMPLETE_H
#include "postgres_fe.h"
void initialize_readline(void);
-
#endif
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.8 2000/04/12 17:16:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.9 2001/10/25 05:49:54 momjian Exp $
*/
/*
bool DeleteVariable(VariableSpace space, const char *name);
void DestroyVariableSpace(VariableSpace space);
-
#endif /* VARIABLES_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: attnum.h,v 1.12 2001/01/24 19:43:19 momjian Exp $
+ * $Id: attnum.h,v 1.13 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
#define AttrOffsetGetAttrNumber(attributeOffset) \
((AttrNumber) (1 + attributeOffset))
-
#endif /* ATTNUM_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: clog.h,v 1.2 2001/09/29 04:02:26 tgl Exp $
+ * $Id: clog.h,v 1.3 2001/10/25 05:49:55 momjian Exp $
*/
#ifndef CLOG_H
#define CLOG_H
extern void clog_redo(XLogRecPtr lsn, XLogRecord *record);
extern void clog_undo(XLogRecPtr lsn, XLogRecord *record);
extern void clog_desc(char *buf, uint8 xl_info, char *rec);
-
#endif /* CLOG_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: genam.h,v 1.27 2001/10/06 23:21:44 tgl Exp $
+ * $Id: genam.h,v 1.28 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* Struct for statistics returned by bulk-delete operation */
typedef struct IndexBulkDeleteResult
{
- BlockNumber num_pages; /* pages remaining in index */
- double tuples_removed; /* # removed by bulk-delete operation */
- double num_index_tuples; /* # remaining */
+ BlockNumber num_pages; /* pages remaining in index */
+ double tuples_removed; /* # removed by bulk-delete operation */
+ double num_index_tuples; /* # remaining */
} IndexBulkDeleteResult;
/* Typedef for callback function to determine if a tuple is bulk-deletable */
extern RetrieveIndexResult index_getnext(IndexScanDesc scan,
ScanDirection direction);
extern IndexBulkDeleteResult *index_bulk_delete(Relation relation,
- IndexBulkDeleteCallback callback,
- void *callback_state);
+ IndexBulkDeleteCallback callback,
+ void *callback_state);
extern RegProcedure index_cost_estimator(Relation relation);
extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum,
uint16 procnum);
extern struct FmgrInfo *index_getprocinfo(Relation irel, AttrNumber attnum,
- uint16 procnum);
+ uint16 procnum);
/* in genam.c */
extern IndexScanDesc RelationGetIndexScan(Relation relation, bool scanFromEnd,
uint16 numberOfKeys, ScanKey key);
extern void IndexScanEnd(IndexScanDesc scan);
-
#endif /* GENAM_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: gist.h,v 1.32 2001/08/22 18:24:26 tgl Exp $
+ * $Id: gist.h,v 1.33 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
OffsetNumber *spl_left; /* array of entries that go left */
int spl_nleft; /* size of this array */
Datum spl_ldatum; /* Union of keys in spl_left */
- Datum spl_lattr[INDEX_MAX_KEYS]; /* Union of subkeys in spl_left */
- int spl_lattrsize[INDEX_MAX_KEYS];
- bool spl_lisnull[INDEX_MAX_KEYS];
+ Datum spl_lattr[INDEX_MAX_KEYS]; /* Union of subkeys in
+ * spl_left */
+ int spl_lattrsize[INDEX_MAX_KEYS];
+ bool spl_lisnull[INDEX_MAX_KEYS];
OffsetNumber *spl_right; /* array of entries that go right */
int spl_nright; /* size of the array */
Datum spl_rdatum; /* Union of keys in spl_right */
- Datum spl_rattr[INDEX_MAX_KEYS]; /* Union of subkeys in spl_right */
- int spl_rattrsize[INDEX_MAX_KEYS];
- bool spl_risnull[INDEX_MAX_KEYS];
-
- int *spl_idgrp;
- int *spl_ngrp; /* number in each group */
- char *spl_grpflag; /* flags of each group */
+ Datum spl_rattr[INDEX_MAX_KEYS]; /* Union of subkeys in
+ * spl_right */
+ int spl_rattrsize[INDEX_MAX_KEYS];
+ bool spl_risnull[INDEX_MAX_KEYS];
+
+ int *spl_idgrp;
+ int *spl_ngrp; /* number in each group */
+ char *spl_grpflag; /* flags of each group */
} GIST_SPLITVEC;
/*
extern void initGISTstate(GISTSTATE *giststate, Relation index);
extern void freeGISTstate(GISTSTATE *giststate);
extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
- Datum k, Relation r, Page pg, OffsetNumber o,
- int b, bool l, bool isNull);
+ Datum k, Relation r, Page pg, OffsetNumber o,
+ int b, bool l, bool isNull);
extern StrategyNumber RelationGetGISTStrategy(Relation, AttrNumber,
- RegProcedure);
+ RegProcedure);
extern void gist_redo(XLogRecPtr lsn, XLogRecord *record);
extern void gist_undo(XLogRecPtr lsn, XLogRecord *record);
/* gistget.c */
extern Datum gistgettuple(PG_FUNCTION_ARGS);
-
#endif /* GIST_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: gistscan.h,v 1.16 2001/07/15 22:48:18 tgl Exp $
+ * $Id: gistscan.h,v 1.17 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern Datum gistendscan(PG_FUNCTION_ARGS);
extern void gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum);
extern void AtEOXact_gist(void);
-
#endif /* GISTSCAN_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: hash.h,v 1.39 2001/07/15 22:48:18 tgl Exp $
+ * $Id: hash.h,v 1.40 2001/10/25 05:49:55 momjian Exp $
*
* NOTES
* modeled after Margo Seltzer's hash implementation for unix.
bits16 hasho_flag; /* is this page a bucket or ovfl */
Bucket hasho_bucket; /* bucket number this pg belongs to */
OverflowPageAddress hasho_oaddr; /* ovfl address of this ovfl pg */
- BlockNumber hasho_nextblkno;/* next ovfl blkno */
- BlockNumber hasho_prevblkno;/* previous ovfl (or bucket) blkno */
+ BlockNumber hasho_nextblkno; /* next ovfl blkno */
+ BlockNumber hasho_prevblkno; /* previous ovfl (or bucket) blkno */
} HashPageOpaqueData;
typedef HashPageOpaqueData *HashPageOpaque;
uint16 hashm_bshift; /* bucket shift */
uint16 hashm_bmsize; /* bitmap array size (bytes) - must be a
* power of 2 */
- uint32 hashm_maxbucket;/* ID of maximum bucket in use */
+ uint32 hashm_maxbucket; /* ID of maximum bucket in use */
uint32 hashm_highmask; /* mask to modulo into entire table */
uint32 hashm_lowmask; /* mask to modulo into lower half of table */
uint32 hashm_ovflpoint;/* pageno. from which ovflpgs being
* allocated */
- uint32 hashm_lastfreed;/* last ovflpage freed */
+ uint32 hashm_lastfreed; /* last ovflpage freed */
uint32 hashm_nmaps; /* Initial number of bitmaps */
uint32 hashm_spares[NCACHED]; /* spare pages available at
* splitpoints */
extern void hash_redo(XLogRecPtr lsn, XLogRecord *record);
extern void hash_undo(XLogRecPtr lsn, XLogRecord *record);
extern void hash_desc(char *buf, uint8 xl_info, char *rec);
-
#endif /* HASH_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: heapam.h,v 1.68 2001/09/17 00:29:10 tgl Exp $
+ * $Id: heapam.h,v 1.69 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
bool *isnull);
-
#endif /* defined(DISABLE_COMPLEX_MACRO) */
extern void heap_undo(XLogRecPtr lsn, XLogRecord *rptr);
extern void heap_desc(char *buf, uint8 xl_info, char *rec);
extern XLogRecPtr log_heap_clean(Relation reln, Buffer buffer,
- char *unused, int unlen);
+ char *unused, int unlen);
extern XLogRecPtr log_heap_move(Relation reln, Buffer oldbuf,
- ItemPointerData from,
- Buffer newbuf, HeapTuple newtup);
+ ItemPointerData from,
+ Buffer newbuf, HeapTuple newtup);
/* in common/heaptuple.c */
extern Size ComputeDataSize(TupleDesc tupleDesc, Datum *value, char *nulls);
/* in common/heap/stats.c */
extern void PrintHeapAccessStatistics(HeapAccessStatistics stats);
extern void initam(void);
-
#endif /* HEAPAM_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: hio.h,v 1.19 2001/06/29 21:08:25 tgl Exp $
+ * $Id: hio.h,v 1.20 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void RelationPutHeapTuple(Relation relation, Buffer buffer,
HeapTuple tuple);
extern Buffer RelationGetBufferForTuple(Relation relation, Size len,
- Buffer otherBuffer);
-
+ Buffer otherBuffer);
#endif /* HIO_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: htup.h,v 1.48 2001/03/25 22:40:58 tgl Exp $
+ * $Id: htup.h,v 1.49 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define HeapTupleHasExtended(tuple) \
((((HeapTuple)(tuple))->t_data->t_infomask & HEAP_HASEXTENDED) != 0)
-
#endif /* HTUP_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: ibit.h,v 1.15 2001/01/24 19:43:19 momjian Exp $
+ * $Id: ibit.h,v 1.16 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* True iff attribute bit map is valid.
*/
#define IndexAttributeBitMapIsValid(bits) PointerIsValid(bits)
-
#endif /* IBIT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: iqual.h,v 1.15 2001/01/24 19:43:19 momjian Exp $
+ * $Id: iqual.h,v 1.16 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool index_keytest(IndexTuple tuple, TupleDesc tupdesc,
int scanKeySize, ScanKey key);
-
#endif /* IQUAL_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: istrat.h,v 1.20 2001/03/22 04:00:28 momjian Exp $
+ * $Id: istrat.h,v 1.21 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
StrategyNumber maxStrategyNumber,
StrategyNumber maxSupportNumber,
AttrNumber maxAttributeNumber);
-
#endif /* ISTRAT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: itup.h,v 1.31 2001/03/22 04:00:29 momjian Exp $
+ * $Id: itup.h,v 1.32 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
ItemPointer heapItemPointer);
extern void CopyIndexTuple(IndexTuple source, IndexTuple *target);
-
#endif /* ITUP_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nbtree.h,v 1.56 2001/07/15 22:48:18 tgl Exp $
+ * $Id: nbtree.h,v 1.57 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void _bt_spooldestroy(BTSpool *btspool);
extern void _bt_spool(BTItem btitem, BTSpool *btspool);
extern void _bt_leafbuild(BTSpool *btspool, BTSpool *spool2);
-
#endif /* NBTREE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: printtup.h,v 1.15 2001/03/22 04:00:29 momjian Exp $
+ * $Id: printtup.h,v 1.16 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem,
bool *typIsVarlena);
-
#endif /* PRINTTUP_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: relscan.h,v 1.22 2001/06/22 19:16:23 wieck Exp $
+ * $Id: relscan.h,v 1.23 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
uint16 rs_nkeys; /* number of scan keys to select tuples */
ScanKey rs_key; /* key descriptors */
- PgStat_Info rs_pgstat_info; /* statistics collector hook */
+ PgStat_Info rs_pgstat_info; /* statistics collector hook */
} HeapScanDescData;
typedef HeapScanDescData *HeapScanDesc;
Relation relation; /* relation descriptor */
void *opaque; /* access-method-specific info */
ItemPointerData currentItemData; /* current index pointer */
- ItemPointerData currentMarkData; /* marked current pointer */
+ ItemPointerData currentMarkData; /* marked current pointer */
uint8 flags; /* scan position flags */
bool scanFromEnd; /* restart scan at end? */
uint16 numberOfKeys; /* number of scan keys to select tuples */
ScanKey keyData; /* key descriptors */
FmgrInfo fn_getnext; /* cached lookup info for am's getnext fn */
- PgStat_Info xs_pgstat_info; /* statistics collector hook */
+ PgStat_Info xs_pgstat_info; /* statistics collector hook */
} IndexScanDescData;
typedef IndexScanDescData *IndexScanDesc;
* True iff the index scan is valid.
*/
#define IndexScanIsValid(scan) PointerIsValid(scan)
-
#endif /* RELSCAN_H */
*
* Resource managers definition
*
- * $Id: rmgr.h,v 1.6 2001/08/25 18:52:42 tgl Exp $
+ * $Id: rmgr.h,v 1.7 2001/10/25 05:49:55 momjian Exp $
*/
#ifndef RMGR_H
#define RMGR_H
#define RM_GIST_ID 14
#define RM_SEQ_ID 15
#define RM_MAX_ID RM_SEQ_ID
-
#endif /* RMGR_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rtree.h,v 1.24 2001/07/15 22:48:18 tgl Exp $
+ * $Id: rtree.h,v 1.25 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* rtstrat.c */
extern RegProcedure RTMapOperator(Relation r, AttrNumber attnum,
RegProcedure proc);
-
#endif /* RTREE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rtscan.h,v 1.10 2001/01/24 19:43:19 momjian Exp $
+ * $Id: rtscan.h,v 1.11 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "utils/rel.h"
void rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum);
-
#endif /* RTSCAN_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: sdir.h,v 1.9 2001/01/24 19:43:19 momjian Exp $
+ * $Id: sdir.h,v 1.10 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
typedef enum ScanDirection
{
- BackwardScanDirection = -1,
- NoMovementScanDirection = 0,
- ForwardScanDirection = 1
+ BackwardScanDirection = -1,
+ NoMovementScanDirection = 0,
+ ForwardScanDirection = 1
} ScanDirection;
/*
*/
#define ScanDirectionIsForward(direction) \
((bool) ((direction) == ForwardScanDirection))
-
#endif /* SDIR_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: skey.h,v 1.17 2001/10/06 23:21:44 tgl Exp $
+ * $Id: skey.h,v 1.18 2001/10/25 05:49:55 momjian Exp $
*
* Note:
* Needs more accessor/assignment routines.
extern void ScanKeyEntryInitialize(ScanKey entry, bits16 flags,
AttrNumber attributeNumber, RegProcedure procedure, Datum argument);
extern void ScanKeyEntryInitializeWithInfo(ScanKey entry, bits16 flags,
- AttrNumber attributeNumber, FmgrInfo *finfo,
- MemoryContext mcxt, Datum argument);
-
+ AttrNumber attributeNumber, FmgrInfo *finfo,
+ MemoryContext mcxt, Datum argument);
#endif /* SKEY_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: strat.h,v 1.22 2001/05/30 19:53:39 tgl Exp $
+ * $Id: strat.h,v 1.23 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef struct StrategyTermData
{ /* conjunctive term */
uint16 degree;
- StrategyOperatorData operatorData[1]; /* VARIABLE LENGTH ARRAY */
+ StrategyOperatorData operatorData[1]; /* VARIABLE LENGTH ARRAY */
} StrategyTermData; /* VARIABLE LENGTH STRUCTURE */
typedef StrategyTermData *StrategyTerm;
} IndexStrategyData; /* VARIABLE LENGTH STRUCTURE */
typedef IndexStrategyData *IndexStrategy;
-
#endif /* STRAT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: transam.h,v 1.41 2001/09/29 04:02:26 tgl Exp $
+ * $Id: transam.h,v 1.42 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define TransactionIdIsNormal(xid) ((xid) >= FirstNormalTransactionId)
#define TransactionIdEquals(id1, id2) ((id1) == (id2))
#define TransactionIdStore(xid, dest) (*(dest) = (xid))
-#define StoreInvalidTransactionId(dest) (*(dest) = InvalidTransactionId)
+#define StoreInvalidTransactionId(dest) (*(dest) = InvalidTransactionId)
/* advance a transaction ID variable, handling wraparound correctly */
#define TransactionIdAdvance(dest) \
do { \
* OIDS 10000-16383 are reserved for assignment by genbki.sh.
*
* OIDs beginning at 16384 are assigned at runtime from the OID
- * generator. (The first few of these will be assigned during initdb,
+ * generator. (The first few of these will be assigned during initdb,
* to objects created after the initial BKI script processing.)
*
* The choices of 10000 and 16384 are completely arbitrary, and can be moved
/* in varsup.c */
extern VariableCache ShmemVariableCache;
-
#endif /* TRAMSAM_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: tupdesc.h,v 1.30 2001/01/24 19:43:20 momjian Exp $
+ * $Id: tupdesc.h,v 1.31 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool attisset);
extern TupleDesc BuildDescForRelation(List *schema, char *relname);
-
#endif /* TUPDESC_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: tupmacs.h,v 1.17 2001/03/22 04:00:31 momjian Exp $
+ * $Id: tupmacs.h,v 1.18 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
: \
PointerGetDatum((char *) (T)) \
)
-
#endif /* SIZEOF_DATUM == 8 */
/*
break; \
} \
} while (0)
-
#endif /* SIZEOF_DATUM == 8 */
-
#endif
*
* Copyright (c) 2000, PostgreSQL Development Team
*
- * $Id: tuptoaster.h,v 1.11 2001/05/07 00:43:24 tgl Exp $
+ * $Id: tuptoaster.h,v 1.12 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
extern Size toast_raw_datum_size(Datum value);
-
#endif /* TUPTOASTER_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: valid.h,v 1.23 2001/01/24 19:43:20 momjian Exp $
+ * $Id: valid.h,v 1.24 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
(tuple)->t_data = NULL; \
} \
} while (0)
-
#endif /* VALID_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: xact.h,v 1.38 2001/10/18 17:30:15 thomas Exp $
+ * $Id: xact.h,v 1.39 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern Datum xidout(PG_FUNCTION_ARGS);
extern Datum xideq(PG_FUNCTION_ARGS);
extern Datum xid_age(PG_FUNCTION_ARGS);
-
#endif /* XACT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: xlog.h,v 1.25 2001/08/25 18:52:42 tgl Exp $
+ * $Id: xlog.h,v 1.26 2001/10/25 05:49:56 momjian Exp $
*/
#ifndef XLOG_H
#define XLOG_H
/* ACTUAL LOG DATA FOLLOWS AT END OF STRUCT */
-} XLogContRecord;
+} XLogContRecord;
#define SizeOfXLogContRecord MAXALIGN(sizeof(XLogContRecord))
extern bool check_xlog_sync_method(const char *method);
extern void assign_xlog_sync_method(const char *method);
-
#endif /* XLOG_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: xlogdefs.h,v 1.4 2001/08/25 18:52:42 tgl Exp $
+ * $Id: xlogdefs.h,v 1.5 2001/10/25 05:49:56 momjian Exp $
*/
#ifndef XLOG_DEFS_H
#define XLOG_DEFS_H
* pg_clog after shutdown, in future.
*/
typedef uint32 StartUpID;
-
#endif /* XLOG_DEFS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: xlogutils.h,v 1.8 2001/08/25 18:52:42 tgl Exp $
+ * $Id: xlogutils.h,v 1.9 2001/10/25 05:49:56 momjian Exp $
*/
#ifndef XLOG_UTILS_H
#define XLOG_UTILS_H
extern Relation XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode);
extern Buffer XLogReadBuffer(bool extend, Relation reln, BlockNumber blkno);
-
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: bootstrap.h,v 1.23 2001/08/10 18:57:39 tgl Exp $
+ * $Id: bootstrap.h,v 1.24 2001/10/25 05:49:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define BS_XLOG_STARTUP 2
#define BS_XLOG_CHECKPOINT 3
#define BS_XLOG_SHUTDOWN 4
-
#endif /* BOOTSTRAP_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: c.h,v 1.105 2001/10/24 21:49:14 petere Exp $
+ * $Id: c.h,v 1.106 2001/10/25 05:49:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
#define _priv_CppIdentity(x)x
#define CppConcat(x, y) _priv_CppIdentity(x)y
-
#endif /* !HAVE_STRINGIZE */
/*
#ifndef false
#define false ((bool) 0)
#endif
-
#endif /* not C++ */
-
#endif /* __BEOS__ */
typedef bool *BoolPtr;
typedef signed char int8; /* == 8 bits */
typedef signed short int16; /* == 16 bits */
typedef signed int int32; /* == 32 bits */
-
#endif /* __BEOS__ */
/*
typedef unsigned char uint8; /* == 8 bits */
typedef unsigned short uint16; /* == 16 bits */
typedef unsigned int uint32; /* == 32 bits */
-
#endif /* __BEOS__ */
/*
#else /* not BUILDING_DLL */
#define DLLIMPORT __declspec (dllimport)
#endif
-#elif defined(WIN32) && defined(_MSC_VER) /* not CYGWIN */
+#elif defined(WIN32) && defined(_MSC_VER) /* not CYGWIN */
#if defined(_DLL)
#define DLLIMPORT __declspec (dllexport)
#else /* not _DLL */
*/
#ifndef HAVE_SNPRINTF_DECL
-extern int snprintf(char *str, size_t count, const char *fmt, ...)
+extern int
+snprintf(char *str, size_t count, const char *fmt,...)
/* This extension allows gcc to check the format string */
__attribute__((format(printf, 3, 4)));
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: catalog.h,v 1.17 2001/05/30 20:52:34 momjian Exp $
+ * $Id: catalog.h,v 1.18 2001/10/25 05:49:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool IsSharedSystemRelationName(const char *relname);
extern Oid newoid(void);
-
#endif /* CATALOG_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: catname.h,v 1.20 2001/08/25 18:52:42 tgl Exp $
+ * $Id: catname.h,v 1.21 2001/10/25 05:49:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define TriggerRelationName "pg_trigger"
extern char *SharedSystemRelationNames[];
-
#endif /* CATNAME_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: catversion.h,v 1.99 2001/10/18 17:30:15 thomas Exp $
+ * $Id: catversion.h,v 1.100 2001/10/25 05:49:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 200110181
-
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: heap.h,v 1.38 2001/10/22 22:47:57 tgl Exp $
+ * $Id: heap.h,v 1.39 2001/10/25 05:49:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
List *rawColDefaults,
List *rawConstraints);
-extern int RemoveCheckConstraint(Relation rel, const char *constrName, bool inh);
+extern int RemoveCheckConstraint(Relation rel, const char *constrName, bool inh);
extern Form_pg_attribute SystemAttributeDefinition(AttrNumber attno,
- bool relhasoids);
+ bool relhasoids);
extern Form_pg_attribute SystemAttributeByName(const char *attname,
- bool relhasoids);
-
+ bool relhasoids);
#endif /* HEAP_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: index.h,v 1.40 2001/10/06 23:21:44 tgl Exp $
+ * $Id: index.h,v 1.41 2001/10/25 05:49:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* Typedef for callback function for IndexBuildHeapScan */
typedef void (*IndexBuildCallback) (Relation index,
- HeapTuple htup,
- Datum *attdata,
- char *nulls,
- bool tupleIsAlive,
- void *state);
+ HeapTuple htup,
+ Datum *attdata,
+ char *nulls,
+ bool tupleIsAlive,
+ void *state);
extern Form_pg_am AccessMethodObjectIdGetForm(Oid accessMethodObjectId,
extern void UpdateStats(Oid relid, double reltuples);
extern bool IndexesAreActive(Oid relid, bool comfirmCommitted);
extern void setRelhasindex(Oid relid, bool hasindex,
- bool isprimary, Oid reltoastidxid);
+ bool isprimary, Oid reltoastidxid);
extern void setNewRelfilenode(Relation relation);
extern bool IsReindexProcessing(void);
extern void index_build(Relation heapRelation, Relation indexRelation,
- IndexInfo *indexInfo);
+ IndexInfo *indexInfo);
extern double IndexBuildHeapScan(Relation heapRelation,
- Relation indexRelation,
- IndexInfo *indexInfo,
- IndexBuildCallback callback,
- void *callback_state);
+ Relation indexRelation,
+ IndexInfo *indexInfo,
+ IndexBuildCallback callback,
+ void *callback_state);
extern bool reindex_index(Oid indexId, bool force, bool inplace);
extern bool activate_indexes_of_a_table(Oid relid, bool activate);
extern bool reindex_relation(Oid relid, bool force);
-
#endif /* INDEX_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: indexing.h,v 1.53 2001/08/21 16:36:05 tgl Exp $
+ * $Id: indexing.h,v 1.54 2001/10/25 05:49:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* last step of initialization script: build the indices declared above */
BUILD_INDICES
-
#endif /* INDEXING_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_aggregate.h,v 1.32 2001/09/28 08:09:13 thomas Exp $
+ * $Id: pg_aggregate.h,v 1.33 2001/10/25 05:49:56 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
DATA(insert OID = 0 ( avg PGUID interval_accum interval_avg 1186 1187 1186 "{0 second,0 second}" ));
DATA(insert OID = 0 ( sum PGUID int8_sum - 20 1700 1700 _null_ ));
-DATA(insert OID = 0 ( sum PGUID int4_sum - 23 20 20 _null_ ));
-DATA(insert OID = 0 ( sum PGUID int2_sum - 21 20 20 _null_ ));
+DATA(insert OID = 0 ( sum PGUID int4_sum - 23 20 20 _null_ ));
+DATA(insert OID = 0 ( sum PGUID int2_sum - 21 20 20 _null_ ));
DATA(insert OID = 0 ( sum PGUID float4pl - 700 700 700 _null_ ));
DATA(insert OID = 0 ( sum PGUID float8pl - 701 701 701 _null_ ));
DATA(insert OID = 0 ( sum PGUID cash_pl - 790 790 790 _null_ ));
extern Datum AggNameGetInitVal(char *aggName, Oid basetype,
bool *isNull);
-
#endif /* PG_AGGREGATE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_am.h,v 1.18 2001/07/15 22:48:18 tgl Exp $
+ * $Id: pg_am.h,v 1.19 2001/10/25 05:49:56 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
{
NameData amname; /* access method name */
int4 amowner; /* usesysid of creator */
- int2 amstrategies; /* total NUMBER of strategies (operators) by
- * which we can traverse/search this AM */
+ int2 amstrategies; /* total NUMBER of strategies (operators)
+ * by which we can traverse/search this AM */
int2 amsupport; /* total NUMBER of support functions that
* this AM uses */
int2 amorderstrategy;/* if this AM has a sort order, the
* ----------------
*/
-DATA(insert OID = 402 ( rtree PGUID 8 3 0 f f f f rtgettuple rtinsert rtbeginscan rtrescan rtendscan rtmarkpos rtrestrpos rtbuild rtbulkdelete rtcostestimate ));
+DATA(insert OID = 402 ( rtree PGUID 8 3 0 f f f f rtgettuple rtinsert rtbeginscan rtrescan rtendscan rtmarkpos rtrestrpos rtbuild rtbulkdelete rtcostestimate ));
DESCR("r-tree index access method");
-DATA(insert OID = 403 ( btree PGUID 5 1 1 t t t t btgettuple btinsert btbeginscan btrescan btendscan btmarkpos btrestrpos btbuild btbulkdelete btcostestimate ));
+DATA(insert OID = 403 ( btree PGUID 5 1 1 t t t t btgettuple btinsert btbeginscan btrescan btendscan btmarkpos btrestrpos btbuild btbulkdelete btcostestimate ));
DESCR("b-tree index access method");
#define BTREE_AM_OID 403
-DATA(insert OID = 405 ( hash PGUID 1 1 0 f f f t hashgettuple hashinsert hashbeginscan hashrescan hashendscan hashmarkpos hashrestrpos hashbuild hashbulkdelete hashcostestimate ));
+DATA(insert OID = 405 ( hash PGUID 1 1 0 f f f t hashgettuple hashinsert hashbeginscan hashrescan hashendscan hashmarkpos hashrestrpos hashbuild hashbulkdelete hashcostestimate ));
DESCR("hash index access method");
DATA(insert OID = 783 ( gist PGUID 100 7 0 f t f f gistgettuple gistinsert gistbeginscan gistrescan gistendscan gistmarkpos gistrestrpos gistbuild gistbulkdelete gistcostestimate ));
DESCR("GiST index access method");
-
#endif /* PG_AM_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_amop.h,v 1.42 2001/09/28 08:09:13 thomas Exp $
+ * $Id: pg_amop.h,v 1.43 2001/10/25 05:49:56 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
DATA(insert ( 2004 1 f 1062 ));
/* timestamp_ops */
DATA(insert ( 2040 1 f 2060 ));
-
#endif /* PG_AMOP_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_amproc.h,v 1.31 2001/09/28 08:09:13 thomas Exp $
+ * $Id: pg_amproc.h,v 1.32 2001/10/25 05:49:56 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
*/
/* rtree */
-DATA(insert ( 422 1 193 ));
-DATA(insert ( 422 2 194 ));
-DATA(insert ( 422 3 196 ));
-DATA(insert ( 425 1 193 ));
-DATA(insert ( 425 2 194 ));
-DATA(insert ( 425 3 195 ));
-DATA(insert ( 1993 1 197 ));
-DATA(insert ( 1993 2 198 ));
-DATA(insert ( 1993 3 199 ));
+DATA(insert ( 422 1 193 ));
+DATA(insert ( 422 2 194 ));
+DATA(insert ( 422 3 196 ));
+DATA(insert ( 425 1 193 ));
+DATA(insert ( 425 2 194 ));
+DATA(insert ( 425 3 195 ));
+DATA(insert ( 1993 1 197 ));
+DATA(insert ( 1993 2 198 ));
+DATA(insert ( 1993 3 199 ));
/* btree */
-DATA(insert ( 421 1 357 ));
+DATA(insert ( 421 1 357 ));
DATA(insert ( 423 1 1596 ));
DATA(insert ( 424 1 1693 ));
DATA(insert ( 426 1 1078 ));
DATA(insert ( 428 1 1954 ));
-DATA(insert ( 429 1 358 ));
-DATA(insert ( 432 1 926 ));
+DATA(insert ( 429 1 358 ));
+DATA(insert ( 432 1 926 ));
DATA(insert ( 434 1 1092 ));
-DATA(insert ( 1970 1 354 ));
-DATA(insert ( 1972 1 355 ));
-DATA(insert ( 1974 1 926 ));
-DATA(insert ( 1976 1 350 ));
-DATA(insert ( 1978 1 351 ));
-DATA(insert ( 1980 1 842 ));
+DATA(insert ( 1970 1 354 ));
+DATA(insert ( 1972 1 355 ));
+DATA(insert ( 1974 1 926 ));
+DATA(insert ( 1976 1 350 ));
+DATA(insert ( 1978 1 351 ));
+DATA(insert ( 1980 1 842 ));
DATA(insert ( 1982 1 1315 ));
-DATA(insert ( 1984 1 836 ));
-DATA(insert ( 1986 1 359 ));
+DATA(insert ( 1984 1 836 ));
+DATA(insert ( 1986 1 359 ));
DATA(insert ( 1988 1 1769 ));
-DATA(insert ( 1989 1 356 ));
-DATA(insert ( 1991 1 404 ));
-DATA(insert ( 1994 1 360 ));
+DATA(insert ( 1989 1 356 ));
+DATA(insert ( 1991 1 404 ));
+DATA(insert ( 1994 1 360 ));
DATA(insert ( 1996 1 1107 ));
DATA(insert ( 1998 1 1314 ));
DATA(insert ( 2000 1 1358 ));
/* hash */
DATA(insert ( 427 1 1080 ));
-DATA(insert ( 431 1 454 ));
-DATA(insert ( 433 1 456 ));
-DATA(insert ( 435 1 450 ));
-DATA(insert ( 1971 1 451 ));
-DATA(insert ( 1973 1 452 ));
-DATA(insert ( 1975 1 456 ));
-DATA(insert ( 1977 1 449 ));
-DATA(insert ( 1979 1 450 ));
-DATA(insert ( 1981 1 949 ));
+DATA(insert ( 431 1 454 ));
+DATA(insert ( 433 1 456 ));
+DATA(insert ( 435 1 450 ));
+DATA(insert ( 1971 1 451 ));
+DATA(insert ( 1973 1 452 ));
+DATA(insert ( 1975 1 456 ));
+DATA(insert ( 1977 1 449 ));
+DATA(insert ( 1979 1 450 ));
+DATA(insert ( 1981 1 949 ));
DATA(insert ( 1983 1 1697 ));
-DATA(insert ( 1985 1 399 ));
-DATA(insert ( 1987 1 455 ));
-DATA(insert ( 1990 1 453 ));
-DATA(insert ( 1992 1 457 ));
-DATA(insert ( 1995 1 456 ));
-DATA(insert ( 1997 1 452 ));
-DATA(insert ( 1999 1 452 ));
+DATA(insert ( 1985 1 399 ));
+DATA(insert ( 1987 1 455 ));
+DATA(insert ( 1990 1 453 ));
+DATA(insert ( 1992 1 457 ));
+DATA(insert ( 1995 1 456 ));
+DATA(insert ( 1997 1 452 ));
+DATA(insert ( 1999 1 452 ));
DATA(insert ( 2001 1 1696 ));
-DATA(insert ( 2004 1 456 ));
-DATA(insert ( 2040 1 452 ));
-
+DATA(insert ( 2004 1 456 ));
+DATA(insert ( 2040 1 452 ));
#endif /* PG_AMPROC_H */
#define Anum_pg_attrdef_adbin 3
#define Anum_pg_attrdef_adsrc 4
-
#endif /* PG_ATTRDEF_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_attribute.h,v 1.76 2001/08/26 16:56:00 tgl Exp $
+ * $Id: pg_attribute.h,v 1.77 2001/10/25 05:49:56 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
* information from the DATA() statements.
*
* utils/cache/relcache.c requires hard-coded tuple descriptors
- * for some of the system catalogs. So if the schema for any of
+ * for some of the system catalogs. So if the schema for any of
* these changes, be sure and change the appropriate Schema_xxx
* macros! -cim 2/5/91
*
Oid atttypid;
/*
- * attstattarget is the target number of statistics datapoints to collect
- * during VACUUM ANALYZE of this column. A zero here indicates that we
- * do not wish to collect any stats about this column.
+ * attstattarget is the target number of statistics datapoints to
+ * collect during VACUUM ANALYZE of this column. A zero here
+ * indicates that we do not wish to collect any stats about this
+ * column.
*/
int4 attstattarget;
{ 1247, {"typsend"}, 24, 0, 4, 14, 0, -1, -1, true, 'p', false, 'i', false, false }, \
{ 1247, {"typalign"}, 18, 0, 1, 15, 0, -1, -1, true, 'p', false, 'c', false, false }, \
{ 1247, {"typstorage"}, 18, 0, 1, 16, 0, -1, -1, true, 'p', false, 'c', false, false }, \
-{ 1247, {"typdefault"}, 25, 0, -1, 17, 0, -1, -1, false , 'x', false, 'i', false, false }
+{ 1247, {"typdefault"}, 25, 0, -1, 17, 0, -1, -1, false , 'x', false, 'i', false, false }
DATA(insert ( 1247 typname 19 DEFAULT_ATTSTATTARGET NAMEDATALEN 1 0 -1 -1 f p f i f f));
DATA(insert ( 1247 typowner 23 0 4 2 0 -1 -1 t p f i f f));
* ----------------
*/
DATA(insert ( 376 xactlockfoo 26 0 4 1 0 -1 -1 t p f i f f));
-
#endif /* PG_ATTRIBUTE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_class.h,v 1.54 2001/08/26 16:56:01 tgl Exp $
+ * $Id: pg_class.h,v 1.55 2001/10/25 05:49:57 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
bool relisshared; /* T if shared across databases */
char relkind; /* see RELKIND_xxx constants below */
int2 relnatts; /* number of user attributes */
+
/*
* Class pg_attribute must contain exactly "relnatts" user attributes
* (with attnums ranging from 1 to relnatts) for this class. It may
bool relhaspkey; /* has PRIMARY KEY index */
bool relhasrules; /* has associated rules */
bool relhassubclass; /* has derived classes */
+
/*
* relacl may or may not be present, see note above!
*/
#define RELKIND_UNCATALOGED 'u' /* temporary heap */
#define RELKIND_TOASTVALUE 't' /* moved off huge values */
#define RELKIND_VIEW 'v' /* view */
-
#endif /* PG_CLASS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_control.h,v 1.3 2001/03/22 04:00:38 momjian Exp $
+ * $Id: pg_control.h,v 1.4 2001/10/25 05:49:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* System status indicator */
typedef enum DBState
{
- DB_STARTUP = 0,
- DB_SHUTDOWNED,
- DB_SHUTDOWNING,
- DB_IN_RECOVERY,
- DB_IN_PRODUCTION
+ DB_STARTUP = 0,
+ DB_SHUTDOWNED,
+ DB_SHUTDOWNING,
+ DB_IN_RECOVERY,
+ DB_IN_PRODUCTION
} DBState;
#define LOCALE_NAME_BUFLEN 128
char lc_collate[LOCALE_NAME_BUFLEN];
char lc_ctype[LOCALE_NAME_BUFLEN];
} ControlFileData;
-
#endif /* PG_CONTROL_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_database.h,v 1.18 2001/08/26 16:56:02 tgl Exp $
+ * $Id: pg_database.h,v 1.19 2001/10/25 05:49:57 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
bool datistemplate; /* allowed as CREATE DATABASE template? */
bool datallowconn; /* new connections allowed? */
Oid datlastsysoid; /* highest OID to consider a system OID */
- TransactionId datvacuumxid; /* all XIDs before this are vacuumed */
- TransactionId datfrozenxid; /* all XIDs before this are frozen */
+ TransactionId datvacuumxid; /* all XIDs before this are vacuumed */
+ TransactionId datfrozenxid; /* all XIDs before this are frozen */
text datpath; /* VARIABLE LENGTH FIELD */
} FormData_pg_database;
#define RecoveryDb 2
#undef DATAMARKOID
-
#endif /* PG_DATABASE_H */
* NOTE: an object is identified by the OID of the row that primarily
* defines the object, plus the OID of the table that that row appears in.
* For example, a function is identified by the OID of its pg_proc row
- * plus the pg_class OID of table pg_proc. This allows unique identification
+ * plus the pg_class OID of table pg_proc. This allows unique identification
* of objects without assuming that OIDs are unique across tables.
*
* Since attributes don't have OIDs of their own, we identify an attribute
* comment by the objoid+classoid of its parent table, plus an "objsubid"
- * giving the attribute column number. "objsubid" must be zero in a comment
+ * giving the attribute column number. "objsubid" must be zero in a comment
* for a table itself, so that it is distinct from any column comment.
* Currently, objsubid is unused and zero for all other kinds of objects,
* but perhaps it might be useful someday to associate comments with
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_description.h,v 1.13 2001/08/10 18:57:40 tgl Exp $
+ * $Id: pg_description.h,v 1.14 2001/10/25 05:49:57 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
* there is no initialization here. The initial contents are extracted
* by genbki.sh and loaded during initdb.
*/
-
#endif /* PG_DESCRIPTION_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_group.h,v 1.10 2001/08/10 18:57:40 tgl Exp $
+ * $Id: pg_group.h,v 1.11 2001/10/25 05:49:57 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
#define Anum_pg_group_groname 1
#define Anum_pg_group_grosysid 2
#define Anum_pg_group_grolist 3
-
#endif /* PG_GROUP_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_index.h,v 1.24 2001/08/21 16:36:05 tgl Exp $
+ * $Id: pg_index.h,v 1.25 2001/10/25 05:49:57 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
regproc indproc; /* OID of function for functional index */
int2vector indkey; /* column numbers of indexed attributes */
oidvector indclass; /* opclass identifiers */
- bool indisclustered; /* presently unused */
+ bool indisclustered; /* presently unused */
bool indisunique; /* is this a unique index? */
bool indisprimary; /* is this index for primary key? */
Oid indreference; /* oid of index of referenced relation (ie
* - this index for foreign key) */
+
/* VARIABLE LENGTH FIELD: */
- text indpred; /* expression tree for predicate,
- * if a partial index */
+ text indpred; /* expression tree for predicate, if a
+ * partial index */
} FormData_pg_index;
/* ----------------
#define Anum_pg_index_indisprimary 8
#define Anum_pg_index_indreference 9
#define Anum_pg_index_indpred 10
-
#endif /* PG_INDEX_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_inherits.h,v 1.11 2001/08/10 18:57:40 tgl Exp $
+ * $Id: pg_inherits.h,v 1.12 2001/10/25 05:49:57 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
#define Anum_pg_inherits_inhparent 2
#define Anum_pg_inherits_inhseqno 3
-
#endif /* PG_INHERITS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_language.h,v 1.13 2001/01/24 19:43:21 momjian Exp $
+ * $Id: pg_language.h,v 1.14 2001/10/25 05:49:57 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
DESCR("SQL-language functions");
#define SQLlanguageId 14
-
#endif /* PG_LANGUAGE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_largeobject.h,v 1.9 2001/08/10 20:52:25 tgl Exp $
+ * $Id: pg_largeobject.h,v 1.10 2001/10/25 05:49:57 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
extern void LargeObjectCreate(Oid loid);
extern void LargeObjectDrop(Oid loid);
extern bool LargeObjectExists(Oid loid);
-
#endif /* PG_LARGEOBJECT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_listener.h,v 1.10 2001/08/10 18:57:40 tgl Exp $
+ * $Id: pg_listener.h,v 1.11 2001/10/25 05:49:57 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
* ----------------
*/
-
#endif /* PG_LISTENER_H */
* --- that is, there is a row for each valid combination
* of opclass name and index access method type. This row specifies the
* expected input data type for the opclass (the type of the heap column,
- * or the function output type in the case of a functional index). Note
+ * or the function output type in the case of a functional index). Note
* that types binary-compatible with the specified type will be accepted too.
*
* For a given pair, there can be at most one row that
* such an index.
*
* Normally opckeytype = InvalidOid (zero), indicating that the data stored
- * in the index is the same as the input data. If opckeytype is nonzero
+ * in the index is the same as the input data. If opckeytype is nonzero
* then it indicates that a conversion step is needed to produce the stored
* index data, which will be of type opckeytype (which might be the same or
- * different from the input data). Performing such a conversion is the
+ * different from the input data). Performing such a conversion is the
* responsibility of the index access method --- not all AMs support this.
- *
+ *
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_opclass.h,v 1.40 2001/09/28 08:09:13 thomas Exp $
+ * $Id: pg_opclass.h,v 1.41 2001/10/25 05:49:57 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
DATA(insert OID = 1995 ( 405 text_ops 25 t 0 ));
DATA(insert OID = 1996 ( 403 time_ops 1083 t 0 ));
DATA(insert OID = 1997 ( 405 time_ops 1083 t 0 ));
-DATA(insert OID = 1998 ( 403 timestamptz_ops 1184 t 0 ));
-DATA(insert OID = 1999 ( 405 timestamptz_ops 1184 t 0 ));
+DATA(insert OID = 1998 ( 403 timestamptz_ops 1184 t 0 ));
+DATA(insert OID = 1999 ( 405 timestamptz_ops 1184 t 0 ));
DATA(insert OID = 2000 ( 403 timetz_ops 1266 t 0 ));
DATA(insert OID = 2001 ( 405 timetz_ops 1266 t 0 ));
DATA(insert OID = 2002 ( 403 varbit_ops 1562 t 0 ));
DATA(insert OID = 2004 ( 405 varchar_ops 1043 t 0 ));
DATA(insert OID = 2039 ( 403 timestamp_ops 1114 t 0 ));
DATA(insert OID = 2040 ( 405 timestamp_ops 1114 t 0 ));
-
#endif /* PG_OPCLASS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_operator.h,v 1.96 2001/09/30 06:46:58 inoue Exp $
+ * $Id: pg_operator.h,v 1.97 2001/10/25 05:49:57 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
/* MAC type */
DATA(insert OID = 1220 ( "=" PGUID 0 b t f 829 829 16 1220 1221 1222 1222 macaddr_eq eqsel eqjoinsel ));
-DATA(insert OID = 1221 ( "<>" PGUID 0 b t f 829 829 16 1221 1220 0 0 macaddr_ne neqsel neqjoinsel ));
-DATA(insert OID = 1222 ( "<" PGUID 0 b t f 829 829 16 1224 1225 0 0 macaddr_lt scalarltsel scalarltjoinsel ));
-DATA(insert OID = 1223 ( "<=" PGUID 0 b t f 829 829 16 1225 1224 0 0 macaddr_le scalarltsel scalarltjoinsel ));
-DATA(insert OID = 1224 ( ">" PGUID 0 b t f 829 829 16 1222 1223 0 0 macaddr_gt scalargtsel scalargtjoinsel ));
-DATA(insert OID = 1225 ( ">=" PGUID 0 b t f 829 829 16 1223 1222 0 0 macaddr_ge scalargtsel scalargtjoinsel ));
+DATA(insert OID = 1221 ( "<>" PGUID 0 b t f 829 829 16 1221 1220 0 0 macaddr_ne neqsel neqjoinsel ));
+DATA(insert OID = 1222 ( "<" PGUID 0 b t f 829 829 16 1224 1225 0 0 macaddr_lt scalarltsel scalarltjoinsel ));
+DATA(insert OID = 1223 ( "<=" PGUID 0 b t f 829 829 16 1225 1224 0 0 macaddr_le scalarltsel scalarltjoinsel ));
+DATA(insert OID = 1224 ( ">" PGUID 0 b t f 829 829 16 1222 1223 0 0 macaddr_gt scalargtsel scalargtjoinsel ));
+DATA(insert OID = 1225 ( ">=" PGUID 0 b t f 829 829 16 1223 1222 0 0 macaddr_ge scalargtsel scalargtjoinsel ));
/* INET type */
DATA(insert OID = 1201 ( "=" PGUID 0 b t f 869 869 16 1201 1202 1203 1203 network_eq eqsel eqjoinsel ));
-DATA(insert OID = 1202 ( "<>" PGUID 0 b t f 869 869 16 1202 1201 0 0 network_ne neqsel neqjoinsel ));
-DATA(insert OID = 1203 ( "<" PGUID 0 b t f 869 869 16 1205 1206 0 0 network_lt scalarltsel scalarltjoinsel ));
-DATA(insert OID = 1204 ( "<=" PGUID 0 b t f 869 869 16 1206 1205 0 0 network_le scalarltsel scalarltjoinsel ));
-DATA(insert OID = 1205 ( ">" PGUID 0 b t f 869 869 16 1203 1204 0 0 network_gt scalargtsel scalargtjoinsel ));
-DATA(insert OID = 1206 ( ">=" PGUID 0 b t f 869 869 16 1204 1203 0 0 network_ge scalargtsel scalargtjoinsel ));
-DATA(insert OID = 931 ( "<<" PGUID 0 b t f 869 869 16 933 0 0 0 network_sub - - ));
-#define OID_INET_SUB_OP 931
-DATA(insert OID = 932 ( "<<=" PGUID 0 b t f 869 869 16 934 0 0 0 network_subeq - - ));
-#define OID_INET_SUBEQ_OP 932
-DATA(insert OID = 933 ( ">>" PGUID 0 b t f 869 869 16 931 0 0 0 network_sup - - ));
-#define OID_INET_SUP_OP 933
-DATA(insert OID = 934 ( ">>=" PGUID 0 b t f 869 869 16 932 0 0 0 network_supeq - - ));
-#define OID_INET_SUPEQ_OP 934
+DATA(insert OID = 1202 ( "<>" PGUID 0 b t f 869 869 16 1202 1201 0 0 network_ne neqsel neqjoinsel ));
+DATA(insert OID = 1203 ( "<" PGUID 0 b t f 869 869 16 1205 1206 0 0 network_lt scalarltsel scalarltjoinsel ));
+DATA(insert OID = 1204 ( "<=" PGUID 0 b t f 869 869 16 1206 1205 0 0 network_le scalarltsel scalarltjoinsel ));
+DATA(insert OID = 1205 ( ">" PGUID 0 b t f 869 869 16 1203 1204 0 0 network_gt scalargtsel scalargtjoinsel ));
+DATA(insert OID = 1206 ( ">=" PGUID 0 b t f 869 869 16 1204 1203 0 0 network_ge scalargtsel scalargtjoinsel ));
+DATA(insert OID = 931 ( "<<" PGUID 0 b t f 869 869 16 933 0 0 0 network_sub - - ));
+#define OID_INET_SUB_OP 931
+DATA(insert OID = 932 ( "<<=" PGUID 0 b t f 869 869 16 934 0 0 0 network_subeq - - ));
+#define OID_INET_SUBEQ_OP 932
+DATA(insert OID = 933 ( ">>" PGUID 0 b t f 869 869 16 931 0 0 0 network_sup - - ));
+#define OID_INET_SUP_OP 933
+DATA(insert OID = 934 ( ">>=" PGUID 0 b t f 869 869 16 932 0 0 0 network_supeq - - ));
+#define OID_INET_SUPEQ_OP 934
/* CIDR type */
DATA(insert OID = 820 ( "=" PGUID 0 b t f 650 650 16 820 821 822 822 network_eq eqsel eqjoinsel ));
DATA(insert OID = 824 ( ">" PGUID 0 b t f 650 650 16 822 823 0 0 network_gt scalargtsel scalargtjoinsel ));
DATA(insert OID = 825 ( ">=" PGUID 0 b t f 650 650 16 823 822 0 0 network_ge scalargtsel scalargtjoinsel ));
DATA(insert OID = 826 ( "<<" PGUID 0 b t f 650 650 16 828 0 0 0 network_sub - - ));
-#define OID_CIDR_SUB_OP 826
+#define OID_CIDR_SUB_OP 826
DATA(insert OID = 827 ( "<<=" PGUID 0 b t f 650 650 16 1004 0 0 0 network_subeq - - ));
#define OID_CIDR_SUBEQ_OP 827
DATA(insert OID = 828 ( ">>" PGUID 0 b t f 650 650 16 826 0 0 0 network_sup - - ));
DATA(insert OID = 1890 ( "<<" PGUID 0 b t f 20 23 20 0 0 0 0 int8shl - - ));
DATA(insert OID = 1891 ( ">>" PGUID 0 b t f 20 23 20 0 0 0 0 int8shr - - ));
-DATA(insert OID = 1916 ( "+" PGUID 0 l t f 0 20 20 0 0 0 0 int8up - - ));
-DATA(insert OID = 1917 ( "+" PGUID 0 l t f 0 21 21 0 0 0 0 int2up - - ));
-DATA(insert OID = 1918 ( "+" PGUID 0 l t f 0 23 23 0 0 0 0 int4up - - ));
-DATA(insert OID = 1919 ( "+" PGUID 0 l t f 0 700 700 0 0 0 0 float4up - - ));
-DATA(insert OID = 1920 ( "+" PGUID 0 l t f 0 701 701 0 0 0 0 float8up - - ));
-DATA(insert OID = 1921 ( "+" PGUID 0 l t f 0 1700 1700 0 0 0 0 numeric_uplus - - ));
+DATA(insert OID = 1916 ( "+" PGUID 0 l t f 0 20 20 0 0 0 0 int8up - - ));
+DATA(insert OID = 1917 ( "+" PGUID 0 l t f 0 21 21 0 0 0 0 int2up - - ));
+DATA(insert OID = 1918 ( "+" PGUID 0 l t f 0 23 23 0 0 0 0 int4up - - ));
+DATA(insert OID = 1919 ( "+" PGUID 0 l t f 0 700 700 0 0 0 0 float4up - - ));
+DATA(insert OID = 1920 ( "+" PGUID 0 l t f 0 701 701 0 0 0 0 float8up - - ));
+DATA(insert OID = 1921 ( "+" PGUID 0 l t f 0 1700 1700 0 0 0 0 numeric_uplus - - ));
/* bytea operators */
DATA(insert OID = 1955 ( "=" PGUID 0 b t t 17 17 16 1955 1956 1957 1957 byteaeq eqsel eqjoinsel ));
-DATA(insert OID = 1956 ( "<>" PGUID 0 b t f 17 17 16 1956 1955 0 0 byteane neqsel neqjoinsel ));
-DATA(insert OID = 1957 ( "<" PGUID 0 b t f 17 17 16 1959 1960 0 0 bytealt scalarltsel scalarltjoinsel ));
-DATA(insert OID = 1958 ( "<=" PGUID 0 b t f 17 17 16 1960 1959 0 0 byteale scalarltsel scalarltjoinsel ));
-DATA(insert OID = 1959 ( ">" PGUID 0 b t f 17 17 16 1957 1958 0 0 byteagt scalargtsel scalargtjoinsel ));
-DATA(insert OID = 1960 ( ">=" PGUID 0 b t f 17 17 16 1958 1957 0 0 byteage scalargtsel scalargtjoinsel ));
-DATA(insert OID = 2016 ( "~~" PGUID 0 b t f 17 17 16 0 2017 0 0 bytealike likesel likejoinsel ));
+DATA(insert OID = 1956 ( "<>" PGUID 0 b t f 17 17 16 1956 1955 0 0 byteane neqsel neqjoinsel ));
+DATA(insert OID = 1957 ( "<" PGUID 0 b t f 17 17 16 1959 1960 0 0 bytealt scalarltsel scalarltjoinsel ));
+DATA(insert OID = 1958 ( "<=" PGUID 0 b t f 17 17 16 1960 1959 0 0 byteale scalarltsel scalarltjoinsel ));
+DATA(insert OID = 1959 ( ">" PGUID 0 b t f 17 17 16 1957 1958 0 0 byteagt scalargtsel scalargtjoinsel ));
+DATA(insert OID = 1960 ( ">=" PGUID 0 b t f 17 17 16 1958 1957 0 0 byteage scalargtsel scalargtjoinsel ));
+DATA(insert OID = 2016 ( "~~" PGUID 0 b t f 17 17 16 0 2017 0 0 bytealike likesel likejoinsel ));
#define OID_BYTEA_LIKE_OP 2016
-DATA(insert OID = 2017 ( "!~~" PGUID 0 b t f 17 17 16 0 2016 0 0 byteanlike nlikesel nlikejoinsel ));
-DATA(insert OID = 2018 ( "||" PGUID 0 b t f 17 17 17 0 0 0 0 byteacat - - ));
+DATA(insert OID = 2017 ( "!~~" PGUID 0 b t f 17 17 16 0 2016 0 0 byteanlike nlikesel nlikejoinsel ));
+DATA(insert OID = 2018 ( "||" PGUID 0 b t f 17 17 17 0 0 0 0 byteacat - - ));
/* timestamp operators */
/* name, owner, prec, kind, isleft, canhash, left, right, result, com, negate, lsortop, rsortop, oprcode, operrest, oprjoin */
bool canHash,
char *leftSortName,
char *rightSortName);
-
#endif /* PG_OPERATOR_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_proc.h,v 1.217 2001/10/18 17:30:15 thomas Exp $
+ * $Id: pg_proc.h,v 1.218 2001/10/25 05:49:57 momjian Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
DATA(insert OID = 1242 ( boolin PGUID 12 f t t t 1 f 16 "0" 100 0 0 100 boolin - ));
DESCR("(internal)");
-DATA(insert OID = 1243 ( boolout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 boolout - ));
+DATA(insert OID = 1243 ( boolout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 boolout - ));
DESCR("(internal)");
-DATA(insert OID = 1244 ( byteain PGUID 12 f t t t 1 f 17 "0" 100 0 0 100 byteain - ));
+DATA(insert OID = 1244 ( byteain PGUID 12 f t t t 1 f 17 "0" 100 0 0 100 byteain - ));
DESCR("(internal)");
-DATA(insert OID = 31 ( byteaout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 byteaout - ));
+DATA(insert OID = 31 ( byteaout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 byteaout - ));
DESCR("(internal)");
-DATA(insert OID = 1245 ( charin PGUID 12 f t t t 1 f 18 "0" 100 0 0 100 charin - ));
+DATA(insert OID = 1245 ( charin PGUID 12 f t t t 1 f 18 "0" 100 0 0 100 charin - ));
DESCR("(internal)");
-DATA(insert OID = 33 ( charout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 charout - ));
+DATA(insert OID = 33 ( charout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 charout - ));
DESCR("(internal)");
-DATA(insert OID = 34 ( namein PGUID 12 f t t t 1 f 19 "0" 100 0 0 100 namein - ));
+DATA(insert OID = 34 ( namein PGUID 12 f t t t 1 f 19 "0" 100 0 0 100 namein - ));
DESCR("(internal)");
-DATA(insert OID = 35 ( nameout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 nameout - ));
+DATA(insert OID = 35 ( nameout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 nameout - ));
DESCR("(internal)");
-DATA(insert OID = 38 ( int2in PGUID 12 f t t t 1 f 21 "0" 100 0 0 100 int2in - ));
+DATA(insert OID = 38 ( int2in PGUID 12 f t t t 1 f 21 "0" 100 0 0 100 int2in - ));
DESCR("(internal)");
-DATA(insert OID = 39 ( int2out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int2out - ));
+DATA(insert OID = 39 ( int2out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int2out - ));
DESCR("(internal)");
-DATA(insert OID = 40 ( int2vectorin PGUID 12 f t t t 1 f 22 "0" 100 0 0 100 int2vectorin - ));
+DATA(insert OID = 40 ( int2vectorin PGUID 12 f t t t 1 f 22 "0" 100 0 0 100 int2vectorin - ));
DESCR("(internal)");
-DATA(insert OID = 41 ( int2vectorout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int2vectorout - ));
+DATA(insert OID = 41 ( int2vectorout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int2vectorout - ));
DESCR("(internal)");
-DATA(insert OID = 42 ( int4in PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int4in - ));
+DATA(insert OID = 42 ( int4in PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int4in - ));
DESCR("(internal)");
-DATA(insert OID = 43 ( int4out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int4out - ));
+DATA(insert OID = 43 ( int4out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int4out - ));
DESCR("(internal)");
-DATA(insert OID = 44 ( regprocin PGUID 12 f t f t 1 f 24 "0" 100 0 0 100 regprocin - ));
+DATA(insert OID = 44 ( regprocin PGUID 12 f t f t 1 f 24 "0" 100 0 0 100 regprocin - ));
DESCR("(internal)");
-DATA(insert OID = 45 ( regprocout PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 regprocout - ));
+DATA(insert OID = 45 ( regprocout PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 regprocout - ));
DESCR("(internal)");
-DATA(insert OID = 46 ( textin PGUID 12 f t t t 1 f 25 "0" 100 0 0 100 textin - ));
+DATA(insert OID = 46 ( textin PGUID 12 f t t t 1 f 25 "0" 100 0 0 100 textin - ));
DESCR("(internal)");
-DATA(insert OID = 47 ( textout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 textout - ));
+DATA(insert OID = 47 ( textout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 textout - ));
DESCR("(internal)");
-DATA(insert OID = 48 ( tidin PGUID 12 f t t t 1 f 27 "0" 100 0 0 100 tidin - ));
+DATA(insert OID = 48 ( tidin PGUID 12 f t t t 1 f 27 "0" 100 0 0 100 tidin - ));
DESCR("(internal)");
-DATA(insert OID = 49 ( tidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 tidout - ));
+DATA(insert OID = 49 ( tidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 tidout - ));
DESCR("(internal)");
-DATA(insert OID = 50 ( xidin PGUID 12 f t t t 1 f 28 "0" 100 0 0 100 xidin - ));
+DATA(insert OID = 50 ( xidin PGUID 12 f t t t 1 f 28 "0" 100 0 0 100 xidin - ));
DESCR("(internal)");
-DATA(insert OID = 51 ( xidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 xidout - ));
+DATA(insert OID = 51 ( xidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 xidout - ));
DESCR("(internal)");
-DATA(insert OID = 52 ( cidin PGUID 12 f t t t 1 f 29 "0" 100 0 0 100 cidin - ));
+DATA(insert OID = 52 ( cidin PGUID 12 f t t t 1 f 29 "0" 100 0 0 100 cidin - ));
DESCR("(internal)");
-DATA(insert OID = 53 ( cidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 cidout - ));
+DATA(insert OID = 53 ( cidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 cidout - ));
DESCR("(internal)");
-DATA(insert OID = 54 ( oidvectorin PGUID 12 f t t t 1 f 30 "0" 100 0 0 100 oidvectorin - ));
+DATA(insert OID = 54 ( oidvectorin PGUID 12 f t t t 1 f 30 "0" 100 0 0 100 oidvectorin - ));
DESCR("(internal)");
-DATA(insert OID = 55 ( oidvectorout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 oidvectorout - ));
+DATA(insert OID = 55 ( oidvectorout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 oidvectorout - ));
DESCR("(internal)");
-DATA(insert OID = 56 ( boollt PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 boollt - ));
+DATA(insert OID = 56 ( boollt PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 boollt - ));
DESCR("less-than");
-DATA(insert OID = 57 ( boolgt PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 boolgt - ));
+DATA(insert OID = 57 ( boolgt PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 boolgt - ));
DESCR("greater-than");
-DATA(insert OID = 60 ( booleq PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 booleq - ));
+DATA(insert OID = 60 ( booleq PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 booleq - ));
DESCR("equal");
-DATA(insert OID = 61 ( chareq PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 chareq - ));
+DATA(insert OID = 61 ( chareq PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 chareq - ));
DESCR("equal");
-DATA(insert OID = 62 ( nameeq PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 nameeq - ));
+DATA(insert OID = 62 ( nameeq PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 nameeq - ));
DESCR("equal");
-DATA(insert OID = 63 ( int2eq PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2eq - ));
+DATA(insert OID = 63 ( int2eq PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2eq - ));
DESCR("equal");
-DATA(insert OID = 64 ( int2lt PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2lt - ));
+DATA(insert OID = 64 ( int2lt PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2lt - ));
DESCR("less-than");
-DATA(insert OID = 65 ( int4eq PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4eq - ));
+DATA(insert OID = 65 ( int4eq PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4eq - ));
DESCR("equal");
-DATA(insert OID = 66 ( int4lt PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4lt - ));
+DATA(insert OID = 66 ( int4lt PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4lt - ));
DESCR("less-than");
-DATA(insert OID = 67 ( texteq PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 texteq - ));
+DATA(insert OID = 67 ( texteq PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 texteq - ));
DESCR("equal");
-DATA(insert OID = 68 ( xideq PGUID 12 f t t t 2 f 16 "28 28" 100 0 0 100 xideq - ));
+DATA(insert OID = 68 ( xideq PGUID 12 f t t t 2 f 16 "28 28" 100 0 0 100 xideq - ));
DESCR("equal");
-DATA(insert OID = 69 ( cideq PGUID 12 f t t t 2 f 16 "29 29" 100 0 0 100 cideq - ));
+DATA(insert OID = 69 ( cideq PGUID 12 f t t t 2 f 16 "29 29" 100 0 0 100 cideq - ));
DESCR("equal");
-DATA(insert OID = 70 ( charne PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charne - ));
+DATA(insert OID = 70 ( charne PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charne - ));
DESCR("not equal");
-DATA(insert OID = 1246 ( charlt PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charlt - ));
+DATA(insert OID = 1246 ( charlt PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charlt - ));
DESCR("less-than");
-DATA(insert OID = 72 ( charle PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charle - ));
+DATA(insert OID = 72 ( charle PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charle - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 73 ( chargt PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 chargt - ));
+DATA(insert OID = 73 ( chargt PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 chargt - ));
DESCR("greater-than");
-DATA(insert OID = 74 ( charge PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charge - ));
+DATA(insert OID = 74 ( charge PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 1248 ( charpl PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 charpl - ));
+DATA(insert OID = 1248 ( charpl PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 charpl - ));
DESCR("add");
-DATA(insert OID = 1250 ( charmi PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 charmi - ));
+DATA(insert OID = 1250 ( charmi PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 charmi - ));
DESCR("subtract");
-DATA(insert OID = 77 ( charmul PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 charmul - ));
+DATA(insert OID = 77 ( charmul PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 charmul - ));
DESCR("multiply");
-DATA(insert OID = 78 ( chardiv PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 chardiv - ));
+DATA(insert OID = 78 ( chardiv PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 chardiv - ));
DESCR("divide");
-DATA(insert OID = 79 ( nameregexeq PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameregexeq - ));
+DATA(insert OID = 79 ( nameregexeq PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameregexeq - ));
DESCR("matches regex., case-sensitive");
-DATA(insert OID = 1252 ( nameregexne PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameregexne - ));
+DATA(insert OID = 1252 ( nameregexne PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameregexne - ));
DESCR("does not match regex., case-sensitive");
-DATA(insert OID = 1254 ( textregexeq PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textregexeq - ));
+DATA(insert OID = 1254 ( textregexeq PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textregexeq - ));
DESCR("matches regex., case-sensitive");
-DATA(insert OID = 1256 ( textregexne PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textregexne - ));
+DATA(insert OID = 1256 ( textregexne PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textregexne - ));
DESCR("does not match regex., case-sensitive");
DATA(insert OID = 1257 ( textlen PGUID 12 f t t t 1 f 23 "25" 100 0 0 100 textlen - ));
DESCR("length");
-DATA(insert OID = 1258 ( textcat PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 textcat - ));
+DATA(insert OID = 1258 ( textcat PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 textcat - ));
DESCR("concatenate");
-DATA(insert OID = 84 ( boolne PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 boolne - ));
+DATA(insert OID = 84 ( boolne PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 boolne - ));
DESCR("not equal");
DATA(insert OID = 89 ( version PGUID 12 f t f t 0 f 25 "" 100 0 0 100 pgsql_version - ));
DESCR("PostgreSQL version string");
DESCR("restriction selectivity for area-comparison operators");
DATA(insert OID = 140 ( areajoinsel PGUID 12 f t f t 3 f 701 "0 26 0" 100 0 0 100 areajoinsel - ));
DESCR("join selectivity for area-comparison operators");
-DATA(insert OID = 141 ( int4mul PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mul - ));
+DATA(insert OID = 141 ( int4mul PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mul - ));
DESCR("multiply");
DATA(insert OID = 142 ( int4fac PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4fac - ));
DESCR("factorial");
-DATA(insert OID = 144 ( int4ne PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4ne - ));
+DATA(insert OID = 144 ( int4ne PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4ne - ));
DESCR("not equal");
-DATA(insert OID = 145 ( int2ne PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2ne - ));
+DATA(insert OID = 145 ( int2ne PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2ne - ));
DESCR("not equal");
-DATA(insert OID = 146 ( int2gt PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2gt - ));
+DATA(insert OID = 146 ( int2gt PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2gt - ));
DESCR("greater-than");
-DATA(insert OID = 147 ( int4gt PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4gt - ));
+DATA(insert OID = 147 ( int4gt PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4gt - ));
DESCR("greater-than");
-DATA(insert OID = 148 ( int2le PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2le - ));
+DATA(insert OID = 148 ( int2le PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 149 ( int4le PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4le - ));
+DATA(insert OID = 149 ( int4le PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 150 ( int4ge PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4ge - ));
+DATA(insert OID = 150 ( int4ge PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4ge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 151 ( int2ge PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2ge - ));
+DATA(insert OID = 151 ( int2ge PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2ge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 152 ( int2mul PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mul - ));
+DATA(insert OID = 152 ( int2mul PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mul - ));
DESCR("multiply");
-DATA(insert OID = 153 ( int2div PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2div - ));
+DATA(insert OID = 153 ( int2div PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2div - ));
DESCR("divide");
-DATA(insert OID = 154 ( int4div PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4div - ));
+DATA(insert OID = 154 ( int4div PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4div - ));
DESCR("divide");
-DATA(insert OID = 155 ( int2mod PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mod - ));
+DATA(insert OID = 155 ( int2mod PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mod - ));
DESCR("modulus");
-DATA(insert OID = 156 ( int4mod PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mod - ));
+DATA(insert OID = 156 ( int4mod PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mod - ));
DESCR("modulus");
-DATA(insert OID = 157 ( textne PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textne - ));
+DATA(insert OID = 157 ( textne PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textne - ));
DESCR("not equal");
-DATA(insert OID = 158 ( int24eq PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24eq - ));
+DATA(insert OID = 158 ( int24eq PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24eq - ));
DESCR("equal");
-DATA(insert OID = 159 ( int42eq PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42eq - ));
+DATA(insert OID = 159 ( int42eq PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42eq - ));
DESCR("equal");
-DATA(insert OID = 160 ( int24lt PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24lt - ));
+DATA(insert OID = 160 ( int24lt PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24lt - ));
DESCR("less-than");
-DATA(insert OID = 161 ( int42lt PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42lt - ));
+DATA(insert OID = 161 ( int42lt PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42lt - ));
DESCR("less-than");
-DATA(insert OID = 162 ( int24gt PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24gt - ));
+DATA(insert OID = 162 ( int24gt PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24gt - ));
DESCR("greater-than");
-DATA(insert OID = 163 ( int42gt PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42gt - ));
+DATA(insert OID = 163 ( int42gt PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42gt - ));
DESCR("greater-than");
-DATA(insert OID = 164 ( int24ne PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24ne - ));
+DATA(insert OID = 164 ( int24ne PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24ne - ));
DESCR("not equal");
-DATA(insert OID = 165 ( int42ne PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42ne - ));
+DATA(insert OID = 165 ( int42ne PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42ne - ));
DESCR("not equal");
-DATA(insert OID = 166 ( int24le PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24le - ));
+DATA(insert OID = 166 ( int24le PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 167 ( int42le PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42le - ));
+DATA(insert OID = 167 ( int42le PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 168 ( int24ge PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24ge - ));
+DATA(insert OID = 168 ( int24ge PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24ge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 169 ( int42ge PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42ge - ));
+DATA(insert OID = 169 ( int42ge PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42ge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 170 ( int24mul PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mul - ));
+DATA(insert OID = 170 ( int24mul PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mul - ));
DESCR("multiply");
-DATA(insert OID = 171 ( int42mul PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mul - ));
+DATA(insert OID = 171 ( int42mul PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mul - ));
DESCR("multiply");
-DATA(insert OID = 172 ( int24div PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24div - ));
+DATA(insert OID = 172 ( int24div PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24div - ));
DESCR("divide");
-DATA(insert OID = 173 ( int42div PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42div - ));
+DATA(insert OID = 173 ( int42div PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42div - ));
DESCR("divide");
-DATA(insert OID = 174 ( int24mod PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mod - ));
+DATA(insert OID = 174 ( int24mod PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mod - ));
DESCR("modulus");
-DATA(insert OID = 175 ( int42mod PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mod - ));
+DATA(insert OID = 175 ( int42mod PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mod - ));
DESCR("modulus");
-DATA(insert OID = 176 ( int2pl PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2pl - ));
+DATA(insert OID = 176 ( int2pl PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2pl - ));
DESCR("add");
-DATA(insert OID = 177 ( int4pl PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4pl - ));
+DATA(insert OID = 177 ( int4pl PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4pl - ));
DESCR("add");
-DATA(insert OID = 178 ( int24pl PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24pl - ));
+DATA(insert OID = 178 ( int24pl PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24pl - ));
DESCR("add");
-DATA(insert OID = 179 ( int42pl PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42pl - ));
+DATA(insert OID = 179 ( int42pl PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42pl - ));
DESCR("add");
-DATA(insert OID = 180 ( int2mi PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mi - ));
+DATA(insert OID = 180 ( int2mi PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mi - ));
DESCR("subtract");
-DATA(insert OID = 181 ( int4mi PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mi - ));
+DATA(insert OID = 181 ( int4mi PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mi - ));
DESCR("subtract");
-DATA(insert OID = 182 ( int24mi PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mi - ));
+DATA(insert OID = 182 ( int24mi PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mi - ));
DESCR("subtract");
-DATA(insert OID = 183 ( int42mi PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mi - ));
+DATA(insert OID = 183 ( int42mi PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mi - ));
DESCR("subtract");
-DATA(insert OID = 184 ( oideq PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oideq - ));
+DATA(insert OID = 184 ( oideq PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oideq - ));
DESCR("equal");
-DATA(insert OID = 185 ( oidne PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidne - ));
+DATA(insert OID = 185 ( oidne PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidne - ));
DESCR("not equal");
DATA(insert OID = 186 ( box_same PGUID 12 f t t t 2 f 16 "603 603" 100 0 0 100 box_same - ));
DESCR("same as");
DESCR("start of interval");
DATA(insert OID = 273 ( tintervalend PGUID 12 f t t t 1 f 702 "704" 100 0 0 100 tintervalend - ));
DESCR("");
-DATA(insert OID = 274 ( timeofday PGUID 12 f t f t 0 f 25 "0" 100 0 0 100 timeofday - ));
+DATA(insert OID = 274 ( timeofday PGUID 12 f t f t 0 f 25 "0" 100 0 0 100 timeofday - ));
DESCR("Current date and time with microseconds");
DATA(insert OID = 275 ( isfinite PGUID 12 f t t t 1 f 16 "702" 100 0 0 100 abstime_finite - ));
DESCR("");
DATA(insert OID = 319 ( int4 PGUID 12 f t t t 1 f 23 "700" 100 0 0 100 ftoi4 - ));
DESCR("convert float4 to int4");
-DATA(insert OID = 320 ( rtinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 rtinsert - ));
+DATA(insert OID = 320 ( rtinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 rtinsert - ));
DESCR("r-tree(internal)");
DATA(insert OID = 322 ( rtgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 rtgettuple - ));
DESCR("r-tree(internal)");
-DATA(insert OID = 323 ( rtbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 rtbuild - ));
+DATA(insert OID = 323 ( rtbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 rtbuild - ));
DESCR("r-tree(internal)");
DATA(insert OID = 324 ( rtbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 rtbeginscan - ));
DESCR("r-tree(internal)");
-DATA(insert OID = 325 ( rtendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtendscan - ));
+DATA(insert OID = 325 ( rtendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtendscan - ));
DESCR("r-tree(internal)");
-DATA(insert OID = 326 ( rtmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtmarkpos - ));
+DATA(insert OID = 326 ( rtmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtmarkpos - ));
DESCR("r-tree(internal)");
-DATA(insert OID = 327 ( rtrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtrestrpos - ));
+DATA(insert OID = 327 ( rtrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtrestrpos - ));
DESCR("r-tree(internal)");
-DATA(insert OID = 328 ( rtrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 rtrescan - ));
+DATA(insert OID = 328 ( rtrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 rtrescan - ));
DESCR("r-tree(internal)");
-DATA(insert OID = 321 ( rtbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 rtbulkdelete - ));
+DATA(insert OID = 321 ( rtbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 rtbulkdelete - ));
DESCR("r-tree(internal)");
DATA(insert OID = 1265 ( rtcostestimate PGUID 12 f t f t 8 f 0 "0 0 0 0 0 0 0 0" 100 0 0 100 rtcostestimate - ));
DESCR("r-tree(internal)");
DATA(insert OID = 330 ( btgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 btgettuple - ));
DESCR("btree(internal)");
-DATA(insert OID = 331 ( btinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 btinsert - ));
+DATA(insert OID = 331 ( btinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 btinsert - ));
DESCR("btree(internal)");
DATA(insert OID = 333 ( btbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 btbeginscan - ));
DESCR("btree(internal)");
-DATA(insert OID = 334 ( btrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 btrescan - ));
+DATA(insert OID = 334 ( btrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 btrescan - ));
DESCR("btree(internal)");
-DATA(insert OID = 335 ( btendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btendscan - ));
+DATA(insert OID = 335 ( btendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btendscan - ));
DESCR("btree(internal)");
-DATA(insert OID = 336 ( btmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btmarkpos - ));
+DATA(insert OID = 336 ( btmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btmarkpos - ));
DESCR("btree(internal)");
-DATA(insert OID = 337 ( btrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btrestrpos - ));
+DATA(insert OID = 337 ( btrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btrestrpos - ));
DESCR("btree(internal)");
-DATA(insert OID = 338 ( btbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 btbuild - ));
+DATA(insert OID = 338 ( btbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 btbuild - ));
DESCR("btree(internal)");
-DATA(insert OID = 332 ( btbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 btbulkdelete - ));
+DATA(insert OID = 332 ( btbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 btbulkdelete - ));
DESCR("btree(internal)");
DATA(insert OID = 1268 ( btcostestimate PGUID 12 f t f t 8 f 0 "0 0 0 0 0 0 0 0" 100 0 0 100 btcostestimate - ));
DESCR("btree(internal)");
DATA(insert OID = 348 ( poly_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 poly_out - ));
DESCR("(internal)");
-DATA(insert OID = 350 ( btint2cmp PGUID 12 f t t t 2 f 23 "21 21" 100 0 0 100 btint2cmp - ));
+DATA(insert OID = 350 ( btint2cmp PGUID 12 f t t t 2 f 23 "21 21" 100 0 0 100 btint2cmp - ));
DESCR("btree less-equal-greater");
-DATA(insert OID = 351 ( btint4cmp PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 btint4cmp - ));
+DATA(insert OID = 351 ( btint4cmp PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 btint4cmp - ));
DESCR("btree less-equal-greater");
-DATA(insert OID = 842 ( btint8cmp PGUID 12 f t t t 2 f 23 "20 20" 100 0 0 100 btint8cmp - ));
+DATA(insert OID = 842 ( btint8cmp PGUID 12 f t t t 2 f 23 "20 20" 100 0 0 100 btint8cmp - ));
DESCR("btree less-equal-greater");
DATA(insert OID = 354 ( btfloat4cmp PGUID 12 f t t t 2 f 23 "700 700" 100 0 0 100 btfloat4cmp - ));
DESCR("btree less-equal-greater");
DATA(insert OID = 355 ( btfloat8cmp PGUID 12 f t t t 2 f 23 "701 701" 100 0 0 100 btfloat8cmp - ));
DESCR("btree less-equal-greater");
-DATA(insert OID = 356 ( btoidcmp PGUID 12 f t t t 2 f 23 "26 26" 100 0 0 100 btoidcmp - ));
+DATA(insert OID = 356 ( btoidcmp PGUID 12 f t t t 2 f 23 "26 26" 100 0 0 100 btoidcmp - ));
DESCR("btree less-equal-greater");
-DATA(insert OID = 404 ( btoidvectorcmp PGUID 12 f t t t 2 f 23 "30 30" 100 0 0 100 btoidvectorcmp - ));
+DATA(insert OID = 404 ( btoidvectorcmp PGUID 12 f t t t 2 f 23 "30 30" 100 0 0 100 btoidvectorcmp - ));
DESCR("btree less-equal-greater");
DATA(insert OID = 357 ( btabstimecmp PGUID 12 f t t t 2 f 23 "702 702" 100 0 0 100 btabstimecmp - ));
DESCR("btree less-equal-greater");
-DATA(insert OID = 358 ( btcharcmp PGUID 12 f t t t 2 f 23 "18 18" 100 0 0 100 btcharcmp - ));
+DATA(insert OID = 358 ( btcharcmp PGUID 12 f t t t 2 f 23 "18 18" 100 0 0 100 btcharcmp - ));
DESCR("btree less-equal-greater");
-DATA(insert OID = 359 ( btnamecmp PGUID 12 f t t t 2 f 23 "19 19" 100 0 0 100 btnamecmp - ));
+DATA(insert OID = 359 ( btnamecmp PGUID 12 f t t t 2 f 23 "19 19" 100 0 0 100 btnamecmp - ));
DESCR("btree less-equal-greater");
-DATA(insert OID = 360 ( bttextcmp PGUID 12 f t t t 2 f 23 "25 25" 100 0 0 100 bttextcmp - ));
+DATA(insert OID = 360 ( bttextcmp PGUID 12 f t t t 2 f 23 "25 25" 100 0 0 100 bttextcmp - ));
DESCR("btree less-equal-greater");
DATA(insert OID = 361 ( lseg_distance PGUID 12 f t t t 2 f 701 "601 601" 100 0 0 100 lseg_distance - ));
DATA(insert OID = 440 ( hashgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 hashgettuple - ));
DESCR("hash(internal)");
-DATA(insert OID = 441 ( hashinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 hashinsert - ));
+DATA(insert OID = 441 ( hashinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 hashinsert - ));
DESCR("hash(internal)");
DATA(insert OID = 443 ( hashbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 hashbeginscan - ));
DESCR("hash(internal)");
-DATA(insert OID = 444 ( hashrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 hashrescan - ));
+DATA(insert OID = 444 ( hashrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 hashrescan - ));
DESCR("hash(internal)");
-DATA(insert OID = 445 ( hashendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashendscan - ));
+DATA(insert OID = 445 ( hashendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashendscan - ));
DESCR("hash(internal)");
-DATA(insert OID = 446 ( hashmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashmarkpos - ));
+DATA(insert OID = 446 ( hashmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashmarkpos - ));
DESCR("hash(internal)");
-DATA(insert OID = 447 ( hashrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashrestrpos - ));
+DATA(insert OID = 447 ( hashrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashrestrpos - ));
DESCR("hash(internal)");
-DATA(insert OID = 448 ( hashbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 hashbuild - ));
+DATA(insert OID = 448 ( hashbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 hashbuild - ));
DESCR("hash(internal)");
-DATA(insert OID = 442 ( hashbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 hashbulkdelete - ));
+DATA(insert OID = 442 ( hashbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 hashbulkdelete - ));
DESCR("hash(internal)");
DATA(insert OID = 438 ( hashcostestimate PGUID 12 f t f t 8 f 0 "0 0 0 0 0 0 0 0" 100 0 0 100 hashcostestimate - ));
DESCR("hash(internal)");
DESCR("hash");
DATA(insert OID = 455 ( hashname PGUID 12 f t t t 1 f 23 "19" 100 0 0 100 hashname - ));
DESCR("hash");
-DATA(insert OID = 456 ( hashvarlena PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 hashvarlena - ));
+DATA(insert OID = 456 ( hashvarlena PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 hashvarlena - ));
DESCR("hash any varlena type");
DATA(insert OID = 457 ( hashoidvector PGUID 12 f t t t 1 f 23 "30" 100 0 0 100 hashoidvector - ));
DESCR("hash");
DATA(insert OID = 399 ( hashmacaddr PGUID 12 f t t t 1 f 23 "829" 100 0 0 100 hashmacaddr - ));
DESCR("hash");
-DATA(insert OID = 458 ( text_larger PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 text_larger - ));
+DATA(insert OID = 458 ( text_larger PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 text_larger - ));
DESCR("larger of two");
-DATA(insert OID = 459 ( text_smaller PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 text_smaller - ));
+DATA(insert OID = 459 ( text_smaller PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 text_smaller - ));
DESCR("smaller of two");
-DATA(insert OID = 460 ( int8in PGUID 12 f t t t 1 f 20 "0" 100 0 0 100 int8in - ));
+DATA(insert OID = 460 ( int8in PGUID 12 f t t t 1 f 20 "0" 100 0 0 100 int8in - ));
DESCR("(internal)");
-DATA(insert OID = 461 ( int8out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int8out - ));
+DATA(insert OID = 461 ( int8out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int8out - ));
DESCR("(internal)");
DATA(insert OID = 462 ( int8um PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8um - ));
DESCR("negate");
-DATA(insert OID = 463 ( int8pl PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8pl - ));
+DATA(insert OID = 463 ( int8pl PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8pl - ));
DESCR("add");
-DATA(insert OID = 464 ( int8mi PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mi - ));
+DATA(insert OID = 464 ( int8mi PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mi - ));
DESCR("subtract");
-DATA(insert OID = 465 ( int8mul PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mul - ));
+DATA(insert OID = 465 ( int8mul PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mul - ));
DESCR("multiply");
-DATA(insert OID = 466 ( int8div PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8div - ));
+DATA(insert OID = 466 ( int8div PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8div - ));
DESCR("divide");
-DATA(insert OID = 467 ( int8eq PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8eq - ));
+DATA(insert OID = 467 ( int8eq PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8eq - ));
DESCR("equal");
-DATA(insert OID = 468 ( int8ne PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8ne - ));
+DATA(insert OID = 468 ( int8ne PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8ne - ));
DESCR("not equal");
-DATA(insert OID = 469 ( int8lt PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8lt - ));
+DATA(insert OID = 469 ( int8lt PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8lt - ));
DESCR("less-than");
-DATA(insert OID = 470 ( int8gt PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8gt - ));
+DATA(insert OID = 470 ( int8gt PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8gt - ));
DESCR("greater-than");
-DATA(insert OID = 471 ( int8le PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8le - ));
+DATA(insert OID = 471 ( int8le PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 472 ( int8ge PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8ge - ));
+DATA(insert OID = 472 ( int8ge PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8ge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 474 ( int84eq PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84eq - ));
+DATA(insert OID = 474 ( int84eq PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84eq - ));
DESCR("equal");
-DATA(insert OID = 475 ( int84ne PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84ne - ));
+DATA(insert OID = 475 ( int84ne PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84ne - ));
DESCR("not equal");
-DATA(insert OID = 476 ( int84lt PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84lt - ));
+DATA(insert OID = 476 ( int84lt PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84lt - ));
DESCR("less-than");
-DATA(insert OID = 477 ( int84gt PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84gt - ));
+DATA(insert OID = 477 ( int84gt PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84gt - ));
DESCR("greater-than");
-DATA(insert OID = 478 ( int84le PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84le - ));
+DATA(insert OID = 478 ( int84le PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 479 ( int84ge PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84ge - ));
+DATA(insert OID = 479 ( int84ge PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84ge - ));
DESCR("greater-than-or-equal");
DATA(insert OID = 480 ( int4 PGUID 12 f t t t 1 f 23 "20" 100 0 0 100 int84 - ));
/* OIDS 600 - 699 */
-DATA(insert OID = 1285 ( int4notin PGUID 12 f t f t 2 f 16 "23 25" 100 0 0 100 int4notin - ));
+DATA(insert OID = 1285 ( int4notin PGUID 12 f t f t 2 f 16 "23 25" 100 0 0 100 int4notin - ));
DESCR("not in");
-DATA(insert OID = 1286 ( oidnotin PGUID 12 f t f t 2 f 16 "26 25" 100 0 0 100 oidnotin - ));
+DATA(insert OID = 1286 ( oidnotin PGUID 12 f t f t 2 f 16 "26 25" 100 0 0 100 oidnotin - ));
DESCR("not in");
-DATA(insert OID = 1287 ( int44in PGUID 12 f t t t 1 f 22 "0" 100 0 0 100 int44in - ));
+DATA(insert OID = 1287 ( int44in PGUID 12 f t t t 1 f 22 "0" 100 0 0 100 int44in - ));
DESCR("(internal)");
-DATA(insert OID = 653 ( int44out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int44out - ));
+DATA(insert OID = 653 ( int44out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int44out - ));
DESCR("(internal)");
-DATA(insert OID = 655 ( namelt PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namelt - ));
+DATA(insert OID = 655 ( namelt PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namelt - ));
DESCR("less-than");
-DATA(insert OID = 656 ( namele PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namele - ));
+DATA(insert OID = 656 ( namele PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namele - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 657 ( namegt PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namegt - ));
+DATA(insert OID = 657 ( namegt PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namegt - ));
DESCR("greater-than");
-DATA(insert OID = 658 ( namege PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namege - ));
+DATA(insert OID = 658 ( namege PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namege - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 659 ( namene PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namene - ));
+DATA(insert OID = 659 ( namene PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namene - ));
DESCR("not equal");
-DATA(insert OID = 668 ( bpchar PGUID 12 f t t t 2 f 1042 "1042 23" 100 0 0 100 bpchar - ));
+DATA(insert OID = 668 ( bpchar PGUID 12 f t t t 2 f 1042 "1042 23" 100 0 0 100 bpchar - ));
DESCR("adjust char() to typmod length");
-DATA(insert OID = 669 ( varchar PGUID 12 f t t t 2 f 1043 "1043 23" 100 0 0 100 varchar - ));
+DATA(insert OID = 669 ( varchar PGUID 12 f t t t 2 f 1043 "1043 23" 100 0 0 100 varchar - ));
DESCR("adjust varchar() to typmod length");
DATA(insert OID = 676 ( mktinterval PGUID 12 f t t t 2 f 704 "702 702" 100 0 0 100 mktinterval - ));
DESCR("convert to tinterval");
-DATA(insert OID = 619 ( oidvectorne PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorne - ));
+DATA(insert OID = 619 ( oidvectorne PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorne - ));
DESCR("not equal");
-DATA(insert OID = 677 ( oidvectorlt PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorlt - ));
+DATA(insert OID = 677 ( oidvectorlt PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorlt - ));
DESCR("less-than");
-DATA(insert OID = 678 ( oidvectorle PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorle - ));
+DATA(insert OID = 678 ( oidvectorle PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorle - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 679 ( oidvectoreq PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectoreq - ));
+DATA(insert OID = 679 ( oidvectoreq PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectoreq - ));
DESCR("equal");
-DATA(insert OID = 680 ( oidvectorge PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorge - ));
+DATA(insert OID = 680 ( oidvectorge PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 681 ( oidvectorgt PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorgt - ));
+DATA(insert OID = 681 ( oidvectorgt PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorgt - ));
DESCR("greater-than");
/* OIDS 700 - 799 */
-DATA(insert OID = 710 ( getpgusername PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 current_user - ));
+DATA(insert OID = 710 ( getpgusername PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 current_user - ));
DESCR("deprecated -- use current_user");
DATA(insert OID = 711 ( userfntest PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 userfntest - ));
DESCR("");
-DATA(insert OID = 713 ( oidrand PGUID 12 f t f t 2 f 16 "26 23" 100 0 0 100 oidrand - ));
+DATA(insert OID = 713 ( oidrand PGUID 12 f t f t 2 f 16 "26 23" 100 0 0 100 oidrand - ));
DESCR("random");
DATA(insert OID = 715 ( oidsrand PGUID 12 f t f t 1 f 16 "23" 100 0 0 100 oidsrand - ));
DESCR("seed random number generator");
-DATA(insert OID = 716 ( oidlt PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidlt - ));
+DATA(insert OID = 716 ( oidlt PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidlt - ));
DESCR("less-than");
-DATA(insert OID = 717 ( oidle PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidle - ));
+DATA(insert OID = 717 ( oidle PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidle - ));
DESCR("less-than-or-equal");
DATA(insert OID = 720 ( octet_length PGUID 12 f t t t 1 f 23 "17" 100 0 0 100 byteaoctetlen - ));
DESCR("octet length");
-DATA(insert OID = 721 ( get_byte PGUID 12 f t t t 2 f 23 "17 23" 100 0 0 100 byteaGetByte - ));
+DATA(insert OID = 721 ( get_byte PGUID 12 f t t t 2 f 23 "17 23" 100 0 0 100 byteaGetByte - ));
DESCR("");
DATA(insert OID = 722 ( set_byte PGUID 12 f t t t 3 f 17 "17 23 23" 100 0 0 100 byteaSetByte - ));
DESCR("");
-DATA(insert OID = 723 ( get_bit PGUID 12 f t t t 2 f 23 "17 23" 100 0 0 100 byteaGetBit - ));
+DATA(insert OID = 723 ( get_bit PGUID 12 f t t t 2 f 23 "17 23" 100 0 0 100 byteaGetBit - ));
DESCR("");
DATA(insert OID = 724 ( set_bit PGUID 12 f t t t 3 f 17 "17 23 23" 100 0 0 100 byteaSetBit - ));
DESCR("");
DATA(insert OID = 729 ( poly_distance PGUID 12 f t t t 2 f 701 "604 604" 100 0 0 100 poly_distance - ));
DESCR("distance between");
-DATA(insert OID = 740 ( text_lt PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_lt - ));
+DATA(insert OID = 740 ( text_lt PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_lt - ));
DESCR("less-than");
-DATA(insert OID = 741 ( text_le PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_le - ));
+DATA(insert OID = 741 ( text_le PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 742 ( text_gt PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_gt - ));
+DATA(insert OID = 742 ( text_gt PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_gt - ));
DESCR("greater-than");
-DATA(insert OID = 743 ( text_ge PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_ge - ));
+DATA(insert OID = 743 ( text_ge PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_ge - ));
DESCR("greater-than-or-equal");
DATA(insert OID = 744 ( array_eq PGUID 12 f t t t 2 f 16 "0 0" 100 0 0 100 array_eq -));
DESCR("array equal");
-DATA(insert OID = 745 ( current_user PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 current_user - ));
+DATA(insert OID = 745 ( current_user PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 current_user - ));
DESCR("current user name");
-DATA(insert OID = 746 ( session_user PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 session_user - ));
+DATA(insert OID = 746 ( session_user PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 session_user - ));
DESCR("session user name");
DATA(insert OID = 747 ( array_dims PGUID 12 f t t t 1 f 25 "0" 100 0 0 100 array_dims -));
DATA(insert OID = 764 ( lo_import PGUID 12 f t f t 1 f 26 "25" 100 0 0 100 lo_import - ));
DESCR("large object import");
-DATA(insert OID = 765 ( lo_export PGUID 12 f t f t 2 f 23 "26 25" 100 0 0 100 lo_export - ));
+DATA(insert OID = 765 ( lo_export PGUID 12 f t f t 2 f 23 "26 25" 100 0 0 100 lo_export - ));
DESCR("large object export");
DATA(insert OID = 766 ( int4inc PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4inc - ));
DESCR("increment");
-DATA(insert OID = 768 ( int4larger PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4larger - ));
+DATA(insert OID = 768 ( int4larger PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4larger - ));
DESCR("larger of two");
-DATA(insert OID = 769 ( int4smaller PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4smaller - ));
+DATA(insert OID = 769 ( int4smaller PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4smaller - ));
DESCR("smaller of two");
-DATA(insert OID = 770 ( int2larger PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2larger - ));
+DATA(insert OID = 770 ( int2larger PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2larger - ));
DESCR("larger of two");
-DATA(insert OID = 771 ( int2smaller PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2smaller - ));
+DATA(insert OID = 771 ( int2smaller PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2smaller - ));
DESCR("smaller of two");
DATA(insert OID = 774 ( gistgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 gistgettuple - ));
DESCR("gist(internal)");
-DATA(insert OID = 775 ( gistinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 gistinsert - ));
+DATA(insert OID = 775 ( gistinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 gistinsert - ));
DESCR("gist(internal)");
DATA(insert OID = 777 ( gistbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 gistbeginscan - ));
DESCR("gist(internal)");
-DATA(insert OID = 778 ( gistrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 gistrescan - ));
+DATA(insert OID = 778 ( gistrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 gistrescan - ));
DESCR("gist(internal)");
-DATA(insert OID = 779 ( gistendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistendscan - ));
+DATA(insert OID = 779 ( gistendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistendscan - ));
DESCR("gist(internal)");
-DATA(insert OID = 780 ( gistmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistmarkpos - ));
+DATA(insert OID = 780 ( gistmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistmarkpos - ));
DESCR("gist(internal)");
-DATA(insert OID = 781 ( gistrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistrestrpos - ));
+DATA(insert OID = 781 ( gistrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistrestrpos - ));
DESCR("gist(internal)");
-DATA(insert OID = 782 ( gistbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 gistbuild - ));
+DATA(insert OID = 782 ( gistbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 gistbuild - ));
DESCR("gist(internal)");
-DATA(insert OID = 776 ( gistbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 gistbulkdelete - ));
+DATA(insert OID = 776 ( gistbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 gistbulkdelete - ));
DESCR("gist(internal)");
DATA(insert OID = 772 ( gistcostestimate PGUID 12 f t f t 8 f 0 "0 0 0 0 0 0 0 0" 100 0 0 100 gistcostestimate - ));
DESCR("gist(internal)");
DATA(insert OID = 851 ( textnlike PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textnlike - ));
DESCR("does not match LIKE expression");
-DATA(insert OID = 852 ( int48eq PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48eq - ));
+DATA(insert OID = 852 ( int48eq PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48eq - ));
DESCR("equal");
-DATA(insert OID = 853 ( int48ne PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48ne - ));
+DATA(insert OID = 853 ( int48ne PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48ne - ));
DESCR("not equal");
-DATA(insert OID = 854 ( int48lt PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48lt - ));
+DATA(insert OID = 854 ( int48lt PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48lt - ));
DESCR("less-than");
-DATA(insert OID = 855 ( int48gt PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48gt - ));
+DATA(insert OID = 855 ( int48gt PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48gt - ));
DESCR("greater-than");
-DATA(insert OID = 856 ( int48le PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48le - ));
+DATA(insert OID = 856 ( int48le PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 857 ( int48ge PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48ge - ));
+DATA(insert OID = 857 ( int48ge PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48ge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 858 ( namelike PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 namelike - ));
+DATA(insert OID = 858 ( namelike PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 namelike - ));
DESCR("matches LIKE expression");
-DATA(insert OID = 859 ( namenlike PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 namenlike - ));
+DATA(insert OID = 859 ( namenlike PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 namenlike - ));
DESCR("does not match LIKE expression");
DATA(insert OID = 860 ( bpchar PGUID 12 f t t t 1 f 1042 "18" 100 0 0 100 char_bpchar - ));
DESCR("add");
DATA(insert OID = 895 ( cash_mi PGUID 12 f t t t 2 f 790 "790 790" 100 0 0 100 cash_mi - ));
DESCR("subtract");
-DATA(insert OID = 896 ( cash_mul_flt8 PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100 cash_mul_flt8 - ));
+DATA(insert OID = 896 ( cash_mul_flt8 PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100 cash_mul_flt8 - ));
DESCR("multiply");
-DATA(insert OID = 897 ( cash_div_flt8 PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100 cash_div_flt8 - ));
+DATA(insert OID = 897 ( cash_div_flt8 PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100 cash_div_flt8 - ));
DESCR("divide");
DATA(insert OID = 898 ( cashlarger PGUID 12 f t t t 2 f 790 "790 790" 100 0 0 100 cashlarger - ));
DESCR("larger of two");
/* OIDS 900 - 999 */
-DATA(insert OID = 940 ( mod PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mod - ));
+DATA(insert OID = 940 ( mod PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mod - ));
DESCR("modulus");
-DATA(insert OID = 941 ( mod PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mod - ));
+DATA(insert OID = 941 ( mod PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mod - ));
DESCR("modulus");
-DATA(insert OID = 942 ( mod PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mod - ));
+DATA(insert OID = 942 ( mod PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mod - ));
DESCR("modulus");
-DATA(insert OID = 943 ( mod PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mod - ));
+DATA(insert OID = 943 ( mod PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mod - ));
DESCR("modulus");
-DATA(insert OID = 945 ( int8mod PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mod - ));
+DATA(insert OID = 945 ( int8mod PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mod - ));
DESCR("modulus");
-DATA(insert OID = 947 ( mod PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mod - ));
+DATA(insert OID = 947 ( mod PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mod - ));
DESCR("modulus");
DATA(insert OID = 944 ( char PGUID 12 f t t t 1 f 18 "25" 100 0 0 100 text_char - ));
DATA(insert OID = 951 ( isfalse PGUID 12 f t t f 1 f 16 "16" 100 0 0 100 isfalse - ));
DESCR("bool is false (not true or unknown)");
-DATA(insert OID = 952 ( lo_open PGUID 12 f t f t 2 f 23 "26 23" 100 0 0 100 lo_open - ));
+DATA(insert OID = 952 ( lo_open PGUID 12 f t f t 2 f 23 "26 23" 100 0 0 100 lo_open - ));
DESCR("large object open");
DATA(insert OID = 953 ( lo_close PGUID 12 f t f t 1 f 23 "23" 100 0 0 100 lo_close - ));
DESCR("large object close");
-DATA(insert OID = 954 ( loread PGUID 12 f t f t 2 f 17 "23 23" 100 0 0 100 loread - ));
+DATA(insert OID = 954 ( loread PGUID 12 f t f t 2 f 17 "23 23" 100 0 0 100 loread - ));
DESCR("large object read");
-DATA(insert OID = 955 ( lowrite PGUID 12 f t f t 2 f 23 "23 17" 100 0 0 100 lowrite - ));
+DATA(insert OID = 955 ( lowrite PGUID 12 f t f t 2 f 23 "23 17" 100 0 0 100 lowrite - ));
DESCR("large object write");
DATA(insert OID = 956 ( lo_lseek PGUID 12 f t f t 3 f 23 "23 23 23" 100 0 0 100 lo_lseek - ));
DESCR("large object seek");
/* OIDS 1000 - 1999 */
-DATA(insert OID = 1026 ( timezone PGUID 12 f t f t 2 f 25 "1186 1184" 100 0 0 100 timestamptz_izone - ));
+DATA(insert OID = 1026 ( timezone PGUID 12 f t f t 2 f 25 "1186 1184" 100 0 0 100 timestamptz_izone - ));
DESCR("time zone");
-DATA(insert OID = 1029 ( nullvalue PGUID 12 f t t f 1 f 16 "0" 100 0 0 100 nullvalue - ));
+DATA(insert OID = 1029 ( nullvalue PGUID 12 f t t f 1 f 16 "0" 100 0 0 100 nullvalue - ));
DESCR("(internal)");
-DATA(insert OID = 1030 ( nonnullvalue PGUID 12 f t t f 1 f 16 "0" 100 0 0 100 nonnullvalue - ));
+DATA(insert OID = 1030 ( nonnullvalue PGUID 12 f t t f 1 f 16 "0" 100 0 0 100 nonnullvalue - ));
DESCR("(internal)");
DATA(insert OID = 1031 ( aclitemin PGUID 12 f t f t 1 f 1033 "0" 100 0 0 100 aclitemin - ));
DESCR("(internal)");
DESCR("add/update ACL item");
DATA(insert OID = 1036 ( aclremove PGUID 12 f t f t 2 f 1034 "1034 1033" 100 0 0 100 aclremove - ));
DESCR("remove ACL item");
-DATA(insert OID = 1037 ( aclcontains PGUID 12 f t f t 2 f 16 "1034 1033" 100 0 0 100 aclcontains - ));
+DATA(insert OID = 1037 ( aclcontains PGUID 12 f t f t 2 f 16 "1034 1033" 100 0 0 100 aclcontains - ));
DESCR("does ACL contain item?");
DATA(insert OID = 1038 ( seteval PGUID 12 f t f t 1 t 23 "26" 100 0 0 100 seteval - ));
DESCR("internal function supporting PostQuel-style sets");
DATA(insert OID = 1044 ( bpcharin PGUID 12 f t t t 3 f 1042 "0 26 23" 100 0 0 100 bpcharin - ));
DESCR("(internal)");
-DATA(insert OID = 1045 ( bpcharout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 bpcharout - ));
+DATA(insert OID = 1045 ( bpcharout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 bpcharout - ));
DESCR("(internal)");
DATA(insert OID = 1046 ( varcharin PGUID 12 f t t t 3 f 1043 "0 26 23" 100 0 0 100 varcharin - ));
DESCR("(internal)");
-DATA(insert OID = 1047 ( varcharout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 varcharout - ));
+DATA(insert OID = 1047 ( varcharout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 varcharout - ));
DESCR("(internal)");
-DATA(insert OID = 1048 ( bpchareq PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpchareq - ));
+DATA(insert OID = 1048 ( bpchareq PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpchareq - ));
DESCR("equal");
-DATA(insert OID = 1049 ( bpcharlt PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharlt - ));
+DATA(insert OID = 1049 ( bpcharlt PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharlt - ));
DESCR("less-than");
-DATA(insert OID = 1050 ( bpcharle PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharle - ));
+DATA(insert OID = 1050 ( bpcharle PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharle - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 1051 ( bpchargt PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpchargt - ));
+DATA(insert OID = 1051 ( bpchargt PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpchargt - ));
DESCR("greater-than");
-DATA(insert OID = 1052 ( bpcharge PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharge - ));
+DATA(insert OID = 1052 ( bpcharge PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 1053 ( bpcharne PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharne - ));
+DATA(insert OID = 1053 ( bpcharne PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharne - ));
DESCR("not equal");
-DATA(insert OID = 1070 ( varchareq PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varchareq - ));
+DATA(insert OID = 1070 ( varchareq PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varchareq - ));
DESCR("equal");
-DATA(insert OID = 1071 ( varcharlt PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharlt - ));
+DATA(insert OID = 1071 ( varcharlt PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharlt - ));
DESCR("less-than");
-DATA(insert OID = 1072 ( varcharle PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharle - ));
+DATA(insert OID = 1072 ( varcharle PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharle - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 1073 ( varchargt PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varchargt - ));
+DATA(insert OID = 1073 ( varchargt PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varchargt - ));
DESCR("greater-than");
-DATA(insert OID = 1074 ( varcharge PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharge - ));
+DATA(insert OID = 1074 ( varcharge PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 1075 ( varcharne PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharne - ));
+DATA(insert OID = 1075 ( varcharne PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharne - ));
DESCR("not equal");
-DATA(insert OID = 1078 ( bpcharcmp PGUID 12 f t t t 2 f 23 "1042 1042" 100 0 0 100 bpcharcmp - ));
+DATA(insert OID = 1078 ( bpcharcmp PGUID 12 f t t t 2 f 23 "1042 1042" 100 0 0 100 bpcharcmp - ));
DESCR("less-equal-greater");
-DATA(insert OID = 1079 ( varcharcmp PGUID 12 f t t t 2 f 23 "1043 1043" 100 0 0 100 varcharcmp - ));
+DATA(insert OID = 1079 ( varcharcmp PGUID 12 f t t t 2 f 23 "1043 1043" 100 0 0 100 varcharcmp - ));
DESCR("less-equal-greater");
DATA(insert OID = 1080 ( hashbpchar PGUID 12 f t t t 1 f 23 "1042" 100 0 0 100 hashbpchar - ));
DESCR("hash");
DESCR("format a type oid and atttypmod to canonical SQL");
DATA(insert OID = 1084 ( date_in PGUID 12 f t f t 1 f 1082 "0" 100 0 0 100 date_in - ));
DESCR("(internal)");
-DATA(insert OID = 1085 ( date_out PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 date_out - ));
+DATA(insert OID = 1085 ( date_out PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 date_out - ));
DESCR("(internal)");
-DATA(insert OID = 1086 ( date_eq PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_eq - ));
+DATA(insert OID = 1086 ( date_eq PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_eq - ));
DESCR("equal");
-DATA(insert OID = 1087 ( date_lt PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_lt - ));
+DATA(insert OID = 1087 ( date_lt PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_lt - ));
DESCR("less-than");
-DATA(insert OID = 1088 ( date_le PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_le - ));
+DATA(insert OID = 1088 ( date_le PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 1089 ( date_gt PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_gt - ));
+DATA(insert OID = 1089 ( date_gt PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_gt - ));
DESCR("greater-than");
-DATA(insert OID = 1090 ( date_ge PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_ge - ));
+DATA(insert OID = 1090 ( date_ge PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_ge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 1091 ( date_ne PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_ne - ));
+DATA(insert OID = 1091 ( date_ne PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_ne - ));
DESCR("not equal");
-DATA(insert OID = 1092 ( date_cmp PGUID 12 f t t t 2 f 23 "1082 1082" 100 0 0 100 date_cmp - ));
+DATA(insert OID = 1092 ( date_cmp PGUID 12 f t t t 2 f 23 "1082 1082" 100 0 0 100 date_cmp - ));
DESCR("less-equal-greater");
/* OIDS 1100 - 1199 */
-DATA(insert OID = 1102 ( time_lt PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_lt - ));
+DATA(insert OID = 1102 ( time_lt PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_lt - ));
DESCR("less-than");
-DATA(insert OID = 1103 ( time_le PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_le - ));
+DATA(insert OID = 1103 ( time_le PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 1104 ( time_gt PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_gt - ));
+DATA(insert OID = 1104 ( time_gt PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_gt - ));
DESCR("greater-than");
-DATA(insert OID = 1105 ( time_ge PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_ge - ));
+DATA(insert OID = 1105 ( time_ge PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_ge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 1106 ( time_ne PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_ne - ));
+DATA(insert OID = 1106 ( time_ne PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_ne - ));
DESCR("not equal");
-DATA(insert OID = 1107 ( time_cmp PGUID 12 f t t t 2 f 23 "1083 1083" 100 0 0 100 time_cmp - ));
+DATA(insert OID = 1107 ( time_cmp PGUID 12 f t t t 2 f 23 "1083 1083" 100 0 0 100 time_cmp - ));
DESCR("less-equal-greater");
DATA(insert OID = 1138 ( date_larger PGUID 12 f t t t 2 f 1082 "1082 1082" 100 0 0 100 date_larger - ));
DESCR("larger of two");
DATA(insert OID = 1139 ( date_smaller PGUID 12 f t t t 2 f 1082 "1082 1082" 100 0 0 100 date_smaller - ));
DESCR("smaller of two");
-DATA(insert OID = 1140 ( date_mi PGUID 12 f t t t 2 f 23 "1082 1082" 100 0 0 100 date_mi - ));
+DATA(insert OID = 1140 ( date_mi PGUID 12 f t t t 2 f 23 "1082 1082" 100 0 0 100 date_mi - ));
DESCR("subtract");
-DATA(insert OID = 1141 ( date_pli PGUID 12 f t t t 2 f 1082 "1082 23" 100 0 0 100 date_pli - ));
+DATA(insert OID = 1141 ( date_pli PGUID 12 f t t t 2 f 1082 "1082 23" 100 0 0 100 date_pli - ));
DESCR("add");
-DATA(insert OID = 1142 ( date_mii PGUID 12 f t t t 2 f 1082 "1082 23" 100 0 0 100 date_mii - ));
+DATA(insert OID = 1142 ( date_mii PGUID 12 f t t t 2 f 1082 "1082 23" 100 0 0 100 date_mii - ));
DESCR("subtract");
DATA(insert OID = 1143 ( time_in PGUID 12 f t f t 1 f 1083 "0" 100 0 0 100 time_in - ));
DESCR("(internal)");
-DATA(insert OID = 1144 ( time_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 time_out - ));
+DATA(insert OID = 1144 ( time_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 time_out - ));
DESCR("(internal)");
-DATA(insert OID = 1145 ( time_eq PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_eq - ));
+DATA(insert OID = 1145 ( time_eq PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_eq - ));
DESCR("equal");
DATA(insert OID = 1146 ( circle_add_pt PGUID 12 f t t t 2 f 718 "718 600" 100 0 0 100 circle_add_pt - ));
DATA(insert OID = 1150 ( timestamptz_in PGUID 12 f t f t 1 f 1184 "0" 100 0 0 100 timestamptz_in - ));
DESCR("(internal)");
-DATA(insert OID = 1151 ( timestamptz_out PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 timestamptz_out - ));
+DATA(insert OID = 1151 ( timestamptz_out PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 timestamptz_out - ));
DESCR("(internal)");
-DATA(insert OID = 1152 ( timestamptz_eq PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_eq - ));
+DATA(insert OID = 1152 ( timestamptz_eq PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_eq - ));
DESCR("equal");
-DATA(insert OID = 1153 ( timestamptz_ne PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_ne - ));
+DATA(insert OID = 1153 ( timestamptz_ne PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_ne - ));
DESCR("not equal");
-DATA(insert OID = 1154 ( timestamptz_lt PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_lt - ));
+DATA(insert OID = 1154 ( timestamptz_lt PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_lt - ));
DESCR("less-than");
-DATA(insert OID = 1155 ( timestamptz_le PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_le - ));
+DATA(insert OID = 1155 ( timestamptz_le PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 1156 ( timestamptz_ge PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_ge - ));
+DATA(insert OID = 1156 ( timestamptz_ge PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_ge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 1157 ( timestamptz_gt PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_gt - ));
+DATA(insert OID = 1157 ( timestamptz_gt PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_gt - ));
DESCR("greater-than");
DATA(insert OID = 1159 ( timezone PGUID 12 f t f t 2 f 25 "25 1184" 100 0 0 100 timestamptz_zone - ));
DESCR("time zone");
DATA(insert OID = 1160 ( interval_in PGUID 12 f t f t 1 f 1186 "0" 100 0 0 100 interval_in - ));
DESCR("(internal)");
-DATA(insert OID = 1161 ( interval_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 interval_out - ));
+DATA(insert OID = 1161 ( interval_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 interval_out - ));
DESCR("(internal)");
-DATA(insert OID = 1162 ( interval_eq PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_eq - ));
+DATA(insert OID = 1162 ( interval_eq PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_eq - ));
DESCR("equal");
-DATA(insert OID = 1163 ( interval_ne PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_ne - ));
+DATA(insert OID = 1163 ( interval_ne PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_ne - ));
DESCR("not equal");
-DATA(insert OID = 1164 ( interval_lt PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_lt - ));
+DATA(insert OID = 1164 ( interval_lt PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_lt - ));
DESCR("less-than");
-DATA(insert OID = 1165 ( interval_le PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_le - ));
+DATA(insert OID = 1165 ( interval_le PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 1166 ( interval_ge PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_ge - ));
+DATA(insert OID = 1166 ( interval_ge PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_ge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 1167 ( interval_gt PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_gt - ));
+DATA(insert OID = 1167 ( interval_gt PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_gt - ));
DESCR("greater-than");
DATA(insert OID = 1168 ( interval_um PGUID 12 f t t t 1 f 1186 "1186" 100 0 0 100 interval_um - ));
DESCR("subtract");
DESCR("add");
DATA(insert OID = 1170 ( interval_mi PGUID 12 f t t t 2 f 1186 "1186 1186" 100 0 0 100 interval_mi - ));
DESCR("subtract");
-DATA(insert OID = 1171 ( date_part PGUID 12 f t f t 2 f 701 "25 1184" 100 0 0 100 timestamptz_part - ));
+DATA(insert OID = 1171 ( date_part PGUID 12 f t f t 2 f 701 "25 1184" 100 0 0 100 timestamptz_part - ));
DESCR("extract field from timestamp with time zone");
-DATA(insert OID = 1172 ( date_part PGUID 12 f t t t 2 f 701 "25 1186" 100 0 0 100 interval_part - ));
+DATA(insert OID = 1172 ( date_part PGUID 12 f t t t 2 f 701 "25 1186" 100 0 0 100 interval_part - ));
DESCR("extract field from interval");
-DATA(insert OID = 1173 ( timestamptz PGUID 12 f t f t 1 f 1184 "702" 100 0 0 100 abstime_timestamptz - ));
+DATA(insert OID = 1173 ( timestamptz PGUID 12 f t f t 1 f 1184 "702" 100 0 0 100 abstime_timestamptz - ));
DESCR("convert abstime to timestamp with time zone");
DATA(insert OID = 1174 ( timestamptz PGUID 12 f t f t 1 f 1184 "1082" 100 0 0 100 date_timestamptz - ));
DESCR("convert date to timestamp with time zone");
DATA(insert OID = 1176 ( timestamptz PGUID 14 f t f t 2 f 1184 "1082 1083" 100 0 0 100 "select timestamptz($1 + $2)" - ));
DESCR("convert date and time to timestamp with time zone");
-DATA(insert OID = 1177 ( interval PGUID 12 f t t t 1 f 1186 "703" 100 0 0 100 reltime_interval - ));
+DATA(insert OID = 1177 ( interval PGUID 12 f t t t 1 f 1186 "703" 100 0 0 100 reltime_interval - ));
DESCR("convert reltime to interval");
DATA(insert OID = 1178 ( date PGUID 12 f t f t 1 f 1082 "1184" 100 0 0 100 timestamptz_date - ));
DESCR("convert timestamp with time zone to date");
-DATA(insert OID = 1179 ( date PGUID 12 f t f t 1 f 1082 "702" 100 0 0 100 abstime_date - ));
+DATA(insert OID = 1179 ( date PGUID 12 f t f t 1 f 1082 "702" 100 0 0 100 abstime_date - ));
DESCR("convert abstime to date");
DATA(insert OID = 1180 ( abstime PGUID 12 f t f t 1 f 702 "1184" 100 0 0 100 timestamptz_abstime - ));
DESCR("convert timestamp with time zone to abstime");
DESCR("plus");
DATA(insert OID = 1190 ( timestamptz_mi_span PGUID 12 f t t t 2 f 1184 "1184 1186" 100 0 0 100 timestamp_mi_span - ));
DESCR("minus");
-DATA(insert OID = 1191 ( timestamptz PGUID 12 f t f t 1 f 1184 "25" 100 0 0 100 text_timestamptz - ));
+DATA(insert OID = 1191 ( timestamptz PGUID 12 f t f t 1 f 1184 "25" 100 0 0 100 text_timestamptz - ));
DESCR("convert text to timestamp with time zone");
-DATA(insert OID = 1192 ( text PGUID 12 f t f t 1 f 25 "1184" 100 0 0 100 timestamptz_text - ));
+DATA(insert OID = 1192 ( text PGUID 12 f t f t 1 f 25 "1184" 100 0 0 100 timestamptz_text - ));
DESCR("convert timestamp to text");
-DATA(insert OID = 1193 ( text PGUID 12 f t t t 1 f 25 "1186" 100 0 0 100 interval_text - ));
+DATA(insert OID = 1193 ( text PGUID 12 f t t t 1 f 25 "1186" 100 0 0 100 interval_text - ));
DESCR("convert interval to text");
-DATA(insert OID = 1194 ( reltime PGUID 12 f t t t 1 f 703 "1186" 100 0 0 100 interval_reltime - ));
+DATA(insert OID = 1194 ( reltime PGUID 12 f t t t 1 f 703 "1186" 100 0 0 100 interval_reltime - ));
DESCR("convert interval to reltime");
DATA(insert OID = 1195 ( timestamptz_smaller PGUID 12 f t t t 2 f 1184 "1184 1184" 100 0 0 100 timestamp_smaller - ));
DESCR("smaller of two");
DATA(insert OID = 1200 ( reltime PGUID 12 f t t t 1 f 703 "23" 100 0 0 100 int4reltime - ));
DESCR("convert int4 to reltime");
-DATA(insert OID = 1215 ( obj_description PGUID 14 f t f t 2 f 25 "26 19" 100 0 0 100 "select description from pg_description where objoid = $1 and classoid = (select oid from pg_class where relname = $2) and objsubid = 0" - ));
+DATA(insert OID = 1215 ( obj_description PGUID 14 f t f t 2 f 25 "26 19" 100 0 0 100 "select description from pg_description where objoid = $1 and classoid = (select oid from pg_class where relname = $2) and objsubid = 0" - ));
DESCR("get description for object id and catalog name");
-DATA(insert OID = 1216 ( col_description PGUID 14 f t f t 2 f 25 "26 23" 100 0 0 100 "select description from pg_description where objoid = $1 and classoid = (select oid from pg_class where relname = \'pg_class\') and objsubid = $2" - ));
+DATA(insert OID = 1216 ( col_description PGUID 14 f t f t 2 f 25 "26 23" 100 0 0 100 "select description from pg_description where objoid = $1 and classoid = (select oid from pg_class where relname = \'pg_class\') and objsubid = $2" - ));
DESCR("get description for table column");
-DATA(insert OID = 1217 ( date_trunc PGUID 12 f t t t 2 f 1184 "25 1184" 100 0 0 100 timestamptz_trunc - ));
+DATA(insert OID = 1217 ( date_trunc PGUID 12 f t t t 2 f 1184 "25 1184" 100 0 0 100 timestamptz_trunc - ));
DESCR("truncate timestamp with time zone to specified units");
-DATA(insert OID = 1218 ( date_trunc PGUID 12 f t t t 2 f 1186 "25 1186" 100 0 0 100 interval_trunc - ));
+DATA(insert OID = 1218 ( date_trunc PGUID 12 f t t t 2 f 1186 "25 1186" 100 0 0 100 interval_trunc - ));
DESCR("truncate interval to specified units");
DATA(insert OID = 1219 ( int8inc PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8inc - ));
DATA(insert OID = 1230 ( int8abs PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8abs - ));
DESCR("absolute value");
-DATA(insert OID = 1236 ( int8larger PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8larger - ));
+DATA(insert OID = 1236 ( int8larger PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8larger - ));
DESCR("larger of two");
-DATA(insert OID = 1237 ( int8smaller PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8smaller - ));
+DATA(insert OID = 1237 ( int8smaller PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8smaller - ));
DESCR("smaller of two");
-DATA(insert OID = 1238 ( texticregexeq PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 texticregexeq - ));
+DATA(insert OID = 1238 ( texticregexeq PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 texticregexeq - ));
DESCR("matches regex., case-insensitive");
-DATA(insert OID = 1239 ( texticregexne PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 texticregexne - ));
+DATA(insert OID = 1239 ( texticregexne PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 texticregexne - ));
DESCR("does not match regex., case-insensitive");
-DATA(insert OID = 1240 ( nameicregexeq PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameicregexeq - ));
+DATA(insert OID = 1240 ( nameicregexeq PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameicregexeq - ));
DESCR("matches regex., case-insensitive");
-DATA(insert OID = 1241 ( nameicregexne PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameicregexne - ));
+DATA(insert OID = 1241 ( nameicregexne PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameicregexne - ));
DESCR("does not match regex., case-insensitive");
DATA(insert OID = 1251 ( int4abs PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4abs - ));
DESCR("SQL92 interval comparison");
DATA(insert OID = 1272 ( datetime_pl PGUID 12 f t t t 2 f 1114 "1082 1083" 100 0 0 100 datetime_timestamp - ));
DESCR("convert date and time to timestamp");
-DATA(insert OID = 1273 ( date_part PGUID 12 f t t t 2 f 701 "25 1266" 100 0 0 100 timetz_part - ));
+DATA(insert OID = 1273 ( date_part PGUID 12 f t t t 2 f 701 "25 1266" 100 0 0 100 timetz_part - ));
DESCR("extract field from time with time zone");
-DATA(insert OID = 1274 ( int84pl PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84pl - ));
+DATA(insert OID = 1274 ( int84pl PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84pl - ));
DESCR("add");
-DATA(insert OID = 1275 ( int84mi PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84mi - ));
+DATA(insert OID = 1275 ( int84mi PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84mi - ));
DESCR("subtract");
-DATA(insert OID = 1276 ( int84mul PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84mul - ));
+DATA(insert OID = 1276 ( int84mul PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84mul - ));
DESCR("multiply");
-DATA(insert OID = 1277 ( int84div PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84div - ));
+DATA(insert OID = 1277 ( int84div PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84div - ));
DESCR("divide");
-DATA(insert OID = 1278 ( int48pl PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48pl - ));
+DATA(insert OID = 1278 ( int48pl PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48pl - ));
DESCR("add");
-DATA(insert OID = 1279 ( int48mi PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48mi - ));
+DATA(insert OID = 1279 ( int48mi PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48mi - ));
DESCR("subtract");
-DATA(insert OID = 1280 ( int48mul PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48mul - ));
+DATA(insert OID = 1280 ( int48mul PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48mul - ));
DESCR("multiply");
-DATA(insert OID = 1281 ( int48div PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48div - ));
+DATA(insert OID = 1281 ( int48div PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48div - ));
DESCR("divide");
DATA(insert OID = 1288 ( text PGUID 12 f t t t 1 f 25 "20" 100 0 0 100 int8_text - ));
DATA(insert OID = 1289 ( int8 PGUID 12 f t t t 1 f 20 "25" 100 0 0 100 text_int8 - ));
DESCR("convert text to int8");
-DATA(insert OID = 1290 ( _bpchar PGUID 12 f t t t 2 f 1014 "1014 23" 100 0 0 100 _bpchar - ));
+DATA(insert OID = 1290 ( _bpchar PGUID 12 f t t t 2 f 1014 "1014 23" 100 0 0 100 _bpchar - ));
DESCR("adjust char()[] to typmod length");
-DATA(insert OID = 1291 ( _varchar PGUID 12 f t t t 2 f 1015 "1015 23" 100 0 0 100 _varchar - ));
+DATA(insert OID = 1291 ( _varchar PGUID 12 f t t t 2 f 1015 "1015 23" 100 0 0 100 _varchar - ));
DESCR("adjust varchar()[] to typmod length");
-DATA(insert OID = 1292 ( tideq PGUID 12 f t t t 2 f 16 "27 27" 100 0 0 100 tideq - ));
+DATA(insert OID = 1292 ( tideq PGUID 12 f t t t 2 f 16 "27 27" 100 0 0 100 tideq - ));
DESCR("equal");
-DATA(insert OID = 1293 ( currtid PGUID 12 f t f t 2 f 27 "26 27" 100 0 0 100 currtid_byreloid - ));
+DATA(insert OID = 1293 ( currtid PGUID 12 f t f t 2 f 27 "26 27" 100 0 0 100 currtid_byreloid - ));
DESCR("latest tid of a tuple");
-DATA(insert OID = 1294 ( currtid2 PGUID 12 f t f t 2 f 27 "25 27" 100 0 0 100 currtid_byrelname - ));
+DATA(insert OID = 1294 ( currtid2 PGUID 12 f t f t 2 f 27 "25 27" 100 0 0 100 currtid_byrelname - ));
DESCR("latest tid of a tuple");
DATA(insert OID = 1296 ( timedate_pl PGUID 14 f t t t 2 f 1114 "1083 1082" 100 0 0 100 "select ($2 + $1)" - ));
DATA(insert OID = 1303 ( contjoinsel PGUID 12 f t f t 3 f 701 "0 26 0" 100 0 0 100 contjoinsel - ));
DESCR("join selectivity for containment comparison operators");
-DATA(insert OID = 1304 ( overlaps PGUID 12 f t t f 4 f 16 "1184 1184 1184 1184" 100 0 0 100 overlaps_timestamp - ));
+DATA(insert OID = 1304 ( overlaps PGUID 12 f t t f 4 f 16 "1184 1184 1184 1184" 100 0 0 100 overlaps_timestamp - ));
DESCR("SQL92 interval comparison");
-DATA(insert OID = 1305 ( overlaps PGUID 14 f t t f 4 f 16 "1184 1186 1184 1186" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))" - ));
+DATA(insert OID = 1305 ( overlaps PGUID 14 f t t f 4 f 16 "1184 1186 1184 1186" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))" - ));
DESCR("SQL92 interval comparison");
-DATA(insert OID = 1306 ( overlaps PGUID 14 f t t f 4 f 16 "1184 1184 1184 1186" 100 0 0 100 "select ($1, $2) overlaps ($3, ($3 + $4))" - ));
+DATA(insert OID = 1306 ( overlaps PGUID 14 f t t f 4 f 16 "1184 1184 1184 1186" 100 0 0 100 "select ($1, $2) overlaps ($3, ($3 + $4))" - ));
DESCR("SQL92 interval comparison");
-DATA(insert OID = 1307 ( overlaps PGUID 14 f t t f 4 f 16 "1184 1186 1184 1184" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, $4)" - ));
+DATA(insert OID = 1307 ( overlaps PGUID 14 f t t f 4 f 16 "1184 1186 1184 1184" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, $4)" - ));
DESCR("SQL92 interval comparison");
-DATA(insert OID = 1308 ( overlaps PGUID 12 f t t f 4 f 16 "1083 1083 1083 1083" 100 0 0 100 overlaps_time - ));
+DATA(insert OID = 1308 ( overlaps PGUID 12 f t t f 4 f 16 "1083 1083 1083 1083" 100 0 0 100 overlaps_time - ));
DESCR("SQL92 interval comparison");
-DATA(insert OID = 1309 ( overlaps PGUID 14 f t t f 4 f 16 "1083 1186 1083 1186" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))" - ));
+DATA(insert OID = 1309 ( overlaps PGUID 14 f t t f 4 f 16 "1083 1186 1083 1186" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))" - ));
DESCR("SQL92 interval comparison");
-DATA(insert OID = 1310 ( overlaps PGUID 14 f t t f 4 f 16 "1083 1083 1083 1186" 100 0 0 100 "select ($1, $2) overlaps ($3, ($3 + $4))" - ));
+DATA(insert OID = 1310 ( overlaps PGUID 14 f t t f 4 f 16 "1083 1083 1083 1186" 100 0 0 100 "select ($1, $2) overlaps ($3, ($3 + $4))" - ));
DESCR("SQL92 interval comparison");
-DATA(insert OID = 1311 ( overlaps PGUID 14 f t t f 4 f 16 "1083 1186 1083 1083" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, $4)" - ));
+DATA(insert OID = 1311 ( overlaps PGUID 14 f t t f 4 f 16 "1083 1186 1083 1083" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, $4)" - ));
DESCR("SQL92 interval comparison");
-DATA(insert OID = 1312 ( timestamp_in PGUID 12 f t f t 1 f 1114 "0" 100 0 0 100 timestamp_in - ));
+DATA(insert OID = 1312 ( timestamp_in PGUID 12 f t f t 1 f 1114 "0" 100 0 0 100 timestamp_in - ));
DESCR("(internal)");
DATA(insert OID = 1313 ( timestamp_out PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 timestamp_out - ));
DESCR("(internal)");
-DATA(insert OID = 1314 ( timestamptz_cmp PGUID 12 f t t t 2 f 23 "1184 1184" 100 0 0 100 timestamp_cmp - ));
+DATA(insert OID = 1314 ( timestamptz_cmp PGUID 12 f t t t 2 f 23 "1184 1184" 100 0 0 100 timestamp_cmp - ));
DESCR("less-equal-greater");
-DATA(insert OID = 1315 ( interval_cmp PGUID 12 f t t t 2 f 23 "1186 1186" 100 0 0 100 interval_cmp - ));
+DATA(insert OID = 1315 ( interval_cmp PGUID 12 f t t t 2 f 23 "1186 1186" 100 0 0 100 interval_cmp - ));
DESCR("less-equal-greater");
DATA(insert OID = 1316 ( time PGUID 12 f t t t 1 f 1083 "1114" 100 0 0 100 timestamp_time - ));
DESCR("convert timestamp to time");
/*
* This form of obj_description is now deprecated, since it will fail if
- * OIDs are not unique across system catalogs. Use the other forms instead.
+ * OIDs are not unique across system catalogs. Use the other forms instead.
*/
DATA(insert OID = 1348 ( obj_description PGUID 14 f t f t 1 f 25 "26" 100 0 0 100 "select description from pg_description where objoid = $1 and objsubid = 0" - ));
DESCR("get description for object id (deprecated)");
DATA(insert OID = 1350 ( timetz_in PGUID 12 f t f t 1 f 1266 "0" 100 0 0 100 timetz_in - ));
DESCR("(internal)");
-DATA(insert OID = 1351 ( timetz_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 timetz_out - ));
+DATA(insert OID = 1351 ( timetz_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 timetz_out - ));
DESCR("(internal)");
-DATA(insert OID = 1352 ( timetz_eq PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_eq - ));
+DATA(insert OID = 1352 ( timetz_eq PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_eq - ));
DESCR("equal");
-DATA(insert OID = 1353 ( timetz_ne PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_ne - ));
+DATA(insert OID = 1353 ( timetz_ne PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_ne - ));
DESCR("not equal");
-DATA(insert OID = 1354 ( timetz_lt PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_lt - ));
+DATA(insert OID = 1354 ( timetz_lt PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_lt - ));
DESCR("less-than");
-DATA(insert OID = 1355 ( timetz_le PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_le - ));
+DATA(insert OID = 1355 ( timetz_le PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 1356 ( timetz_ge PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_ge - ));
+DATA(insert OID = 1356 ( timetz_ge PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_ge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 1357 ( timetz_gt PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_gt - ));
+DATA(insert OID = 1357 ( timetz_gt PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_gt - ));
DESCR("greater-than");
-DATA(insert OID = 1358 ( timetz_cmp PGUID 12 f t t t 2 f 23 "1266 1266" 100 0 0 100 timetz_cmp - ));
+DATA(insert OID = 1358 ( timetz_cmp PGUID 12 f t t t 2 f 23 "1266 1266" 100 0 0 100 timetz_cmp - ));
DESCR("less-equal-greater");
DATA(insert OID = 1359 ( timestamptz PGUID 12 f t t t 2 f 1184 "1082 1266" 100 0 0 100 datetimetz_timestamptz - ));
DESCR("convert date and time with time zone to timestamp with time zone");
DESCR("extract field from abstime");
DATA(insert OID = 1383 ( date_part PGUID 14 f t f t 2 f 701 "25 703" 100 0 0 100 "select date_part($1, cast($2 as interval))" - ));
DESCR("extract field from reltime");
-DATA(insert OID = 1384 ( date_part PGUID 14 f t t t 2 f 701 "25 1082" 100 0 0 100 "select date_part($1, cast($2 as timestamp without time zone))" - ));
+DATA(insert OID = 1384 ( date_part PGUID 14 f t t t 2 f 701 "25 1082" 100 0 0 100 "select date_part($1, cast($2 as timestamp without time zone))" - ));
DESCR("extract field from date");
-DATA(insert OID = 1385 ( date_part PGUID 14 f t t t 2 f 701 "25 1083" 100 0 0 100 "select date_part($1, cast($2 as time with time zone))" - ));
+DATA(insert OID = 1385 ( date_part PGUID 14 f t t t 2 f 701 "25 1083" 100 0 0 100 "select date_part($1, cast($2 as time with time zone))" - ));
DESCR("extract field from time");
DATA(insert OID = 1386 ( age PGUID 14 f t f t 1 f 1186 "1184" 100 0 0 100 "select age(cast(current_date as timestamp with time zone), $1)" - ));
DESCR("date difference from today preserving months and years");
DESCR("lines vertical?");
DATA(insert OID = 1415 ( ishorizontal PGUID 12 f t t t 1 f 16 "628" 100 0 0 100 line_horizontal - ));
DESCR("lines horizontal?");
-DATA(insert OID = 1416 ( point PGUID 12 f t t t 1 f 600 "718" 100 0 0 100 circle_center - ));
+DATA(insert OID = 1416 ( point PGUID 12 f t t t 1 f 600 "718" 100 0 0 100 circle_center - ));
DESCR("center of");
DATA(insert OID = 1417 ( isnottrue PGUID 12 f t t f 1 f 16 "16" 100 0 0 100 isnottrue - ));
DATA(insert OID = 1419 ( time PGUID 12 f t t t 1 f 1083 "1186" 100 0 0 100 interval_time - ));
DESCR("convert interval to time");
-DATA(insert OID = 1421 ( box PGUID 12 f t t t 2 f 603 "600 600" 100 0 0 100 points_box - ));
+DATA(insert OID = 1421 ( box PGUID 12 f t t t 2 f 603 "600 600" 100 0 0 100 points_box - ));
DESCR("convert points to box");
-DATA(insert OID = 1422 ( box_add PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_add - ));
+DATA(insert OID = 1422 ( box_add PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_add - ));
DESCR("add point to box (translate)");
-DATA(insert OID = 1423 ( box_sub PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_sub - ));
+DATA(insert OID = 1423 ( box_sub PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_sub - ));
DESCR("subtract point from box (translate)");
-DATA(insert OID = 1424 ( box_mul PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_mul - ));
+DATA(insert OID = 1424 ( box_mul PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_mul - ));
DESCR("multiply box by point (scale)");
-DATA(insert OID = 1425 ( box_div PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_div - ));
+DATA(insert OID = 1425 ( box_div PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_div - ));
DESCR("divide box by point (scale)");
DATA(insert OID = 1426 ( path_contain_pt PGUID 14 f t t t 2 f 16 "602 600" 100 0 0 100 "select on_ppath($2, $1)" - ));
DESCR("path contains point?");
* - thomas 97/04/20
*/
-DATA(insert OID = 1433 ( pclose PGUID 12 f t t t 1 f 602 "602" 100 0 0 100 path_close - ));
+DATA(insert OID = 1433 ( pclose PGUID 12 f t t t 1 f 602 "602" 100 0 0 100 path_close - ));
DESCR("close path");
-DATA(insert OID = 1434 ( popen PGUID 12 f t t t 1 f 602 "602" 100 0 0 100 path_open - ));
+DATA(insert OID = 1434 ( popen PGUID 12 f t t t 1 f 602 "602" 100 0 0 100 path_open - ));
DESCR("open path");
-DATA(insert OID = 1435 ( path_add PGUID 12 f t t t 2 f 602 "602 602" 100 0 0 100 path_add - ));
+DATA(insert OID = 1435 ( path_add PGUID 12 f t t t 2 f 602 "602 602" 100 0 0 100 path_add - ));
DESCR("concatenate open paths");
-DATA(insert OID = 1436 ( path_add_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_add_pt - ));
+DATA(insert OID = 1436 ( path_add_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_add_pt - ));
DESCR("add (translate path)");
-DATA(insert OID = 1437 ( path_sub_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_sub_pt - ));
+DATA(insert OID = 1437 ( path_sub_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_sub_pt - ));
DESCR("subtract (translate path)");
-DATA(insert OID = 1438 ( path_mul_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_mul_pt - ));
+DATA(insert OID = 1438 ( path_mul_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_mul_pt - ));
DESCR("multiply (rotate/scale path)");
-DATA(insert OID = 1439 ( path_div_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_div_pt - ));
+DATA(insert OID = 1439 ( path_div_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_div_pt - ));
DESCR("divide (rotate/scale path)");
-DATA(insert OID = 1440 ( point PGUID 12 f t t t 2 f 600 "701 701" 100 0 0 100 construct_point - ));
+DATA(insert OID = 1440 ( point PGUID 12 f t t t 2 f 600 "701 701" 100 0 0 100 construct_point - ));
DESCR("convert x, y to point");
-DATA(insert OID = 1441 ( point_add PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_add - ));
+DATA(insert OID = 1441 ( point_add PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_add - ));
DESCR("add points (translate)");
-DATA(insert OID = 1442 ( point_sub PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_sub - ));
+DATA(insert OID = 1442 ( point_sub PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_sub - ));
DESCR("subtract points (translate)");
-DATA(insert OID = 1443 ( point_mul PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_mul - ));
+DATA(insert OID = 1443 ( point_mul PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_mul - ));
DESCR("multiply points (scale/rotate)");
-DATA(insert OID = 1444 ( point_div PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_div - ));
+DATA(insert OID = 1444 ( point_div PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_div - ));
DESCR("divide points (scale/rotate)");
DATA(insert OID = 1445 ( poly_npoints PGUID 12 f t t t 1 f 23 "604" 100 0 0 100 poly_npoints - ));
DESCR("number of points in polygon");
-DATA(insert OID = 1446 ( box PGUID 12 f t t t 1 f 603 "604" 100 0 0 100 poly_box - ));
+DATA(insert OID = 1446 ( box PGUID 12 f t t t 1 f 603 "604" 100 0 0 100 poly_box - ));
DESCR("convert polygon to bounding box");
-DATA(insert OID = 1447 ( path PGUID 12 f t t t 1 f 602 "604" 100 0 0 100 poly_path - ));
+DATA(insert OID = 1447 ( path PGUID 12 f t t t 1 f 602 "604" 100 0 0 100 poly_path - ));
DESCR("convert polygon to path");
-DATA(insert OID = 1448 ( polygon PGUID 12 f t t t 1 f 604 "603" 100 0 0 100 box_poly - ));
+DATA(insert OID = 1448 ( polygon PGUID 12 f t t t 1 f 604 "603" 100 0 0 100 box_poly - ));
DESCR("convert box to polygon");
-DATA(insert OID = 1449 ( polygon PGUID 12 f t t t 1 f 604 "602" 100 0 0 100 path_poly - ));
+DATA(insert OID = 1449 ( polygon PGUID 12 f t t t 1 f 604 "602" 100 0 0 100 path_poly - ));
DESCR("convert path to polygon");
DATA(insert OID = 1450 ( circle_in PGUID 12 f t t t 1 f 718 "0" 100 0 0 100 circle_in - ));
DESCR("less-than-or-equal by area");
DATA(insert OID = 1467 ( circle_ge PGUID 12 f t t t 2 f 16 "718 718" 100 0 0 100 circle_ge - ));
DESCR("greater-than-or-equal by area");
-DATA(insert OID = 1468 ( area PGUID 12 f t t t 1 f 701 "718" 100 0 0 100 circle_area - ));
+DATA(insert OID = 1468 ( area PGUID 12 f t t t 1 f 701 "718" 100 0 0 100 circle_area - ));
DESCR("area of circle");
-DATA(insert OID = 1469 ( diameter PGUID 12 f t t t 1 f 701 "718" 100 0 0 100 circle_diameter - ));
+DATA(insert OID = 1469 ( diameter PGUID 12 f t t t 1 f 701 "718" 100 0 0 100 circle_diameter - ));
DESCR("diameter of circle");
-DATA(insert OID = 1470 ( radius PGUID 12 f t t t 1 f 701 "718" 100 0 0 100 circle_radius - ));
+DATA(insert OID = 1470 ( radius PGUID 12 f t t t 1 f 701 "718" 100 0 0 100 circle_radius - ));
DESCR("radius of circle");
-DATA(insert OID = 1471 ( circle_distance PGUID 12 f t t t 2 f 701 "718 718" 100 0 0 100 circle_distance - ));
+DATA(insert OID = 1471 ( circle_distance PGUID 12 f t t t 2 f 701 "718 718" 100 0 0 100 circle_distance - ));
DESCR("distance between");
-DATA(insert OID = 1472 ( circle_center PGUID 12 f t t t 1 f 600 "718" 100 0 0 100 circle_center - ));
+DATA(insert OID = 1472 ( circle_center PGUID 12 f t t t 1 f 600 "718" 100 0 0 100 circle_center - ));
DESCR("center of");
-DATA(insert OID = 1473 ( circle PGUID 12 f t t t 2 f 718 "600 701" 100 0 0 100 cr_circle - ));
+DATA(insert OID = 1473 ( circle PGUID 12 f t t t 2 f 718 "600 701" 100 0 0 100 cr_circle - ));
DESCR("convert point and radius to circle");
-DATA(insert OID = 1474 ( circle PGUID 12 f t t t 1 f 718 "604" 100 0 0 100 poly_circle - ));
+DATA(insert OID = 1474 ( circle PGUID 12 f t t t 1 f 718 "604" 100 0 0 100 poly_circle - ));
DESCR("convert polygon to circle");
DATA(insert OID = 1475 ( polygon PGUID 12 f t t t 2 f 604 "23 718" 100 0 0 100 circle_poly - ));
DESCR("convert vertex count and circle to polygon");
-DATA(insert OID = 1476 ( dist_pc PGUID 12 f t t t 2 f 701 "600 718" 100 0 0 100 dist_pc - ));
+DATA(insert OID = 1476 ( dist_pc PGUID 12 f t t t 2 f 701 "600 718" 100 0 0 100 dist_pc - ));
DESCR("distance between point and circle");
DATA(insert OID = 1477 ( circle_contain_pt PGUID 12 f t t t 2 f 16 "718 600" 100 0 0 100 circle_contain_pt - ));
DESCR("circle contains point?");
DATA(insert OID = 1478 ( pt_contained_circle PGUID 12 f t t t 2 f 16 "600 718" 100 0 0 100 pt_contained_circle - ));
DESCR("point inside circle?");
-DATA(insert OID = 1479 ( circle PGUID 12 f t t t 1 f 718 "603" 100 0 0 100 box_circle - ));
+DATA(insert OID = 1479 ( circle PGUID 12 f t t t 1 f 718 "603" 100 0 0 100 box_circle - ));
DESCR("convert box to circle");
-DATA(insert OID = 1480 ( box PGUID 12 f t t t 1 f 603 "718" 100 0 0 100 circle_box - ));
+DATA(insert OID = 1480 ( box PGUID 12 f t t t 1 f 603 "718" 100 0 0 100 circle_box - ));
DESCR("convert circle to box");
DATA(insert OID = 1481 ( tinterval PGUID 12 f t t t 2 f 704 "702 702" 100 0 0 100 mktinterval - ));
DESCR("convert to tinterval");
DESCR("greater-than by length");
DATA(insert OID = 1486 ( lseg_ge PGUID 12 f t t t 2 f 16 "601 601" 100 0 0 100 lseg_ge - ));
DESCR("greater-than-or-equal by length");
-DATA(insert OID = 1487 ( lseg_length PGUID 12 f t t t 1 f 701 "601" 100 0 0 100 lseg_length - ));
+DATA(insert OID = 1487 ( lseg_length PGUID 12 f t t t 1 f 701 "601" 100 0 0 100 lseg_length - ));
DESCR("distance between endpoints");
-DATA(insert OID = 1488 ( close_ls PGUID 12 f t t t 2 f 600 "628 601" 100 0 0 100 close_ls - ));
+DATA(insert OID = 1488 ( close_ls PGUID 12 f t t t 2 f 600 "628 601" 100 0 0 100 close_ls - ));
DESCR("closest point to line on line segment");
-DATA(insert OID = 1489 ( close_lseg PGUID 12 f t t t 2 f 600 "601 601" 100 0 0 100 close_lseg - ));
+DATA(insert OID = 1489 ( close_lseg PGUID 12 f t t t 2 f 600 "601 601" 100 0 0 100 close_lseg - ));
DESCR("closest point to line segment on line segment");
DATA(insert OID = 1490 ( line_in PGUID 12 f t t t 1 f 628 "0" 100 0 0 100 line_in - ));
DESCR("(internal)");
-DATA(insert OID = 1491 ( line_out PGUID 12 f t t t 1 f 23 "628" 100 0 0 100 line_out - ));
+DATA(insert OID = 1491 ( line_out PGUID 12 f t t t 1 f 23 "628" 100 0 0 100 line_out - ));
DESCR("(internal)");
-DATA(insert OID = 1492 ( line_eq PGUID 12 f t t t 2 f 16 "628 628" 100 0 0 100 line_eq - ));
+DATA(insert OID = 1492 ( line_eq PGUID 12 f t t t 2 f 16 "628 628" 100 0 0 100 line_eq - ));
DESCR("lines equal?");
-DATA(insert OID = 1493 ( line PGUID 12 f t t t 2 f 628 "600 600" 100 0 0 100 line_construct_pp - ));
+DATA(insert OID = 1493 ( line PGUID 12 f t t t 2 f 628 "600 600" 100 0 0 100 line_construct_pp - ));
DESCR("line from points");
-DATA(insert OID = 1494 ( line_interpt PGUID 12 f t t t 2 f 600 "628 628" 100 0 0 100 line_interpt - ));
+DATA(insert OID = 1494 ( line_interpt PGUID 12 f t t t 2 f 600 "628 628" 100 0 0 100 line_interpt - ));
DESCR("intersection point");
DATA(insert OID = 1495 ( line_intersect PGUID 12 f t t t 2 f 16 "628 628" 100 0 0 100 line_intersect - ));
DESCR("lines intersect?");
/* OIDS 1500 - 1599 */
-DATA(insert OID = 1530 ( length PGUID 12 f t t t 1 f 701 "601" 100 0 0 100 lseg_length - ));
+DATA(insert OID = 1530 ( length PGUID 12 f t t t 1 f 701 "601" 100 0 0 100 lseg_length - ));
DESCR("distance between endpoints");
-DATA(insert OID = 1531 ( length PGUID 12 f t t t 1 f 701 "602" 100 0 0 100 path_length - ));
+DATA(insert OID = 1531 ( length PGUID 12 f t t t 1 f 701 "602" 100 0 0 100 path_length - ));
DESCR("sum of path segments");
-DATA(insert OID = 1532 ( point PGUID 12 f t t t 1 f 600 "601" 100 0 0 100 lseg_center - ));
+DATA(insert OID = 1532 ( point PGUID 12 f t t t 1 f 600 "601" 100 0 0 100 lseg_center - ));
DESCR("center of");
-DATA(insert OID = 1533 ( point PGUID 12 f t t t 1 f 600 "602" 100 0 0 100 path_center - ));
+DATA(insert OID = 1533 ( point PGUID 12 f t t t 1 f 600 "602" 100 0 0 100 path_center - ));
DESCR("center of");
-DATA(insert OID = 1534 ( point PGUID 12 f t t t 1 f 600 "603" 100 0 0 100 box_center - ));
+DATA(insert OID = 1534 ( point PGUID 12 f t t t 1 f 600 "603" 100 0 0 100 box_center - ));
DESCR("center of");
-DATA(insert OID = 1540 ( point PGUID 12 f t t t 1 f 600 "604" 100 0 0 100 poly_center - ));
+DATA(insert OID = 1540 ( point PGUID 12 f t t t 1 f 600 "604" 100 0 0 100 poly_center - ));
DESCR("center of");
-DATA(insert OID = 1541 ( lseg PGUID 12 f t t t 1 f 601 "603" 100 0 0 100 box_diagonal - ));
+DATA(insert OID = 1541 ( lseg PGUID 12 f t t t 1 f 601 "603" 100 0 0 100 box_diagonal - ));
DESCR("diagonal of");
-DATA(insert OID = 1542 ( center PGUID 12 f t t t 1 f 600 "603" 100 0 0 100 box_center - ));
+DATA(insert OID = 1542 ( center PGUID 12 f t t t 1 f 600 "603" 100 0 0 100 box_center - ));
DESCR("center of");
-DATA(insert OID = 1543 ( center PGUID 12 f t t t 1 f 600 "718" 100 0 0 100 circle_center - ));
+DATA(insert OID = 1543 ( center PGUID 12 f t t t 1 f 600 "718" 100 0 0 100 circle_center - ));
DESCR("center of");
-DATA(insert OID = 1544 ( polygon PGUID 14 f t t t 1 f 604 "718" 100 0 0 100 "select polygon(12, $1)" - ));
+DATA(insert OID = 1544 ( polygon PGUID 14 f t t t 1 f 604 "718" 100 0 0 100 "select polygon(12, $1)" - ));
DESCR("convert circle to 12-vertex polygon");
DATA(insert OID = 1545 ( npoints PGUID 12 f t t t 1 f 23 "602" 100 0 0 100 path_npoints - ));
DESCR("# points in path");
DESCR("sequence current value");
DATA(insert OID = 1576 ( setval PGUID 12 f t f t 2 f 20 "25 20" 100 0 0 100 setval - ));
DESCR("set sequence value");
-DATA(insert OID = 1765 ( setval PGUID 12 f t f t 3 f 20 "25 20 16" 100 0 0 100 setval_and_iscalled - ));
+DATA(insert OID = 1765 ( setval PGUID 12 f t f t 3 f 20 "25 20 16" 100 0 0 100 setval_and_iscalled - ));
DESCR("set sequence value and iscalled status");
DATA(insert OID = 1579 ( varbit_in PGUID 12 f t t t 1 f 1562 "0" 100 0 0 100 varbit_in - ));
DATA(insert OID = 1598 ( random PGUID 12 f t f t 0 f 701 "0" 100 0 0 100 drandom - ));
DESCR("random value");
-DATA(insert OID = 1599 ( setseed PGUID 12 f t f t 1 f 23 "701" 100 0 0 100 setseed - ));
+DATA(insert OID = 1599 ( setseed PGUID 12 f t f t 1 f 23 "701" 100 0 0 100 setseed - ));
DESCR("set random seed");
/* OIDS 1600 - 1699 */
-DATA(insert OID = 1600 ( asin PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dasin - ));
+DATA(insert OID = 1600 ( asin PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dasin - ));
DESCR("arcsine");
-DATA(insert OID = 1601 ( acos PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dacos - ));
+DATA(insert OID = 1601 ( acos PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dacos - ));
DESCR("arccosine");
-DATA(insert OID = 1602 ( atan PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 datan - ));
+DATA(insert OID = 1602 ( atan PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 datan - ));
DESCR("arctangent");
-DATA(insert OID = 1603 ( atan2 PGUID 12 f t t t 2 f 701 "701 701" 100 0 0 100 datan2 - ));
+DATA(insert OID = 1603 ( atan2 PGUID 12 f t t t 2 f 701 "701 701" 100 0 0 100 datan2 - ));
DESCR("arctangent, two arguments");
-DATA(insert OID = 1604 ( sin PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dsin - ));
+DATA(insert OID = 1604 ( sin PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dsin - ));
DESCR("sine");
-DATA(insert OID = 1605 ( cos PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dcos - ));
+DATA(insert OID = 1605 ( cos PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dcos - ));
DESCR("cosine");
-DATA(insert OID = 1606 ( tan PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dtan - ));
+DATA(insert OID = 1606 ( tan PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dtan - ));
DESCR("tangent");
-DATA(insert OID = 1607 ( cot PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dcot - ));
+DATA(insert OID = 1607 ( cot PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dcot - ));
DESCR("cotangent");
-DATA(insert OID = 1608 ( degrees PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 degrees - ));
+DATA(insert OID = 1608 ( degrees PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 degrees - ));
DESCR("radians to degrees");
-DATA(insert OID = 1609 ( radians PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 radians - ));
+DATA(insert OID = 1609 ( radians PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 radians - ));
DESCR("degrees to radians");
DATA(insert OID = 1610 ( pi PGUID 12 f t t t 0 f 701 "0" 100 0 0 100 dpi - ));
DESCR("PI");
DATA(insert OID = 1618 ( interval_mul PGUID 12 f t t t 2 f 1186 "1186 701" 100 0 0 100 interval_mul - ));
DESCR("multiply interval");
-DATA(insert OID = 1619 ( varchar PGUID 12 f t t t 1 f 1043 "23" 100 0 0 100 int4_text - ));
+DATA(insert OID = 1619 ( varchar PGUID 12 f t t t 1 f 1043 "23" 100 0 0 100 int4_text - ));
DESCR("convert int4 to varchar");
DATA(insert OID = 1620 ( ascii PGUID 12 f t t t 1 f 23 "25" 100 0 0 100 ascii - ));
DATA(insert OID = 1622 ( repeat PGUID 12 f t t t 2 f 25 "25 23" 100 0 0 100 repeat - ));
DESCR("replicate string int4 times");
-DATA(insert OID = 1623 ( varchar PGUID 12 f t t t 1 f 1043 "20" 100 0 0 100 int8_text - ));
+DATA(insert OID = 1623 ( varchar PGUID 12 f t t t 1 f 1043 "20" 100 0 0 100 int8_text - ));
DESCR("convert int8 to varchar");
DATA(insert OID = 1624 ( mul_d_interval PGUID 12 f t t t 2 f 1186 "701 1186" 100 0 0 100 mul_d_interval - ));
DESCR("update pg_pwd file");
/* Oracle Compatibility Related Functions - By Edmund Mergl */
-DATA(insert OID = 868 ( strpos PGUID 12 f t t t 2 f 23 "25 25" 100 0 0 100 textpos - ));
+DATA(insert OID = 868 ( strpos PGUID 12 f t t t 2 f 23 "25 25" 100 0 0 100 textpos - ));
DESCR("find position of substring");
DATA(insert OID = 870 ( lower PGUID 12 f t t t 1 f 25 "25" 100 0 0 100 lower - ));
DESCR("lowercase");
DESCR("left-pad string to length");
DATA(insert OID = 874 ( rpad PGUID 12 f t t t 3 f 25 "25 23 25" 100 0 0 100 rpad - ));
DESCR("right-pad string to length");
-DATA(insert OID = 875 ( ltrim PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 ltrim - ));
+DATA(insert OID = 875 ( ltrim PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 ltrim - ));
DESCR("left-pad string to length");
-DATA(insert OID = 876 ( rtrim PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 rtrim - ));
+DATA(insert OID = 876 ( rtrim PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 rtrim - ));
DESCR("right-pad string to length");
DATA(insert OID = 877 ( substr PGUID 12 f t t t 3 f 25 "25 23 23" 100 0 0 100 text_substr - ));
DESCR("return portion of string");
DATA(insert OID = 878 ( translate PGUID 12 f t t t 3 f 25 "25 25 25" 100 0 0 100 translate - ));
DESCR("map a set of character appearing in string");
-DATA(insert OID = 879 ( lpad PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select lpad($1, $2, \' \')" - ));
+DATA(insert OID = 879 ( lpad PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select lpad($1, $2, \' \')" - ));
DESCR("left-pad string to length");
-DATA(insert OID = 880 ( rpad PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select rpad($1, $2, \' \')" - ));
+DATA(insert OID = 880 ( rpad PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select rpad($1, $2, \' \')" - ));
DESCR("right-pad string to length");
DATA(insert OID = 881 ( ltrim PGUID 14 f t t t 1 f 25 "25" 100 0 0 100 "select ltrim($1, \' \')" - ));
DESCR("remove initial characters from string");
DATA(insert OID = 882 ( rtrim PGUID 14 f t t t 1 f 25 "25" 100 0 0 100 "select rtrim($1, \' \')" - ));
DESCR("remove trailing characters from string");
-DATA(insert OID = 883 ( substr PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select substr($1, $2, -1)" - ));
+DATA(insert OID = 883 ( substr PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select substr($1, $2, -1)" - ));
DESCR("return portion of string");
-DATA(insert OID = 884 ( btrim PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 btrim - ));
+DATA(insert OID = 884 ( btrim PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 btrim - ));
DESCR("trim both ends of string");
DATA(insert OID = 885 ( btrim PGUID 14 f t t t 1 f 25 "25" 100 0 0 100 "select btrim($1, \' \')" - ));
DESCR("trim both ends of string");
DATA(insert OID = 936 ( substring PGUID 12 f t t t 3 f 25 "25 23 23" 100 0 0 100 text_substr - ));
DESCR("return portion of string");
-DATA(insert OID = 937 ( substring PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select substring($1, $2, -1)" - ));
+DATA(insert OID = 937 ( substring PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select substring($1, $2, -1)" - ));
DESCR("return portion of string");
/* for multi-byte support */
/* return database encoding name */
-DATA(insert OID = 1039 ( getdatabaseencoding PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 getdatabaseencoding - ));
+DATA(insert OID = 1039 ( getdatabaseencoding PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 getdatabaseencoding - ));
DESCR("encoding name of current database");
/* return client encoding name i.e. session encoding */
-DATA(insert OID = 810 ( pg_client_encoding PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 pg_client_encoding - ));
+DATA(insert OID = 810 ( pg_client_encoding PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 pg_client_encoding - ));
DESCR("encoding name of current database");
-DATA(insert OID = 1717 ( convert PGUID 12 f t f t 2 f 25 "25 19" 100 0 0 100 pg_convert - ));
+DATA(insert OID = 1717 ( convert PGUID 12 f t f t 2 f 25 "25 19" 100 0 0 100 pg_convert - ));
DESCR("convert string with specified destination encoding name");
DATA(insert OID = 1813 ( convert PGUID 12 f t f t 3 f 25 "25 19 19" 100 0 0 100 pg_convert2 - ));
DATA(insert OID = 1597 ( pg_encoding_to_char PGUID 12 f t f t 1 f 19 "23" 100 0 0 100 PG_encoding_to_char - ));
DESCR("convert encoding id to encoding name");
-DATA(insert OID = 1638 ( oidgt PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidgt - ));
+DATA(insert OID = 1638 ( oidgt PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidgt - ));
DESCR("greater-than");
-DATA(insert OID = 1639 ( oidge PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidge - ));
+DATA(insert OID = 1639 ( oidge PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidge - ));
DESCR("greater-than-or-equal");
/* System-view support functions */
DESCR("user name by UID (with fallback)");
DATA(insert OID = 1643 ( pg_get_indexdef PGUID 12 f t f t 1 f 25 "26" 100 0 0 100 pg_get_indexdef - ));
DESCR("index description");
-DATA(insert OID = 1716 ( pg_get_expr PGUID 12 f t f t 2 f 25 "25 26" 100 0 0 100 pg_get_expr - ));
+DATA(insert OID = 1716 ( pg_get_expr PGUID 12 f t f t 2 f 25 "25 26" 100 0 0 100 pg_get_expr - ));
DESCR("deparse an encoded expression");
DESCR("referential integrity ON DELETE SET NULL");
DATA(insert OID = 1651 ( RI_FKey_setnull_upd PGUID 12 f t f t 0 f 0 "" 100 0 0 100 RI_FKey_setnull_upd - ));
DESCR("referential integrity ON UPDATE SET NULL");
-DATA(insert OID = 1652 ( RI_FKey_setdefault_del PGUID 12 f t f t 0 f 0 "" 100 0 0 100 RI_FKey_setdefault_del - ));
+DATA(insert OID = 1652 ( RI_FKey_setdefault_del PGUID 12 f t f t 0 f 0 "" 100 0 0 100 RI_FKey_setdefault_del - ));
DESCR("referential integrity ON DELETE SET DEFAULT");
-DATA(insert OID = 1653 ( RI_FKey_setdefault_upd PGUID 12 f t f t 0 f 0 "" 100 0 0 100 RI_FKey_setdefault_upd - ));
+DATA(insert OID = 1653 ( RI_FKey_setdefault_upd PGUID 12 f t f t 0 f 0 "" 100 0 0 100 RI_FKey_setdefault_upd - ));
DESCR("referential integrity ON UPDATE SET DEFAULT");
DATA(insert OID = 1654 ( RI_FKey_noaction_del PGUID 12 f t f t 0 f 0 "" 100 0 0 100 RI_FKey_noaction_del - ));
DESCR("referential integrity ON DELETE NO ACTION");
DESCR("bitwise right shift");
DATA(insert OID = 1679 ( bitcat PGUID 12 f t t t 2 f 1560 "1560 1560" 100 0 0 100 bitcat - ));
DESCR("bitwise concatenation");
-DATA(insert OID = 1680 ( substring PGUID 12 f t t t 3 f 1560 "1560 23 23" 100 0 0 100 bitsubstr - ));
+DATA(insert OID = 1680 ( substring PGUID 12 f t t t 3 f 1560 "1560 23 23" 100 0 0 100 bitsubstr - ));
DESCR("return portion of bitstring");
-DATA(insert OID = 1681 ( length PGUID 12 f t t t 1 f 23 "1560" 100 0 0 100 bitlength - ));
+DATA(insert OID = 1681 ( length PGUID 12 f t t t 1 f 23 "1560" 100 0 0 100 bitlength - ));
DESCR("bitstring length");
-DATA(insert OID = 1682 ( octet_length PGUID 12 f t t t 1 f 23 "1560" 100 0 0 100 bitoctetlength - ));
+DATA(insert OID = 1682 ( octet_length PGUID 12 f t t t 1 f 23 "1560" 100 0 0 100 bitoctetlength - ));
DESCR("octet length");
-DATA(insert OID = 1683 ( bitfromint4 PGUID 12 f t t t 1 f 1560 "23" 100 0 0 100 bitfromint4 - ));
+DATA(insert OID = 1683 ( bitfromint4 PGUID 12 f t t t 1 f 1560 "23" 100 0 0 100 bitfromint4 - ));
DESCR("int4 to bitstring");
-DATA(insert OID = 1684 ( bittoint4 PGUID 12 f t t t 1 f 23 "1560" 100 0 0 100 bittoint4 - ));
+DATA(insert OID = 1684 ( bittoint4 PGUID 12 f t t t 1 f 23 "1560" 100 0 0 100 bittoint4 - ));
DESCR("bitstring to int4");
-DATA(insert OID = 1685 ( bit PGUID 12 f t t t 2 f 1560 "1560 23" 100 0 0 100 bit - ));
+DATA(insert OID = 1685 ( bit PGUID 12 f t t t 2 f 1560 "1560 23" 100 0 0 100 bit - ));
DESCR("adjust bit() to typmod length");
-DATA(insert OID = 1686 ( _bit PGUID 12 f t t t 2 f 1561 "1561 23" 100 0 0 100 _bit - ));
+DATA(insert OID = 1686 ( _bit PGUID 12 f t t t 2 f 1561 "1561 23" 100 0 0 100 _bit - ));
DESCR("adjust bit()[] to typmod length");
-DATA(insert OID = 1687 ( varbit PGUID 12 f t t t 2 f 1562 "1562 23" 100 0 0 100 varbit - ));
+DATA(insert OID = 1687 ( varbit PGUID 12 f t t t 2 f 1562 "1562 23" 100 0 0 100 varbit - ));
DESCR("adjust varbit() to typmod length");
-DATA(insert OID = 1688 ( _varbit PGUID 12 f t t t 2 f 1563 "1563 23" 100 0 0 100 _varbit - ));
+DATA(insert OID = 1688 ( _varbit PGUID 12 f t t t 2 f 1563 "1563 23" 100 0 0 100 _varbit - ));
DESCR("adjust varbit()[] to typmod length");
DATA(insert OID = 1698 ( position PGUID 12 f t t t 2 f 23 "1560 1560" 100 0 0 100 bitposition - ));
DATA(insert OID = 752 ( text PGUID 12 f t t t 1 f 25 "829" 100 0 0 100 macaddr_text - ));
DESCR("MAC address to text");
-DATA(insert OID = 753 ( trunc PGUID 12 f t t t 1 f 829 "829" 100 0 0 100 macaddr_trunc - ));
+DATA(insert OID = 753 ( trunc PGUID 12 f t t t 1 f 829 "829" 100 0 0 100 macaddr_trunc - ));
DESCR("MAC manufacturer fields");
DATA(insert OID = 767 ( macaddr PGUID 12 f t t t 1 f 829 "25" 100 0 0 100 text_macaddr - ));
DESCR("text to MAC address");
/* inet/cidr functions */
DATA(insert OID = 605 ( abbrev PGUID 12 f t t t 1 f 25 "869" 100 0 0 100 network_abbrev - ));
DESCR("abbreviated display of inet/cidr value");
-DATA(insert OID = 683 ( network PGUID 12 f t t t 1 f 650 "869" 100 0 0 100 network_network - ));
+DATA(insert OID = 683 ( network PGUID 12 f t t t 1 f 650 "869" 100 0 0 100 network_network - ));
DESCR("network part of address");
-DATA(insert OID = 696 ( netmask PGUID 12 f t t t 1 f 869 "869" 100 0 0 100 network_netmask - ));
+DATA(insert OID = 696 ( netmask PGUID 12 f t t t 1 f 869 "869" 100 0 0 100 network_netmask - ));
DESCR("netmask of address");
DATA(insert OID = 697 ( masklen PGUID 12 f t t t 1 f 23 "869" 100 0 0 100 network_masklen - ));
DESCR("netmask length");
-DATA(insert OID = 698 ( broadcast PGUID 12 f t t t 1 f 869 "869" 100 0 0 100 network_broadcast - ));
+DATA(insert OID = 698 ( broadcast PGUID 12 f t t t 1 f 869 "869" 100 0 0 100 network_broadcast - ));
DESCR("broadcast address of network");
DATA(insert OID = 699 ( host PGUID 12 f t t t 1 f 25 "869" 100 0 0 100 network_host - ));
DESCR("show address octets only");
DATA(insert OID = 1693 ( btboolcmp PGUID 12 f t t t 2 f 23 "16 16" 100 0 0 100 btboolcmp - ));
DESCR("btree less-equal-greater");
-DATA(insert OID = 1696 ( timetz_hash PGUID 12 f t t t 1 f 23 "1266" 100 0 0 100 timetz_hash - ));
+DATA(insert OID = 1696 ( timetz_hash PGUID 12 f t t t 1 f 23 "1266" 100 0 0 100 timetz_hash - ));
DESCR("hash");
-DATA(insert OID = 1697 ( interval_hash PGUID 12 f t t t 1 f 23 "1186" 100 0 0 100 interval_hash - ));
+DATA(insert OID = 1697 ( interval_hash PGUID 12 f t t t 1 f 23 "1186" 100 0 0 100 interval_hash - ));
DESCR("hash");
DESCR("m raised to the power of n");
DATA(insert OID = 1739 ( numeric_power PGUID 12 f t t t 2 f 1700 "1700 1700" 100 0 0 100 numeric_power - ));
DESCR("m raised to the power of n");
-DATA(insert OID = 1740 ( numeric PGUID 12 f t t t 1 f 1700 "23" 100 0 0 100 int4_numeric - ));
+DATA(insert OID = 1740 ( numeric PGUID 12 f t t t 1 f 1700 "23" 100 0 0 100 int4_numeric - ));
DESCR("(internal)");
DATA(insert OID = 1741 ( log PGUID 14 f t t t 1 f 1700 "1700" 100 0 0 100 "select log(10, $1)" - ));
DESCR("logarithm base 10 of n");
DESCR("(internal)");
DATA(insert OID = 1743 ( numeric PGUID 12 f t t t 1 f 1700 "701" 100 0 0 100 float8_numeric - ));
DESCR("(internal)");
-DATA(insert OID = 1744 ( int4 PGUID 12 f t t t 1 f 23 "1700" 100 0 0 100 numeric_int4 - ));
+DATA(insert OID = 1744 ( int4 PGUID 12 f t t t 1 f 23 "1700" 100 0 0 100 numeric_int4 - ));
DESCR("(internal)");
DATA(insert OID = 1745 ( float4 PGUID 12 f t t t 1 f 700 "1700" 100 0 0 100 numeric_float4 - ));
DESCR("(internal)");
DESCR("compare two numbers");
DATA(insert OID = 1771 ( numeric_uminus PGUID 12 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_uminus - ));
DESCR("negate");
-DATA(insert OID = 1779 ( int8 PGUID 12 f t t t 1 f 20 "1700" 100 0 0 100 numeric_int8 - ));
+DATA(insert OID = 1779 ( int8 PGUID 12 f t t t 1 f 20 "1700" 100 0 0 100 numeric_int8 - ));
DESCR("(internal)");
-DATA(insert OID = 1781 ( numeric PGUID 12 f t t t 1 f 1700 "20" 100 0 0 100 int8_numeric - ));
+DATA(insert OID = 1781 ( numeric PGUID 12 f t t t 1 f 1700 "20" 100 0 0 100 int8_numeric - ));
DESCR("(internal)");
-DATA(insert OID = 1782 ( numeric PGUID 12 f t t t 1 f 1700 "21" 100 0 0 100 int2_numeric - ));
+DATA(insert OID = 1782 ( numeric PGUID 12 f t t t 1 f 1700 "21" 100 0 0 100 int2_numeric - ));
DESCR("(internal)");
-DATA(insert OID = 1783 ( int2 PGUID 12 f t t t 1 f 21 "1700" 100 0 0 100 numeric_int2 - ));
+DATA(insert OID = 1783 ( int2 PGUID 12 f t t t 1 f 21 "1700" 100 0 0 100 numeric_int2 - ));
DESCR("(internal)");
/* formatting */
DESCR("format timestamp with time zone to text");
DATA(insert OID = 1772 ( to_char PGUID 12 f t t t 2 f 25 "1700 25" 100 0 0 100 numeric_to_char - ));
DESCR("format numeric to text");
-DATA(insert OID = 1773 ( to_char PGUID 12 f t t t 2 f 25 "23 25" 100 0 0 100 int4_to_char - ));
+DATA(insert OID = 1773 ( to_char PGUID 12 f t t t 2 f 25 "23 25" 100 0 0 100 int4_to_char - ));
DESCR("format int4 to text");
-DATA(insert OID = 1774 ( to_char PGUID 12 f t t t 2 f 25 "20 25" 100 0 0 100 int8_to_char - ));
+DATA(insert OID = 1774 ( to_char PGUID 12 f t t t 2 f 25 "20 25" 100 0 0 100 int8_to_char - ));
DESCR("format int8 to text");
DATA(insert OID = 1775 ( to_char PGUID 12 f t t t 2 f 25 "700 25" 100 0 0 100 float4_to_char - ));
DESCR("format float4 to text");
DATA(insert OID = 1283 ( quote_literal PGUID 12 f t t t 1 f 25 "25" 100 0 0 100 quote_literal - ));
DESCR("quote a literal for usage in a querystring");
-DATA(insert OID = 1798 ( oidin PGUID 12 f t t t 1 f 26 "0" 100 0 0 100 oidin - ));
+DATA(insert OID = 1798 ( oidin PGUID 12 f t t t 1 f 26 "0" 100 0 0 100 oidin - ));
DESCR("(internal)");
-DATA(insert OID = 1799 ( oidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 oidout - ));
+DATA(insert OID = 1799 ( oidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 oidout - ));
DESCR("(internal)");
-DATA(insert OID = 1810 ( bit_length PGUID 14 f t t t 1 f 23 "17" 100 0 0 100 "select octet_length($1) * 8" - ));
+DATA(insert OID = 1810 ( bit_length PGUID 14 f t t t 1 f 23 "17" 100 0 0 100 "select octet_length($1) * 8" - ));
DESCR("length in bits");
-DATA(insert OID = 1811 ( bit_length PGUID 14 f t t t 1 f 23 "25" 100 0 0 100 "select octet_length($1) * 8" - ));
+DATA(insert OID = 1811 ( bit_length PGUID 14 f t t t 1 f 23 "25" 100 0 0 100 "select octet_length($1) * 8" - ));
DESCR("length in bits");
-DATA(insert OID = 1812 ( bit_length PGUID 14 f t t t 1 f 23 "1560" 100 0 0 100 "select length($1)" - ));
+DATA(insert OID = 1812 ( bit_length PGUID 14 f t t t 1 f 23 "1560" 100 0 0 100 "select length($1)" - ));
DESCR("length in bits");
/* Selectivity estimators for LIKE and related operators */
DESCR("join selectivity of case-insensitive regex non-match");
/* Aggregate-related functions */
-DATA(insert OID = 1830 ( float8_avg PGUID 12 f t t t 1 f 701 "1022" 100 0 0 100 float8_avg - ));
+DATA(insert OID = 1830 ( float8_avg PGUID 12 f t t t 1 f 701 "1022" 100 0 0 100 float8_avg - ));
DESCR("AVG aggregate final function");
-DATA(insert OID = 1831 ( float8_variance PGUID 12 f t t t 1 f 701 "1022" 100 0 0 100 float8_variance - ));
+DATA(insert OID = 1831 ( float8_variance PGUID 12 f t t t 1 f 701 "1022" 100 0 0 100 float8_variance - ));
DESCR("VARIANCE aggregate final function");
-DATA(insert OID = 1832 ( float8_stddev PGUID 12 f t t t 1 f 701 "1022" 100 0 0 100 float8_stddev - ));
+DATA(insert OID = 1832 ( float8_stddev PGUID 12 f t t t 1 f 701 "1022" 100 0 0 100 float8_stddev - ));
DESCR("STDDEV aggregate final function");
DATA(insert OID = 1833 ( numeric_accum PGUID 12 f t t t 2 f 1231 "1231 1700" 100 0 0 100 numeric_accum - ));
DESCR("aggregate transition function");
-DATA(insert OID = 1834 ( int2_accum PGUID 12 f t t t 2 f 1231 "1231 21" 100 0 0 100 int2_accum - ));
+DATA(insert OID = 1834 ( int2_accum PGUID 12 f t t t 2 f 1231 "1231 21" 100 0 0 100 int2_accum - ));
DESCR("aggregate transition function");
-DATA(insert OID = 1835 ( int4_accum PGUID 12 f t t t 2 f 1231 "1231 23" 100 0 0 100 int4_accum - ));
+DATA(insert OID = 1835 ( int4_accum PGUID 12 f t t t 2 f 1231 "1231 23" 100 0 0 100 int4_accum - ));
DESCR("aggregate transition function");
-DATA(insert OID = 1836 ( int8_accum PGUID 12 f t t t 2 f 1231 "1231 20" 100 0 0 100 int8_accum - ));
+DATA(insert OID = 1836 ( int8_accum PGUID 12 f t t t 2 f 1231 "1231 20" 100 0 0 100 int8_accum - ));
DESCR("aggregate transition function");
DATA(insert OID = 1837 ( numeric_avg PGUID 12 f t t t 1 f 1700 "1231" 100 0 0 100 numeric_avg - ));
DESCR("AVG aggregate final function");
DESCR("VARIANCE aggregate final function");
DATA(insert OID = 1839 ( numeric_stddev PGUID 12 f t t t 1 f 1700 "1231" 100 0 0 100 numeric_stddev - ));
DESCR("STDDEV aggregate final function");
-DATA(insert OID = 1840 ( int2_sum PGUID 12 f t t f 2 f 20 "20 21" 100 0 0 100 int2_sum - ));
+DATA(insert OID = 1840 ( int2_sum PGUID 12 f t t f 2 f 20 "20 21" 100 0 0 100 int2_sum - ));
DESCR("SUM(int2) transition function");
-DATA(insert OID = 1841 ( int4_sum PGUID 12 f t t f 2 f 20 "20 23" 100 0 0 100 int4_sum - ));
+DATA(insert OID = 1841 ( int4_sum PGUID 12 f t t f 2 f 20 "20 23" 100 0 0 100 int4_sum - ));
DESCR("SUM(int4) transition function");
-DATA(insert OID = 1842 ( int8_sum PGUID 12 f t t f 2 f 1700 "1700 20" 100 0 0 100 int8_sum - ));
+DATA(insert OID = 1842 ( int8_sum PGUID 12 f t t f 2 f 1700 "1700 20" 100 0 0 100 int8_sum - ));
DESCR("SUM(int8) transition function");
DATA(insert OID = 1843 ( interval_accum PGUID 12 f t t t 2 f 1187 "1187 1186" 100 0 0 100 interval_accum - ));
DESCR("aggregate transition function");
DATA(insert OID = 1844 ( interval_avg PGUID 12 f t t t 1 f 1186 "1187" 100 0 0 100 interval_avg - ));
DESCR("AVG aggregate final function");
-DATA(insert OID = 1962 ( int2_avg_accum PGUID 12 f t t t 2 f 1016 "1016 21" 100 0 0 100 int2_avg_accum - ));
+DATA(insert OID = 1962 ( int2_avg_accum PGUID 12 f t t t 2 f 1016 "1016 21" 100 0 0 100 int2_avg_accum - ));
DESCR("AVG(int2) transition function");
-DATA(insert OID = 1963 ( int4_avg_accum PGUID 12 f t t t 2 f 1016 "1016 23" 100 0 0 100 int4_avg_accum - ));
+DATA(insert OID = 1963 ( int4_avg_accum PGUID 12 f t t t 2 f 1016 "1016 23" 100 0 0 100 int4_avg_accum - ));
DESCR("AVG(int4) transition function");
DATA(insert OID = 1964 ( int8_avg PGUID 12 f t t t 1 f 1700 "1016" 100 0 0 100 int8_avg - ));
DESCR("AVG(int) aggregate final function");
/* To ASCII conversion */
DATA(insert OID = 1845 ( to_ascii PGUID 12 f t t t 1 f 25 "25" 100 0 0 100 to_ascii_default - ));
DESCR("encode text from DB encoding to ASCII text");
-DATA(insert OID = 1846 ( to_ascii PGUID 12 f t t t 2 f 25 "25 23" 100 0 0 100 to_ascii_enc - ));
+DATA(insert OID = 1846 ( to_ascii PGUID 12 f t t t 2 f 25 "25 23" 100 0 0 100 to_ascii_enc - ));
DESCR("encode text from encoding to ASCII text");
-DATA(insert OID = 1847 ( to_ascii PGUID 12 f t t t 2 f 25 "25 19" 100 0 0 100 to_ascii_encname - ));
+DATA(insert OID = 1847 ( to_ascii PGUID 12 f t t t 2 f 25 "25 19" 100 0 0 100 to_ascii_encname - ));
DESCR("encode text from encoding to ASCII text");
DATA(insert OID = 1848 ( interval_pl_time PGUID 12 f t t t 2 f 1083 "1186 1083" 100 0 0 100 interval_pl_time - ));
DESCR("plus");
-DATA(insert OID = 1850 ( int28eq PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28eq - ));
+DATA(insert OID = 1850 ( int28eq PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28eq - ));
DESCR("equal");
-DATA(insert OID = 1851 ( int28ne PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28ne - ));
+DATA(insert OID = 1851 ( int28ne PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28ne - ));
DESCR("not equal");
-DATA(insert OID = 1852 ( int28lt PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28lt - ));
+DATA(insert OID = 1852 ( int28lt PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28lt - ));
DESCR("less-than");
-DATA(insert OID = 1853 ( int28gt PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28gt - ));
+DATA(insert OID = 1853 ( int28gt PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28gt - ));
DESCR("greater-than");
-DATA(insert OID = 1854 ( int28le PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28le - ));
+DATA(insert OID = 1854 ( int28le PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 1855 ( int28ge PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28ge - ));
+DATA(insert OID = 1855 ( int28ge PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28ge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 1856 ( int82eq PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82eq - ));
+DATA(insert OID = 1856 ( int82eq PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82eq - ));
DESCR("equal");
-DATA(insert OID = 1857 ( int82ne PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82ne - ));
+DATA(insert OID = 1857 ( int82ne PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82ne - ));
DESCR("not equal");
-DATA(insert OID = 1858 ( int82lt PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82lt - ));
+DATA(insert OID = 1858 ( int82lt PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82lt - ));
DESCR("less-than");
-DATA(insert OID = 1859 ( int82gt PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82gt - ));
+DATA(insert OID = 1859 ( int82gt PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82gt - ));
DESCR("greater-than");
-DATA(insert OID = 1860 ( int82le PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82le - ));
+DATA(insert OID = 1860 ( int82le PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82le - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 1861 ( int82ge PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82ge - ));
+DATA(insert OID = 1861 ( int82ge PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82ge - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 1892 ( int2and PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2and - ));
+DATA(insert OID = 1892 ( int2and PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2and - ));
DESCR("binary and");
-DATA(insert OID = 1893 ( int2or PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2or - ));
+DATA(insert OID = 1893 ( int2or PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2or - ));
DESCR("binary or");
-DATA(insert OID = 1894 ( int2xor PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2xor - ));
+DATA(insert OID = 1894 ( int2xor PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2xor - ));
DESCR("binary xor");
DATA(insert OID = 1895 ( int2not PGUID 12 f t t t 1 f 21 "21" 100 0 0 100 int2not - ));
DESCR("binary not");
-DATA(insert OID = 1896 ( int2shl PGUID 12 f t t t 2 f 21 "21 23" 100 0 0 100 int2shl - ));
+DATA(insert OID = 1896 ( int2shl PGUID 12 f t t t 2 f 21 "21 23" 100 0 0 100 int2shl - ));
DESCR("binary shift left");
-DATA(insert OID = 1897 ( int2shr PGUID 12 f t t t 2 f 21 "21 23" 100 0 0 100 int2shr - ));
+DATA(insert OID = 1897 ( int2shr PGUID 12 f t t t 2 f 21 "21 23" 100 0 0 100 int2shr - ));
DESCR("binary shift right");
-DATA(insert OID = 1898 ( int4and PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4and - ));
+DATA(insert OID = 1898 ( int4and PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4and - ));
DESCR("binary and");
-DATA(insert OID = 1899 ( int4or PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4or - ));
+DATA(insert OID = 1899 ( int4or PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4or - ));
DESCR("binary or");
-DATA(insert OID = 1900 ( int4xor PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4xor - ));
+DATA(insert OID = 1900 ( int4xor PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4xor - ));
DESCR("binary xor");
DATA(insert OID = 1901 ( int4not PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4not - ));
DESCR("binary not");
-DATA(insert OID = 1902 ( int4shl PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4shl - ));
+DATA(insert OID = 1902 ( int4shl PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4shl - ));
DESCR("binary shift left");
-DATA(insert OID = 1903 ( int4shr PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4shr - ));
+DATA(insert OID = 1903 ( int4shr PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4shr - ));
DESCR("binary shift right");
-DATA(insert OID = 1904 ( int8and PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8and - ));
+DATA(insert OID = 1904 ( int8and PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8and - ));
DESCR("binary and");
-DATA(insert OID = 1905 ( int8or PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8or - ));
+DATA(insert OID = 1905 ( int8or PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8or - ));
DESCR("binary or");
-DATA(insert OID = 1906 ( int8xor PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8xor - ));
+DATA(insert OID = 1906 ( int8xor PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8xor - ));
DESCR("binary xor");
DATA(insert OID = 1907 ( int8not PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8not - ));
DESCR("binary not");
-DATA(insert OID = 1908 ( int8shl PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int8shl - ));
+DATA(insert OID = 1908 ( int8shl PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int8shl - ));
DESCR("binary shift left");
-DATA(insert OID = 1909 ( int8shr PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int8shr - ));
+DATA(insert OID = 1909 ( int8shr PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int8shr - ));
DESCR("binary shift right");
-DATA(insert OID = 1910 ( int8up PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8up - ));
+DATA(insert OID = 1910 ( int8up PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8up - ));
DESCR("unary plus");
-DATA(insert OID = 1911 ( int2up PGUID 12 f t t t 1 f 21 "21" 100 0 0 100 int2up - ));
+DATA(insert OID = 1911 ( int2up PGUID 12 f t t t 1 f 21 "21" 100 0 0 100 int2up - ));
DESCR("unary plus");
-DATA(insert OID = 1912 ( int4up PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4up - ));
+DATA(insert OID = 1912 ( int4up PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4up - ));
DESCR("unary plus");
-DATA(insert OID = 1913 ( float4up PGUID 12 f t t t 1 f 700 "700" 100 0 0 100 float4up - ));
+DATA(insert OID = 1913 ( float4up PGUID 12 f t t t 1 f 700 "700" 100 0 0 100 float4up - ));
DESCR("unary plus");
-DATA(insert OID = 1914 ( float8up PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 float8up - ));
+DATA(insert OID = 1914 ( float8up PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 float8up - ));
DESCR("unary plus");
-DATA(insert OID = 1915 ( numeric_uplus PGUID 12 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_uplus - ));
+DATA(insert OID = 1915 ( numeric_uplus PGUID 12 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_uplus - ));
DESCR("unary plus");
DATA(insert OID = 1922 ( has_table_privilege PGUID 12 f t f t 3 f 16 "19 19 25" 100 0 0 100 has_table_privilege_name_name - ));
DESCR("user privilege on relation by usesysid, relname");
DATA(insert OID = 1925 ( has_table_privilege PGUID 12 f t f t 3 f 16 "23 26 25" 100 0 0 100 has_table_privilege_id_id - ));
DESCR("user privilege on relation by usesysid, rel oid");
-DATA(insert OID = 1926 ( has_table_privilege PGUID 12 f t f t 2 f 16 "19 25" 100 0 0 100 has_table_privilege_name - ));
+DATA(insert OID = 1926 ( has_table_privilege PGUID 12 f t f t 2 f 16 "19 25" 100 0 0 100 has_table_privilege_name - ));
DESCR("current user privilege on relation by relname");
-DATA(insert OID = 1927 ( has_table_privilege PGUID 12 f t f t 2 f 16 "26 25" 100 0 0 100 has_table_privilege_id - ));
+DATA(insert OID = 1927 ( has_table_privilege PGUID 12 f t f t 2 f 16 "26 25" 100 0 0 100 has_table_privilege_id - ));
DESCR("current user privilege on relation by rel oid");
DESCR("Statistics: Number of blocks fetched");
DATA(insert OID = 1935 ( pg_stat_get_blocks_hit PGUID 12 f t f t 1 f 20 "26" 100 0 0 100 pg_stat_get_blocks_hit - ));
DESCR("Statistics: Number of blocks found in cache");
-DATA(insert OID = 1936 ( pg_stat_get_backend_idset PGUID 12 f t f t 0 t 23 "" 100 0 0 100 pg_stat_get_backend_idset - ));
+DATA(insert OID = 1936 ( pg_stat_get_backend_idset PGUID 12 f t f t 0 t 23 "" 100 0 0 100 pg_stat_get_backend_idset - ));
DESCR("Statistics: Currently active backend IDs");
DATA(insert OID = 1937 ( pg_stat_get_backend_pid PGUID 12 f t f t 1 f 23 "23" 100 0 0 100 pg_stat_get_backend_pid - ));
DESCR("Statistics: PID of backend");
DESCR("Statistics: Transactions committed");
DATA(insert OID = 1943 ( pg_stat_get_db_xact_rollback PGUID 12 f t f t 1 f 20 "26" 100 0 0 100 pg_stat_get_db_xact_rollback - ));
DESCR("Statistics: Transactions rolled back");
-DATA(insert OID = 1944 ( pg_stat_get_db_blocks_fetched PGUID 12 f t f t 1 f 20 "26" 100 0 0 100 pg_stat_get_db_blocks_fetched - ));
+DATA(insert OID = 1944 ( pg_stat_get_db_blocks_fetched PGUID 12 f t f t 1 f 20 "26" 100 0 0 100 pg_stat_get_db_blocks_fetched - ));
DESCR("Statistics: Blocks fetched for database");
DATA(insert OID = 1945 ( pg_stat_get_db_blocks_hit PGUID 12 f t f t 1 f 20 "26" 100 0 0 100 pg_stat_get_db_blocks_hit - ));
DESCR("Statistics: Block found in cache for database");
DATA(insert OID = 1947 ( decode PGUID 12 f t t t 2 f 17 "25 25" 100 0 0 100 binary_decode - ));
DESCR("Convert ascii-encoded text string into bytea value");
-DATA(insert OID = 1948 ( byteaeq PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteaeq - ));
+DATA(insert OID = 1948 ( byteaeq PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteaeq - ));
DESCR("equal");
-DATA(insert OID = 1949 ( bytealt PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 bytealt - ));
+DATA(insert OID = 1949 ( bytealt PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 bytealt - ));
DESCR("less-than");
-DATA(insert OID = 1950 ( byteale PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteale - ));
+DATA(insert OID = 1950 ( byteale PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteale - ));
DESCR("less-than-or-equal");
-DATA(insert OID = 1951 ( byteagt PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteagt - ));
+DATA(insert OID = 1951 ( byteagt PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteagt - ));
DESCR("greater-than");
-DATA(insert OID = 1952 ( byteage PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteage - ));
+DATA(insert OID = 1952 ( byteage PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteage - ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 1953 ( byteane PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteane - ));
+DATA(insert OID = 1953 ( byteane PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteane - ));
DESCR("not equal");
-DATA(insert OID = 1954 ( byteacmp PGUID 12 f t t t 2 f 23 "17 17" 100 0 0 100 byteacmp - ));
+DATA(insert OID = 1954 ( byteacmp PGUID 12 f t t t 2 f 23 "17 17" 100 0 0 100 byteacmp - ));
DESCR("less-equal-greater");
-DATA(insert OID = 1961 ( timestamp PGUID 12 f t t t 2 f 1114 "1114 23" 100 0 0 100 timestamp_scale - ));
+DATA(insert OID = 1961 ( timestamp PGUID 12 f t t t 2 f 1114 "1114 23" 100 0 0 100 timestamp_scale - ));
DESCR("adjust time precision");
-DATA(insert OID = 1965 ( oidlarger PGUID 12 f t t t 2 f 26 "26 26" 100 0 0 100 oidlarger - ));
+DATA(insert OID = 1965 ( oidlarger PGUID 12 f t t t 2 f 26 "26 26" 100 0 0 100 oidlarger - ));
DESCR("larger of two");
-DATA(insert OID = 1966 ( oidsmaller PGUID 12 f t t t 2 f 26 "26 26" 100 0 0 100 oidsmaller - ));
+DATA(insert OID = 1966 ( oidsmaller PGUID 12 f t t t 2 f 26 "26 26" 100 0 0 100 oidsmaller - ));
DESCR("smaller of two");
-DATA(insert OID = 1967 ( timestamptz PGUID 12 f t t t 2 f 1184 "1184 23" 100 0 0 100 timestamptz_scale - ));
+DATA(insert OID = 1967 ( timestamptz PGUID 12 f t t t 2 f 1184 "1184 23" 100 0 0 100 timestamptz_scale - ));
DESCR("adjust time precision");
-DATA(insert OID = 1968 ( time PGUID 12 f t t t 2 f 1083 "1083 23" 100 0 0 100 time_scale - ));
+DATA(insert OID = 1968 ( time PGUID 12 f t t t 2 f 1083 "1083 23" 100 0 0 100 time_scale - ));
DESCR("adjust time precision");
-DATA(insert OID = 1969 ( timetz PGUID 12 f t t t 2 f 1266 "1266 23" 100 0 0 100 timetz_scale - ));
+DATA(insert OID = 1969 ( timetz PGUID 12 f t t t 2 f 1266 "1266 23" 100 0 0 100 timetz_scale - ));
DESCR("adjust time with time zone precision");
DATA(insert OID = 2005 ( bytealike PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 bytealike - ));
DESCR("matches LIKE expression");
DATA(insert OID = 2006 ( byteanlike PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteanlike - ));
DESCR("does not match LIKE expression");
-DATA(insert OID = 2007 ( like PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 bytealike - ));
+DATA(insert OID = 2007 ( like PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 bytealike - ));
DESCR("matches LIKE expression");
-DATA(insert OID = 2008 ( notlike PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteanlike - ));
+DATA(insert OID = 2008 ( notlike PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteanlike - ));
DESCR("does not match LIKE expression");
DATA(insert OID = 2009 ( like_escape PGUID 12 f t t t 2 f 17 "17 17" 100 0 0 100 like_escape_bytea - ));
DESCR("convert match pattern to use backslash escapes");
DESCR("return position of substring");
DATA(insert OID = 2015 ( btrim PGUID 12 f t t t 2 f 17 "17 17" 100 0 0 100 byteatrim - ));
DESCR("trim both ends of string");
-
+
DATA(insert OID = 2020 ( date_trunc PGUID 12 f t t t 2 f 1114 "25 1114" 100 0 0 100 timestamp_trunc - ));
DESCR("truncate timestamp to specified units");
DATA(insert OID = 2021 ( date_part PGUID 12 f t t t 2 f 701 "25 1114" 100 0 0 100 timestamp_part - ));
DESCR("extract field from timestamp");
-DATA(insert OID = 2022 ( timestamp PGUID 12 f t f t 1 f 1114 "25" 100 0 0 100 text_timestamp - ));
+DATA(insert OID = 2022 ( timestamp PGUID 12 f t f t 1 f 1114 "25" 100 0 0 100 text_timestamp - ));
DESCR("convert text to timestamp");
DATA(insert OID = 2023 ( timestamp PGUID 12 f t f t 1 f 1114 "702" 100 0 0 100 abstime_timestamp - ));
DESCR("convert abstime to timestamp");
DESCR("SQL92 interval comparison");
DATA(insert OID = 2044 ( overlaps PGUID 14 f t t f 4 f 16 "1114 1186 1114 1114" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, $4)" - ));
DESCR("SQL92 interval comparison");
-DATA(insert OID = 2045 ( timestamp_cmp PGUID 12 f t t t 2 f 23 "1114 1114" 100 0 0 100 timestamp_cmp - ));
+DATA(insert OID = 2045 ( timestamp_cmp PGUID 12 f t t t 2 f 23 "1114 1114" 100 0 0 100 timestamp_cmp - ));
DESCR("less-equal-greater");
DATA(insert OID = 2046 ( time PGUID 12 f t t t 1 f 1083 "1266" 100 0 0 100 timetz_time - ));
DESCR("convert time with time zone to time");
DESCR("format timestamp to text");
DATA(insert OID = 2050 ( interval_mi_time PGUID 14 f t t t 2 f 1083 "1186 1083" 100 0 0 100 "select $2 - $1" - ));
DESCR("minus");
-DATA(insert OID = 2051 ( interval_mi_timetz PGUID 14 f t t t 2 f 1266 "1186 1266" 100 0 0 100 "select $2 - $1" - ));
+DATA(insert OID = 2051 ( interval_mi_timetz PGUID 14 f t t t 2 f 1266 "1186 1266" 100 0 0 100 "select $2 - $1" - ));
DESCR("minus");
DATA(insert OID = 2052 ( timestamp_eq PGUID 12 f t t t 2 f 16 "1114 1114" 100 0 0 100 timestamp_eq - ));
DESCR("equal");
int32 percall_cpu,
int32 outin_ratio,
List *argList);
-
-#endif /* PG_PROC_H */
+#endif /* PG_PROC_H */
#define Anum_pg_relcheck_rcname 2
#define Anum_pg_relcheck_rcbin 3
#define Anum_pg_relcheck_rcsrc 4
-
#endif /* PG_RELCHECK_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_rewrite.h,v 1.14 2001/03/22 04:00:40 momjian Exp $
+ * $Id: pg_rewrite.h,v 1.15 2001/10/25 05:49:58 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
#define Anum_pg_rewrite_is_instead 5
#define Anum_pg_rewrite_ev_qual 6
#define Anum_pg_rewrite_ev_action 7
-
#endif /* PG_REWRITE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_shadow.h,v 1.14 2001/09/08 15:24:00 petere Exp $
+ * $Id: pg_shadow.h,v 1.15 2001/10/25 05:49:58 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
DATA(insert ( "POSTGRES" PGUID t t t t _null_ _null_ ));
#define BOOTSTRAP_USESYSID 1
-
#endif /* PG_SHADOW_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_statistic.h,v 1.12 2001/08/10 18:57:41 tgl Exp $
+ * $Id: pg_statistic.h,v 1.13 2001/10/25 05:49:58 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
float4 stanullfrac;
/*
- * stawidth is the average width in bytes of non-null entries. For
+ * stawidth is the average width in bytes of non-null entries. For
* fixed-width datatypes this is of course the same as the typlen, but
* for varlena types it is more useful. Note that this is the average
* width of the data as actually stored, post-TOASTing (eg, for a
* moved-out-of-line value, only the size of the pointer object is
- * counted). This is the appropriate definition for the primary use of
- * the statistic, which is to estimate sizes of in-memory hash tables of
- * tuples.
+ * counted). This is the appropriate definition for the primary use
+ * of the statistic, which is to estimate sizes of in-memory hash
+ * tables of tuples.
*/
int4 stawidth;
* The special negative case allows us to cope with columns that are
* unique (stadistinct = -1) or nearly so (for example, a column in
* which values appear about twice on the average could be represented
- * by stadistinct = -0.5). Because the number-of-rows statistic in
+ * by stadistinct = -0.5). Because the number-of-rows statistic in
* pg_class may be updated more frequently than pg_statistic is, it's
* important to be able to describe such situations as a multiple of
* the number of rows, rather than a fixed number of distinct values.
/* ----------------
* To allow keeping statistics on different kinds of datatypes,
* we do not hard-wire any particular meaning for the remaining
- * statistical fields. Instead, we provide several "slots" in which
- * statistical data can be placed. Each slot includes:
+ * statistical fields. Instead, we provide several "slots" in which
+ * statistical data can be placed. Each slot includes:
* kind integer code identifying kind of data
* op OID of associated operator, if needed
* numbers float4 array (for statistical values)
Oid staop4;
/*
- * THE REST OF THESE ARE VARIABLE LENGTH FIELDS, and may even be absent
- * (NULL). They cannot be accessed as C struct entries; you have to use
- * the full field access machinery (heap_getattr) for them. We declare
- * them here for the catalog machinery.
+ * THE REST OF THESE ARE VARIABLE LENGTH FIELDS, and may even be
+ * absent (NULL). They cannot be accessed as C struct entries; you
+ * have to use the full field access machinery (heap_getattr) for
+ * them. We declare them here for the catalog machinery.
*/
float4 stanumbers1[1];
/*
* Currently, three statistical slot "kinds" are defined: most common values,
- * histogram, and correlation. Additional "kinds" will probably appear in
+ * histogram, and correlation. Additional "kinds" will probably appear in
* future to help cope with non-scalar datatypes.
*
* Code reading the pg_statistic relation should not assume that a particular
- * data "kind" will appear in any particular slot. Instead, search the
+ * data "kind" will appear in any particular slot. Instead, search the
* stakind fields to see if the desired data is available.
*/
* the K most common non-null values appearing in the column, and stanumbers
* contains their frequencies (fractions of total row count). The values
* shall be ordered in decreasing frequency. Note that since the arrays are
- * variable-size, K may be chosen by the statistics collector. Values should
+ * variable-size, K may be chosen by the statistics collector. Values should
* not appear in MCV unless they have been observed to occur more than once;
* a unique column will have no MCV slot.
*/
-#define STATISTIC_KIND_MCV 1
+#define STATISTIC_KIND_MCV 1
/*
* A "histogram" slot describes the distribution of scalar data. staop is
* more than one histogram could appear, if a datatype has more than one
* useful sort operator.) stavalues contains M (>=2) non-null values that
* divide the non-null column data values into M-1 bins of approximately equal
- * population. The first stavalues item is the MIN and the last is the MAX.
+ * population. The first stavalues item is the MIN and the last is the MAX.
* stanumbers is not used and should be NULL. IMPORTANT POINT: if an MCV
* slot is also provided, then the histogram describes the data distribution
* *after removing the values listed in MCV* (thus, it's a "compressed
* histogram" in the technical parlance). This allows a more accurate
* representation of the distribution of a column with some very-common
- * values. In a column with only a few distinct values, it's possible that
+ * values. In a column with only a few distinct values, it's possible that
* the MCV list describes the entire data population; in this case the
* histogram reduces to empty and should be omitted.
*/
* A "correlation" slot describes the correlation between the physical order
* of table tuples and the ordering of data values of this column, as seen
* by the "<" operator identified by staop. (As with the histogram, more
- * than one entry could theoretically appear.) stavalues is not used and
- * should be NULL. stanumbers contains a single entry, the correlation
+ * than one entry could theoretically appear.) stavalues is not used and
+ * should be NULL. stanumbers contains a single entry, the correlation
* coefficient between the sequence of data values and the sequence of
* their actual tuple positions. The coefficient ranges from +1 to -1.
*/
-#define STATISTIC_KIND_CORRELATION 3
-
+#define STATISTIC_KIND_CORRELATION 3
#endif /* PG_STATISTIC_H */
#define TRIGGER_FOR_INSERT(type) (type & TRIGGER_TYPE_INSERT)
#define TRIGGER_FOR_DELETE(type) (type & TRIGGER_TYPE_DELETE)
#define TRIGGER_FOR_UPDATE(type) (type & TRIGGER_TYPE_UPDATE)
-
#endif /* PG_TRIGGER_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_type.h,v 1.112 2001/09/28 08:09:14 thomas Exp $
+ * $Id: pg_type.h,v 1.113 2001/10/25 05:49:58 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
/*
* For a fixed-size type, typlen is the number of bytes we use to
- * represent a value of this type, e.g. 4 for an int4. But for a
+ * represent a value of this type, e.g. 4 for an int4. But for a
* variable-length type, typlen is -1.
*/
int2 typlen;
+
/*
* typprtlen was once intended to be the length of the external
* representation of a datatype, with the same interpretation as for
- * typlen. But it's currently unused.
+ * typlen. But it's currently unused.
*/
int2 typprtlen;
/*
* If typisdefined is false, the entry is only a placeholder (forward
- * reference). We know the type name, but not yet anything else about it.
+ * reference). We know the type name, but not yet anything else about
+ * it.
*/
bool typisdefined;
* be turned into pseudo-arrays like that. Hence, the way to determine
* whether a type is a "true" array type is if:
*
- * typelem != 0 and typlen < 0.
+ * typelem != 0 and typlen < 0.
*/
Oid typelem;
char typstorage;
/*
- * typdefault is NULL if the type has no associated default value.
- * If it's not NULL, it contains the external representation of the
- * type's default value --- this default is used whenever no per-column
- * default is specified for a column of the datatype.
+ * typdefault is NULL if the type has no associated default value. If
+ * it's not NULL, it contains the external representation of the
+ * type's default value --- this default is used whenever no
+ * per-column default is specified for a column of the datatype.
*/
text typdefault; /* VARIABLE LENGTH FIELD */
} FormData_pg_type;
DATA(insert OID = 1184 ( timestamptz PGUID 8 47 f b t \054 0 0 timestamptz_in timestamptz_out timestamptz_in timestamptz_out d p _null_ ));
DESCR("date and time with time zone");
#define TIMESTAMPTZOID 1184
-DATA(insert OID = 1185 ( _timestamptz PGUID -1 -1 f b t \054 0 1184 array_in array_out array_in array_out d x _null_ ));
+DATA(insert OID = 1185 ( _timestamptz PGUID -1 -1 f b t \054 0 1184 array_in array_out array_in array_out d x _null_ ));
DATA(insert OID = 1186 ( interval PGUID 12 47 f b t \054 0 0 interval_in interval_out interval_in interval_out d p _null_ ));
DESCR("@ , time interval");
#define INTERVALOID 1186
extern void TypeRename(const char *oldTypeName, const char *newTypeName);
extern char *makeArrayTypeName(char *typeName);
-
#endif /* PG_TYPE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_version.h,v 1.12 2001/01/24 19:43:23 momjian Exp $
+ * $Id: pg_version.h,v 1.13 2001/10/25 05:49:58 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
#define Anum_pg_version_verbaseid 2
#define Anum_pg_version_vertime 3
-
#endif /* PG_VERSION_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: async.h,v 1.17 2001/01/24 19:43:23 momjian Exp $
+ * $Id: async.h,v 1.18 2001/10/25 05:49:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
extern void EnableNotifyInterrupt(void);
extern void DisableNotifyInterrupt(void);
-
#endif /* ASYNC_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994-5, Regents of the University of California
*
- * $Id: cluster.h,v 1.9 2001/01/24 19:43:23 momjian Exp $
+ * $Id: cluster.h,v 1.10 2001/10/25 05:49:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* functions
*/
extern void cluster(char *oldrelname, char *oldindexname);
-
#endif /* CLUSTER_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: command.h,v 1.28 2001/10/12 00:07:15 tgl Exp $
+ * $Id: command.h,v 1.29 2001/10/25 05:49:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool inh, ColumnDef *colDef);
extern void AlterTableAlterColumnDefault(const char *relationName,
- bool inh, const char *colName,
- Node *newDefault);
+ bool inh, const char *colName,
+ Node *newDefault);
extern void AlterTableAlterColumnStatistics(const char *relationName,
- bool inh, const char *colName,
- Node *statsTarget);
+ bool inh, const char *colName,
+ Node *statsTarget);
extern void AlterTableDropColumn(const char *relationName,
bool inh, const char *colName,
* LOCK
*/
extern void LockTableCommand(LockStmt *lockstmt);
-
#endif /* COMMAND_H */
extern void DeleteComments(Oid oid, Oid classoid);
extern void CreateComments(Oid oid, Oid classoid, int32 subid, char *comment);
-
#endif /* COMMENT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: copy.h,v 1.13 2001/06/08 21:16:48 petere Exp $
+ * $Id: copy.h,v 1.14 2001/10/25 05:49:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
void DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
char *filename, char *delim, char *null_print);
-
#endif /* COPY_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: creatinh.h,v 1.14 2001/01/24 19:43:23 momjian Exp $
+ * $Id: creatinh.h,v 1.15 2001/10/25 05:49:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void DefineRelation(CreateStmt *stmt, char relkind);
extern void RemoveRelation(char *name);
extern void TruncateRelation(char *name);
-
#endif /* CREATINH_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: dbcommands.h,v 1.16 2001/03/22 04:00:42 momjian Exp $
+ * $Id: dbcommands.h,v 1.17 2001/10/25 05:49:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void createdb(const char *dbname, const char *dbpath,
const char *dbtemplate, int encoding);
extern void dropdb(const char *dbname);
-
#endif /* DBCOMMANDS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: defrem.h,v 1.25 2001/09/08 01:10:21 tgl Exp $
+ * $Id: defrem.h,v 1.26 2001/10/25 05:49:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
char *typeName1, char *typeName2);
extern void RemoveType(char *typeName);
extern void RemoveAggregate(char *aggName, char *aggType);
-
#endif /* DEFREM_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994-5, Regents of the University of California
*
- * $Id: explain.h,v 1.12 2001/09/18 01:59:06 tgl Exp $
+ * $Id: explain.h,v 1.13 2001/10/25 05:49:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "tcop/dest.h"
extern void ExplainQuery(Query *query, bool verbose, bool analyze, CommandDest dest);
-
#endif /* EXPLAIN_H */
extern void CreateProceduralLanguage(CreatePLangStmt *stmt);
extern void DropProceduralLanguage(DropPLangStmt *stmt);
-
#endif /* PROCLANG_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rename.h,v 1.10 2001/01/24 19:43:23 momjian Exp $
+ * $Id: rename.h,v 1.11 2001/10/25 05:49:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void renamerel(const char *oldrelname,
const char *newrelname);
-
#endif /* RENAME_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: sequence.h,v 1.16 2001/08/16 20:38:55 tgl Exp $
+ * $Id: sequence.h,v 1.17 2001/10/25 05:49:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void seq_redo(XLogRecPtr lsn, XLogRecord *rptr);
extern void seq_undo(XLogRecPtr lsn, XLogRecord *rptr);
extern void seq_desc(char *buf, uint8 xl_info, char *rec);
-
#endif /* SEQUENCE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: trigger.h,v 1.27 2001/06/01 02:41:36 tgl Exp $
+ * $Id: trigger.h,v 1.28 2001/10/25 05:49:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool equalTriggerDescs(TriggerDesc *trigdesc1, TriggerDesc *trigdesc2);
extern HeapTuple ExecBRInsertTriggers(EState *estate,
- ResultRelInfo *relinfo,
- HeapTuple trigtuple);
+ ResultRelInfo *relinfo,
+ HeapTuple trigtuple);
extern void ExecARInsertTriggers(EState *estate,
- ResultRelInfo *relinfo,
- HeapTuple trigtuple);
+ ResultRelInfo *relinfo,
+ HeapTuple trigtuple);
extern bool ExecBRDeleteTriggers(EState *estate,
- ResultRelInfo *relinfo,
- ItemPointer tupleid);
+ ResultRelInfo *relinfo,
+ ItemPointer tupleid);
extern void ExecARDeleteTriggers(EState *estate,
- ResultRelInfo *relinfo,
- ItemPointer tupleid);
+ ResultRelInfo *relinfo,
+ ItemPointer tupleid);
extern HeapTuple ExecBRUpdateTriggers(EState *estate,
- ResultRelInfo *relinfo,
- ItemPointer tupleid,
- HeapTuple newtuple);
+ ResultRelInfo *relinfo,
+ ItemPointer tupleid,
+ HeapTuple newtuple);
extern void ExecARUpdateTriggers(EState *estate,
- ResultRelInfo *relinfo,
- ItemPointer tupleid,
- HeapTuple newtuple);
+ ResultRelInfo *relinfo,
+ ItemPointer tupleid,
+ HeapTuple newtuple);
/* ----------
*
*/
extern bool RI_FKey_keyequal_upd(TriggerData *trigdata);
-
#endif /* TRIGGER_H */
* user.h
*
*
- * $Id: user.h,v 1.13 2000/06/15 03:32:35 momjian Exp $
+ * $Id: user.h,v 1.14 2001/10/25 05:49:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void DropGroup(DropGroupStmt *stmt);
extern Datum update_pg_pwd(PG_FUNCTION_ARGS);
-
#endif /* USER_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: vacuum.h,v 1.40 2001/08/26 16:56:02 tgl Exp $
+ * $Id: vacuum.h,v 1.41 2001/10/25 05:49:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* State structure for vac_init_rusage/vac_show_rusage */
typedef struct VacRUsage
{
- struct timeval tv;
- struct rusage ru;
+ struct timeval tv;
+ struct rusage ru;
} VacRUsage;
/* in commands/vacuum.c */
extern void vacuum(VacuumStmt *vacstmt);
extern void vac_open_indexes(Relation relation, int *nindexes,
- Relation **Irel);
+ Relation **Irel);
extern void vac_close_indexes(int nindexes, Relation *Irel);
extern void vac_update_relstats(Oid relid,
- BlockNumber num_pages,
- double num_tuples,
- bool hasindex);
+ BlockNumber num_pages,
+ double num_tuples,
+ bool hasindex);
extern void vacuum_set_xid_limits(VacuumStmt *vacstmt, bool sharedRel,
- TransactionId *oldestXmin,
- TransactionId *freezeLimit);
+ TransactionId *oldestXmin,
+ TransactionId *freezeLimit);
extern bool vac_is_partial_index(Relation indrel);
extern void vac_init_rusage(VacRUsage *ru0);
extern const char *vac_show_rusage(VacRUsage *ru0);
/* in commands/analyze.c */
extern void analyze_rel(Oid relid, VacuumStmt *vacstmt);
-
#endif /* VACUUM_H */
* Headers for handling of 'SET var TO', 'SHOW var' and 'RESET var'
* statements
*
- * $Id: variable.h,v 1.14 2001/10/18 17:30:16 thomas Exp $
+ * $Id: variable.h,v 1.15 2001/10/25 05:49:59 momjian Exp $
*
*/
#ifndef VARIABLE_H
extern void set_default_datestyle(void);
extern void set_default_client_encoding(void);
-
#endif /* VARIABLE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: version.h,v 1.9 2001/01/24 19:43:23 momjian Exp $
+ * $Id: version.h,v 1.10 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef VERSION_H
#define VERSION_H
-
#endif /* VERSION_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: view.h,v 1.10 2001/08/12 21:35:19 tgl Exp $
+ * $Id: view.h,v 1.11 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void DefineView(char *view_name, Query *view_parse);
extern void RemoveView(char *view_name);
-
#endif /* VIEW_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: execFlatten.h,v 1.14 2001/03/22 04:00:44 momjian Exp $
+ * $Id: execFlatten.h,v 1.15 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void ExecEvalFjoin(TargetEntry *tlist, ExprContext *econtext,
bool *isNullVect, ExprDoneCond *fj_isDone);
-
#endif /* EXECFLATTEN_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: execdebug.h,v 1.16 2001/09/20 21:07:57 tgl Exp $
+ * $Id: execdebug.h,v 1.17 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define MJ_DEBUG_QUAL(clause, res)
#define MJ_DEBUG_MERGE_COMPARE(qual, res)
#define MJ_DEBUG_PROC_NODE(slot)
-
#endif /* EXEC_MERGEJOINDEBUG */
/* ----------------------------------------------------------------
extern long NDirectFileRead;
extern long NDirectFileWrite;
-
#endif /* ExecDebugIncluded */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: execdefs.h,v 1.8 2001/01/24 19:43:23 momjian Exp $
+ * $Id: execdefs.h,v 1.9 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define EXEC_MJ_SKIPINNER_ADVANCE 13
#define EXEC_MJ_ENDOUTER 14
#define EXEC_MJ_ENDINNER 15
-
#endif /* EXECDEFS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: execdesc.h,v 1.14 2001/01/24 19:43:23 momjian Exp $
+ * $Id: execdesc.h,v 1.15 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* in pquery.c */
extern QueryDesc *CreateQueryDesc(Query *parsetree, Plan *plantree,
CommandDest dest);
-
#endif /* EXECDESC_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: executor.h,v 1.58 2001/05/27 20:48:51 tgl Exp $
+ * $Id: executor.h,v 1.59 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* prototypes from functions in execJunk.c
*/
extern JunkFilter *ExecInitJunkFilter(List *targetList, TupleDesc tupType,
- TupleTableSlot *slot);
+ TupleTableSlot *slot);
extern void ExecFreeJunkFilter(JunkFilter *junkfilter);
extern bool ExecGetJunkAttribute(JunkFilter *junkfilter, TupleTableSlot *slot,
char *attrName, Datum *value, bool *isNull);
extern void ExecCloseIndices(ResultRelInfo *resultRelInfo);
extern void ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid,
EState *estate, bool is_update);
-
#endif /* EXECUTOR_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: functions.h,v 1.15 2001/01/24 19:43:23 momjian Exp $
+ * $Id: functions.h,v 1.16 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "fmgr.h"
extern Datum fmgr_sql(PG_FUNCTION_ARGS);
-
#endif /* FUNCTIONS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: hashjoin.h,v 1.22 2001/03/22 04:00:44 momjian Exp $
+ * $Id: hashjoin.h,v 1.23 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
} HashTableData;
typedef HashTableData *HashJoinTable;
-
#endif /* HASHJOIN_H */
*
* Copyright (c) 2001, PostgreSQL Global Development Group
*
- * $Id: instrument.h,v 1.1 2001/09/18 01:59:06 tgl Exp $
+ * $Id: instrument.h,v 1.2 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef struct Instrumentation
{
/* Info about current plan cycle: */
- bool running; /* TRUE if we've completed first tuple */
+ bool running; /* TRUE if we've completed first tuple */
struct timeval starttime; /* Start time of current iteration of node */
struct timeval counter; /* Accumulates runtime for this node */
- double firsttuple; /* Time for first tuple of this cycle */
- double tuplecount; /* Tuples so far this cycle */
+ double firsttuple; /* Time for first tuple of this cycle */
+ double tuplecount; /* Tuples so far this cycle */
/* Accumulated statistics across all completed cycles: */
- double startup; /* Total startup time (in seconds) */
- double total; /* Total total time (in seconds) */
- double ntuples; /* Total tuples produced */
- double nloops; /* # of run cycles for this node */
+ double startup; /* Total startup time (in seconds) */
+ double total; /* Total total time (in seconds) */
+ double ntuples; /* Total tuples produced */
+ double nloops; /* # of run cycles for this node */
} Instrumentation;
extern Instrumentation *InstrAlloc(void);
extern void InstrStartNode(Instrumentation *instr);
extern void InstrStopNode(Instrumentation *instr, bool returnedTuple);
extern void InstrEndLoop(Instrumentation *instr);
-
-#endif /* INSTRUMENT_H */
+#endif /* INSTRUMENT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeAgg.h,v 1.12 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeAgg.h,v 1.13 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int ExecCountSlotsAgg(Agg *node);
extern void ExecEndAgg(Agg *node);
extern void ExecReScanAgg(Agg *node, ExprContext *exprCtxt, Plan *parent);
-
#endif /* NODEAGG_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeAppend.h,v 1.13 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeAppend.h,v 1.14 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern TupleTableSlot *ExecProcAppend(Append *node);
extern void ExecEndAppend(Append *node);
extern void ExecReScanAppend(Append *node, ExprContext *exprCtxt, Plan *parent);
-
#endif /* NODEAPPEND_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeGroup.h,v 1.18 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeGroup.h,v 1.19 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern FmgrInfo *execTuplesMatchPrepare(TupleDesc tupdesc,
int numCols,
AttrNumber *matchColIdx);
-
#endif /* NODEGROUP_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeHash.h,v 1.20 2001/06/11 00:17:07 tgl Exp $
+ * $Id: nodeHash.h,v 1.21 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void ExecHashTableReset(HashJoinTable hashtable, long ntuples);
extern void ExecReScanHash(Hash *node, ExprContext *exprCtxt, Plan *parent);
extern void ExecChooseHashTableSize(double ntuples, int tupwidth,
- int *virtualbuckets,
- int *physicalbuckets,
- int *numbatches);
-
+ int *virtualbuckets,
+ int *physicalbuckets,
+ int *numbatches);
#endif /* NODEHASH_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeHashjoin.h,v 1.19 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeHashjoin.h,v 1.20 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void ExecEndHashJoin(HashJoin *node);
extern void ExecHashJoinSaveTuple(HeapTuple heapTuple, BufFile *file);
extern void ExecReScanHashJoin(HashJoin *node, ExprContext *exprCtxt, Plan *parent);
-
#endif /* NODEHASHJOIN_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeIndexscan.h,v 1.11 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeIndexscan.h,v 1.12 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent);
extern int ExecCountSlotsIndexScan(IndexScan *node);
extern void ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent);
-
#endif /* NODEINDEXSCAN_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeLimit.h,v 1.2 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeLimit.h,v 1.3 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int ExecCountSlotsLimit(Limit *node);
extern void ExecEndLimit(Limit *node);
extern void ExecReScanLimit(Limit *node, ExprContext *exprCtxt, Plan *parent);
-
#endif /* NODELIMIT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeMaterial.h,v 1.14 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeMaterial.h,v 1.15 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void ExecMaterialMarkPos(Material *node);
extern void ExecMaterialRestrPos(Material *node);
extern void ExecMaterialReScan(Material *node, ExprContext *exprCtxt, Plan *parent);
-
#endif /* NODEMATERIAL_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeMergejoin.h,v 1.13 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeMergejoin.h,v 1.14 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int ExecCountSlotsMergeJoin(MergeJoin *node);
extern void ExecEndMergeJoin(MergeJoin *node);
extern void ExecReScanMergeJoin(MergeJoin *node, ExprContext *exprCtxt, Plan *parent);
-
#endif /* NODEMERGEJOIN_H; */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeNestloop.h,v 1.14 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeNestloop.h,v 1.15 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void ExecEndNestLoop(NestLoop *node);
extern void ExecReScanNestLoop(NestLoop *node, ExprContext *exprCtxt,
Plan *parent);
-
#endif /* NODENESTLOOP_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeResult.h,v 1.11 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeResult.h,v 1.12 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int ExecCountSlotsResult(Result *node);
extern void ExecEndResult(Result *node);
extern void ExecReScanResult(Result *node, ExprContext *exprCtxt, Plan *parent);
-
#endif /* NODERESULT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeSeqscan.h,v 1.11 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeSeqscan.h,v 1.12 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void ExecSeqReScan(SeqScan *node, ExprContext *exprCtxt, Plan *parent);
extern void ExecSeqMarkPos(SeqScan *node);
extern void ExecSeqRestrPos(SeqScan *node);
-
#endif /* NODESEQSCAN_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeSetOp.h,v 1.2 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeSetOp.h,v 1.3 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int ExecCountSlotsSetOp(SetOp *node);
extern void ExecEndSetOp(SetOp *node);
extern void ExecReScanSetOp(SetOp *node, ExprContext *exprCtxt, Plan *parent);
-
#endif /* NODESETOP_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeSort.h,v 1.11 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeSort.h,v 1.12 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void ExecSortMarkPos(Sort *node);
extern void ExecSortRestrPos(Sort *node);
extern void ExecReScanSort(Sort *node, ExprContext *exprCtxt, Plan *parent);
-
#endif /* NODESORT_H */
extern void ExecReScanSetParamPlan(SubPlan *node, Plan *parent);
extern void ExecSetParamPlan(SubPlan *node, ExprContext *econtext);
extern void ExecEndSubPlan(SubPlan *node);
-
#endif /* NODESUBPLAN_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeSubqueryscan.h,v 1.2 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeSubqueryscan.h,v 1.3 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool ExecInitSubqueryScan(SubqueryScan *node, EState *estate, Plan *parent);
extern int ExecCountSlotsSubqueryScan(SubqueryScan *node);
extern void ExecSubqueryReScan(SubqueryScan *node, ExprContext *exprCtxt, Plan *parent);
-
#endif /* NODESUBQUERYSCAN_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeTidscan.h,v 1.5 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeTidscan.h,v 1.6 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool ExecInitTidScan(TidScan *node, EState *estate, Plan *parent);
extern int ExecCountSlotsTidScan(TidScan *node);
extern void ExecTidReScan(TidScan *node, ExprContext *exprCtxt, Plan *parent);
-
#endif /* NODETIDSCAN_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeUnique.h,v 1.11 2001/01/24 19:43:23 momjian Exp $
+ * $Id: nodeUnique.h,v 1.12 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int ExecCountSlotsUnique(Unique *node);
extern void ExecEndUnique(Unique *node);
extern void ExecReScanUnique(Unique *node, ExprContext *exprCtxt, Plan *parent);
-
#endif /* NODEUNIQUE_H */
*
* spi.h
*
- * $Id: spi.h,v 1.28 2001/08/02 18:08:43 tgl Exp $
+ * $Id: spi.h,v 1.29 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int SPI_execp(void *plan, Datum *values, char *Nulls, int tcount);
extern void *SPI_prepare(char *src, int nargs, Oid *argtypes);
extern void *SPI_saveplan(void *plan);
-extern int SPI_freeplan(void *plan);
+extern int SPI_freeplan(void *plan);
extern HeapTuple SPI_copytuple(HeapTuple tuple);
extern TupleDesc SPI_copytupledesc(TupleDesc tupdesc);
extern void SPI_freetuple(HeapTuple pointer);
extern void SPI_freetuptable(SPITupleTable *tuptable);
-extern Portal SPI_cursor_open(char *name, void *plan,
+extern Portal SPI_cursor_open(char *name, void *plan,
Datum *Values, char *Nulls);
extern Portal SPI_cursor_find(char *name);
-extern void SPI_cursor_fetch(Portal portal, bool forward, int count);
-extern void SPI_cursor_move(Portal portal, bool forward, int count);
-extern void SPI_cursor_close(Portal portal);
+extern void SPI_cursor_fetch(Portal portal, bool forward, int count);
+extern void SPI_cursor_move(Portal portal, bool forward, int count);
+extern void SPI_cursor_close(Portal portal);
extern void AtEOXact_SPI(void);
-
#endif /* SPI_H */
* spi.c
* Server Programming Interface private declarations
*
- * $Header: /cvsroot/pgsql/src/include/executor/spi_priv.h,v 1.8 2001/05/21 14:22:18 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/include/executor/spi_priv.h,v 1.9 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define _SPI_CPLAN_CURCXT 0
#define _SPI_CPLAN_PROCXT 1
#define _SPI_CPLAN_TOPCXT 2
-
#endif /* SPI_PRIV_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: tuptable.h,v 1.18 2001/01/29 00:39:20 tgl Exp $
+ * $Id: tuptable.h,v 1.19 2001/10/25 05:49:59 momjian Exp $
*
* NOTES
* The tuple table interface is getting pretty ugly.
} TupleTableData;
typedef TupleTableData *TupleTable;
-
#endif /* TUPTABLE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: fmgr.h,v 1.15 2001/10/06 23:21:44 tgl Exp $
+ * $Id: fmgr.h,v 1.16 2001/10/25 05:49:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* and used to hold all subsidiary data of finfo.
*/
extern void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo,
- MemoryContext mcxt);
+ MemoryContext mcxt);
/*
* Copy an FmgrInfo struct
*/
extern void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo,
- MemoryContext destcxt);
+ MemoryContext destcxt);
/*
* This macro invokes a function given a filled-in FunctionCallInfoData
/*
* Routines in dfmgr.c
*/
-extern char * Dynamic_library_path;
+extern char *Dynamic_library_path;
extern PGFunction load_external_function(char *filename, char *funcname,
bool signalNotFound, void **filehandle);
* DEPRECATED, DO NOT USE IN NEW CODE
*/
extern char *fmgr(Oid procedureId,...);
-
#endif /* FMGR_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: dllist.h,v 1.16 2001/03/22 04:00:46 momjian Exp $
+ * $Id: dllist.h,v 1.17 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern Dlelem *DLNewElem(void *val);
extern void DLInitElem(Dlelem *e, void *val);
extern void DLFreeElem(Dlelem *e);
-extern void DLRemove(Dlelem *e);/* removes node from list */
+extern void DLRemove(Dlelem *e); /* removes node from list */
extern void DLAddHead(Dllist *list, Dlelem *node);
extern void DLAddTail(Dllist *list, Dlelem *node);
extern Dlelem *DLRemHead(Dllist *list); /* remove and return the head */
#define DLGetListHdr(elem) ((elem)->dle_list)
#define DLE_VAL(elem) ((elem)->dle_val)
-
#endif /* DLLIST_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: lispsort.h,v 1.7 2001/01/24 19:43:24 momjian Exp $
+ * $Id: lispsort.h,v 1.8 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef LISPSORT_H
#define LISPSORT_H
-
#endif /* LISPSORT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: stringinfo.h,v 1.20 2001/10/03 21:58:28 tgl Exp $
+ * $Id: stringinfo.h,v 1.21 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* to str if necessary. This is sort of like a combination of sprintf and
* strcat.
*/
-extern void appendStringInfo(StringInfo str, const char *fmt, ...)
+extern void
+appendStringInfo(StringInfo str, const char *fmt,...)
/* This extension allows gcc to check the format string */
__attribute__((format(printf, 2, 3)));
*/
extern void appendBinaryStringInfo(StringInfo str,
const char *data, int datalen);
-
#endif /* STRINGINFO_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: auth.h,v 1.17 2001/06/20 18:07:56 petere Exp $
+ * $Id: auth.h,v 1.18 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define PG_KRB5_VERSION "PGVER5.1"
extern char *pg_krb_server_keyfile;
-
#endif /* AUTH_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: be-fsstubs.h,v 1.12 2001/01/24 19:43:24 momjian Exp $
+ * $Id: be-fsstubs.h,v 1.13 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* Cleanup LOs at xact commit/abort [ Pascal André
]
*/
extern void lo_commit(bool isCommit);
-
#endif /* BE_FSSTUBS_H */
extern char *crypt_getpwdfilename(void);
extern char *crypt_getpwdreloadfilename(void);
-extern int md5_crypt_verify(const Port *port, const char *user, const char *pgpass);
+extern int md5_crypt_verify(const Port *port, const char *user, const char *pgpass);
extern bool md5_hash(const void *buff, size_t len, char *hexsum);
extern bool CheckMD5Pwd(char *passwd, char *storedpwd, char *seed);
-extern bool EncryptMD5(const char *passwd, const char *salt,
- size_t salt_len, char *buf);
+extern bool EncryptMD5(const char *passwd, const char *salt,
+ size_t salt_len, char *buf);
#define MD5_PASSWD_LEN 35
#define isMD5(passwd) (strncmp((passwd),"md5",3) == 0 && \
strlen(passwd) == MD5_PASSWD_LEN)
-
#endif
* Interface to hba.c
*
*
- * $Id: hba.h,v 1.28 2001/10/01 02:26:36 ishii Exp $
+ * $Id: hba.h,v 1.29 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef enum UserAuth
{
- uaReject,
- uaKrb4,
- uaKrb5,
- uaTrust,
- uaIdent,
- uaPassword,
- uaCrypt,
- uaMD5
+ uaReject,
+ uaKrb4,
+ uaKrb5,
+ uaTrust,
+ uaIdent,
+ uaPassword,
+ uaCrypt,
+ uaMD5
#ifdef USE_PAM
- ,uaPAM
-#endif /* USE_PAM */
+ ,uaPAM
+#endif /* USE_PAM */
} UserAuth;
typedef struct Port hbaPort;
-extern int hba_getauthmethod(hbaPort *port);
-extern int authident(hbaPort *port);
+extern int hba_getauthmethod(hbaPort *port);
+extern int authident(hbaPort *port);
extern void load_hba_and_ident(void);
-
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq-be.h,v 1.22 2001/08/17 02:59:19 momjian Exp $
+ * $Id: libpq-be.h,v 1.23 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef enum
{
- Idle,
- ReadingPacketLength,
- ReadingPacket,
- WritingPacket
+ Idle,
+ ReadingPacketLength,
+ ReadingPacket,
+ WritingPacket
} PacketState;
typedef int (*PacketDoneProc) (void *arg, PacketLen pktlen, void *pktdata);
SockAddr laddr; /* local addr (us) */
SockAddr raddr; /* remote addr (them) */
char md5Salt[4]; /* Password salt */
- char cryptSalt[2]; /* Password salt */
+ char cryptSalt[2]; /* Password salt */
/*
* Information that needs to be held during the fe/be authentication
void PacketSendSetup(Packet *pkt, int nbytes, PacketDoneProc iodone, void *arg);
int PacketSendFragment(Port *port);
void PacketSendError(Packet *pkt, char *errormsg);
-
#endif /* LIBPQ_BE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq-fs.h,v 1.12 2001/02/10 02:31:28 tgl Exp $
+ * $Id: libpq-fs.h,v 1.13 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define INV_WRITE 0x00020000
#define INV_READ 0x00040000
-
#endif /* LIBPQ_FS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq.h,v 1.45 2001/08/07 10:44:16 petere Exp $
+ * $Id: libpq.h,v 1.46 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void pqdebug(char *fmt, char *msg);
extern void PQtrace(void);
extern void PQuntrace(void);
-
#endif /* LIBPQ_H */
#define PASSWORD_H
int verify_password(const Port *port, const char *user, const char *password);
-
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqcomm.h,v 1.59 2001/09/06 03:18:12 momjian Exp $
+ * $Id: pqcomm.h,v 1.60 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
short int sun_family; /* AF_UNIX */
char sun_path[108]; /* path name (gag) */
};
-
#endif
/* Define a generic socket address type. */
*/
#define NEGOTIATE_SSL_CODE PG_PROTOCOL(1234,5679)
-
#endif /* PQCOMM_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqformat.h,v 1.8 2001/01/24 19:43:25 momjian Exp $
+ * $Id: pqformat.h,v 1.9 2001/10/25 05:49:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int pq_getint(int *result, int b);
extern int pq_getstr(StringInfo s);
-
#endif /* PQFORMAT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqsignal.h,v 1.16 2001/09/07 16:12:49 wieck Exp $
+ * $Id: pqsignal.h,v 1.17 2001/10/25 05:49:59 momjian Exp $
*
* NOTES
* This shouldn't be in libpq, but the monitor and some other
extern void pqinitmask(void);
extern pqsigfunc pqsignal(int signo, pqsigfunc func);
-
#endif /* PQSIGNAL_H */
-/* $Id: pg_wchar.h,v 1.34 2001/10/16 10:09:17 ishii Exp $ */
+/* $Id: pg_wchar.h,v 1.35 2001/10/25 05:49:59 momjian Exp $ */
#ifndef PG_WCHAR_H
#define PG_WCHAR_H
#endif
/*
- * The pg_wchar
+ * The pg_wchar
*/
#ifdef MULTIBYTE
typedef unsigned int pg_wchar;
+
#else
#define pg_wchar char
#endif
/*
* Leading byte types or leading prefix byte for MULE internal code.
- * See http://www.xemacs.org for more details. (there is a doc titled
+ * See http://www.xemacs.org for more details. (there is a doc titled
* "XEmacs Internals Manual", "MULE Character Sets and Encodings"
* section.
*/
#define LC_ISO8859_2 0x82 /* ISO8859 Latin 2 */
#define LC_ISO8859_3 0x83 /* ISO8859 Latin 3 */
#define LC_ISO8859_4 0x84 /* ISO8859 Latin 4 */
-#define LC_TIS620 0x85 /* Thai (not supported yet) */
-#define LC_ISO8859_7 0x86 /* Greek (not supported yet) */
-#define LC_ISO8859_6 0x87 /* Arabic (not supported yet) */
-#define LC_ISO8859_8 0x88 /* Hebrew (not supported yet) */
+#define LC_TIS620 0x85 /* Thai (not supported yet) */
+#define LC_ISO8859_7 0x86 /* Greek (not supported yet) */
+#define LC_ISO8859_6 0x87 /* Arabic (not supported yet) */
+#define LC_ISO8859_8 0x88 /* Hebrew (not supported yet) */
#define LC_JISX0201K 0x89 /* Japanese 1 byte kana */
#define LC_JISX0201R 0x8a /* Japanese 1 byte Roman */
/* Note that 0x8b seems to be unused in as of Emacs 20.7.
* However, there might be a chance that 0x8b could be used
* in later version of Emacs.
*/
-#define LC_KOI8_R 0x8b /* Cyrillic KOI8-R */
-#define LC_KOI8_U 0x8b /* Cyrillic KOI8-U */
+#define LC_KOI8_R 0x8b /* Cyrillic KOI8-R */
+#define LC_KOI8_U 0x8b /* Cyrillic KOI8-U */
#define LC_ISO8859_5 0x8c /* ISO8859 Cyrillic */
#define LC_ISO8859_9 0x8d /* ISO8859 Latin 5 (not supported yet) */
/* #define FREE 0x8e free (unused) */
/*
* Unused
*/
-#define CONTROL_1 0x8f /* control characters (unused) */
+#define CONTROL_1 0x8f /* control characters (unused) */
/*
* Official multibyte byte encodings (0x90-0x99)
* 0x9a-0x9d are free. 0x9e and 0x9f are reserved.
*/
-#define LC_JISX0208_1978 0x90 /* Japanese Kanji, old JIS (not supported) */
+#define LC_JISX0208_1978 0x90/* Japanese Kanji, old JIS (not supported) */
/* #define FREE 0x90 free (unused) */
#define LC_GB2312_80 0x91 /* Chinese */
-#define LC_JISX0208 0x92 /* Japanese Kanji (JIS X 0208) */
-#define LC_KS5601 0x93 /* Korean */
-#define LC_JISX0212 0x94 /* Japanese Kanji (JIS X 0212) */
+#define LC_JISX0208 0x92 /* Japanese Kanji (JIS X 0208) */
+#define LC_KS5601 0x93 /* Korean */
+#define LC_JISX0212 0x94 /* Japanese Kanji (JIS X 0212) */
#define LC_CNS11643_1 0x95 /* CNS 11643-1992 Plane 1 */
#define LC_CNS11643_2 0x96 /* CNS 11643-1992 Plane 2 */
/* #define FREE 0x97 free (unused) */
-#define LC_BIG5_1 0x98 /* Plane 1 Chinese traditional (not supported) */
-#define LC_BIG5_2 0x99 /* Plane 1 Chinese traditional (not supported) */
+#define LC_BIG5_1 0x98 /* Plane 1 Chinese traditional (not
+ * supported) */
+#define LC_BIG5_2 0x99 /* Plane 1 Chinese traditional (not
+ * supported) */
/*
* Private single byte encodings (0xa0-0xef)
*/
-#define LC_SISHENG 0xa0 /* Chinese SiSheng characters for PinYin/ZhuYin
- (not supported) */
-#define LC_IPA 0xa1 /* IPA (International Phonetic Association)
- (not supported) */
-#define LC_VISCII_LOWER 0xa2 /* Vietnamese VISCII1.1 lower-case (not supported) */
-#define LC_VISCII_UPPER 0xa3 /* Vietnamese VISCII1.1 upper-case (not supported) */
-#define LC_ARABIC_DIGIT 0xa4 /* Arabic digit (not supported) */
-#define LC_ARABIC_1_COLUMN 0xa5 /* Arabic 1-column (not supported) */
-#define LC_ASCII_RIGHT_TO_LEFT 0xa6 /* ASCII (left half of ISO8859-1)
- with right-to-left direction
- (not supported) */
-#define LC_LAO 0xa7 /* Lao characters (ISO10646 0E80..0EDF)
- (not supported) */
-#define LC_ARABIC_2_COLUMN 0xa8 /* Arabic 1-column (not supported) */
+#define LC_SISHENG 0xa0 /* Chinese SiSheng characters for
+ * PinYin/ZhuYin (not supported) */
+#define LC_IPA 0xa1 /* IPA (International Phonetic
+ * Association) (not supported) */
+#define LC_VISCII_LOWER 0xa2 /* Vietnamese VISCII1.1 lower-case (not
+ * supported) */
+#define LC_VISCII_UPPER 0xa3 /* Vietnamese VISCII1.1 upper-case (not
+ * supported) */
+#define LC_ARABIC_DIGIT 0xa4 /* Arabic digit (not supported) */
+#define LC_ARABIC_1_COLUMN 0xa5/* Arabic 1-column (not supported) */
+#define LC_ASCII_RIGHT_TO_LEFT 0xa6 /* ASCII (left half of ISO8859-1)
+ * with right-to-left direction
+ * (not supported) */
+#define LC_LAO 0xa7 /* Lao characters (ISO10646 0E80..0EDF)
+ * (not supported) */
+#define LC_ARABIC_2_COLUMN 0xa8/* Arabic 1-column (not supported) */
/*
* Private multi byte encodings (0xf0-0xff)
*/
-#define LC_INDIAN_1_COLUMN 0xf0 /* Indian charset for 1-column
- width glypps (not supported) */
-#define LC_TIBETAN_1_COLUMN 0xf1 /* Tibetan 1 column glyph
- (not supported) */
-#define LC_ETHIOPIC 0xf5 /* Ethiopic characters (not supported) */
+#define LC_INDIAN_1_COLUMN 0xf0/* Indian charset for 1-column width
+ * glypps (not supported) */
+#define LC_TIBETAN_1_COLUMN 0xf1/* Tibetan 1 column glyph (not supported) */
+#define LC_ETHIOPIC 0xf5 /* Ethiopic characters (not supported) */
#define LC_CNS11643_3 0xf6 /* CNS 11643-1992 Plane 3 */
#define LC_CNS11643_4 0xf7 /* CNS 11643-1992 Plane 4 */
#define LC_CNS11643_5 0xf8 /* CNS 11643-1992 Plane 5 */
#define LC_CNS11643_6 0xf9 /* CNS 11643-1992 Plane 6 */
#define LC_CNS11643_7 0xfa /* CNS 11643-1992 Plane 7 */
-#define LC_INDIAN_2_COLUMN 0xfb /* Indian charset for 2-column
- width glypps (not supported) */
-#define LC_TIBETAN 0xfc /* Tibetan (not supported) */
+#define LC_INDIAN_2_COLUMN 0xfb/* Indian charset for 2-column width
+ * glypps (not supported) */
+#define LC_TIBETAN 0xfc /* Tibetan (not supported) */
/* #define FREE 0xfd free (unused) */
/* #define FREE 0xfe free (unused) */
/* #define FREE 0xff free (unused) */
/*
* Encoding numeral identificators
*
- * WARNING: the order of this table must be same as order
- * in the pg_enconv[] (mb/conv.c) and pg_enc2name[] (mb/encnames.c) array!
+ * WARNING: the order of this table must be same as order
+ * in the pg_enconv[] (mb/conv.c) and pg_enc2name[] (mb/encnames.c) array!
*
- * If you add some encoding don'y forget check
- * PG_ENCODING_[BE|FE]_LAST macros.
+ * If you add some encoding don'y forget check
+ * PG_ENCODING_[BE|FE]_LAST macros.
*
- * The PG_SQL_ASCII is default encoding and must be = 0.
+ * The PG_SQL_ASCII is default encoding and must be = 0.
*/
typedef enum pg_enc
{
- PG_SQL_ASCII = 0, /* SQL/ASCII */
- PG_EUC_JP, /* EUC for Japanese */
- PG_EUC_CN, /* EUC for Chinese */
- PG_EUC_KR, /* EUC for Korean */
- PG_EUC_TW, /* EUC for Taiwan */
- PG_UTF8, /* Unicode UTF-8 */
- PG_MULE_INTERNAL, /* Mule internal code */
- PG_LATIN1, /* ISO-8859-1 Latin 1 */
- PG_LATIN2, /* ISO-8859-2 Latin 2 */
- PG_LATIN3, /* ISO-8859-3 Latin 3 */
- PG_LATIN4, /* ISO-8859-4 Latin 4 */
- PG_LATIN5, /* ISO-8859-9 Latin 5 */
- PG_LATIN6, /* ISO-8859-10 Latin6 */
- PG_LATIN7, /* ISO-8859-13 Latin7 */
- PG_LATIN8, /* ISO-8859-14 Latin8 */
- PG_LATIN9, /* ISO-8859-15 Latin9 */
- PG_LATIN10, /* ISO-8859-16 Latin10 */
- PG_KOI8R, /* KOI8-R */
- PG_WIN1251, /* windows-1251 (was: WIN) */
- PG_ALT, /* (MS-DOS CP866) */
- PG_ISO_8859_5, /* ISO-8859-5 */
- PG_ISO_8859_6, /* ISO-8859-6 */
- PG_ISO_8859_7, /* ISO-8859-7 */
- PG_ISO_8859_8, /* ISO-8859-8 */
+ PG_SQL_ASCII = 0, /* SQL/ASCII */
+ PG_EUC_JP, /* EUC for Japanese */
+ PG_EUC_CN, /* EUC for Chinese */
+ PG_EUC_KR, /* EUC for Korean */
+ PG_EUC_TW, /* EUC for Taiwan */
+ PG_UTF8, /* Unicode UTF-8 */
+ PG_MULE_INTERNAL, /* Mule internal code */
+ PG_LATIN1, /* ISO-8859-1 Latin 1 */
+ PG_LATIN2, /* ISO-8859-2 Latin 2 */
+ PG_LATIN3, /* ISO-8859-3 Latin 3 */
+ PG_LATIN4, /* ISO-8859-4 Latin 4 */
+ PG_LATIN5, /* ISO-8859-9 Latin 5 */
+ PG_LATIN6, /* ISO-8859-10 Latin6 */
+ PG_LATIN7, /* ISO-8859-13 Latin7 */
+ PG_LATIN8, /* ISO-8859-14 Latin8 */
+ PG_LATIN9, /* ISO-8859-15 Latin9 */
+ PG_LATIN10, /* ISO-8859-16 Latin10 */
+ PG_KOI8R, /* KOI8-R */
+ PG_WIN1251, /* windows-1251 (was: WIN) */
+ PG_ALT, /* (MS-DOS CP866) */
+ PG_ISO_8859_5, /* ISO-8859-5 */
+ PG_ISO_8859_6, /* ISO-8859-6 */
+ PG_ISO_8859_7, /* ISO-8859-7 */
+ PG_ISO_8859_8, /* ISO-8859-8 */
/* followings are for client encoding only */
- PG_SJIS, /* Shift JIS */
- PG_BIG5, /* Big5 */
- PG_WIN1250, /* windows-1250 */
+ PG_SJIS, /* Shift JIS */
+ PG_BIG5, /* Big5 */
+ PG_WIN1250, /* windows-1250 */
- _PG_LAST_ENCODING_ /* mark only */
+ _PG_LAST_ENCODING_ /* mark only */
} pg_enc;
-#define PG_ENCODING_BE_LAST PG_ISO_8859_8
-#define PG_ENCODING_FE_LAST PG_WIN1250
+#define PG_ENCODING_BE_LAST PG_ISO_8859_8
+#define PG_ENCODING_FE_LAST PG_WIN1250
#ifdef MULTIBYTE
/*
- * Please use these tests before access to pg_encconv_tbl[]
+ * Please use these tests before access to pg_encconv_tbl[]
* or to other places...
*/
#define PG_VALID_BE_ENCODING(_enc) \
- ((_enc) >= 0 && (_enc) <= PG_ENCODING_BE_LAST)
-
+ ((_enc) >= 0 && (_enc) <= PG_ENCODING_BE_LAST)
+
#define PG_ENCODING_IS_CLIEN_ONLY(_enc) \
(((_enc) > PG_ENCODING_BE_LAST && (_enc) <= PG_ENCODING_FE_LAST)
#define PG_VALID_ENCODING(_enc) \
((_enc) >= 0 && (_enc) < _PG_LAST_ENCODING_)
-/* On FE are possible all encodings
+/* On FE are possible all encodings
*/
-#define PG_VALID_FE_ENCODING(_enc) PG_VALID_ENCODING(_enc)
+#define PG_VALID_FE_ENCODING(_enc) PG_VALID_ENCODING(_enc)
-/*
+/*
* Encoding names with all aliases
*/
typedef struct pg_encname
{
- char *name;
- pg_enc encoding;
+ char *name;
+ pg_enc encoding;
} pg_encname;
-extern pg_encname pg_encname_tbl[];
-extern unsigned int pg_encname_tbl_sz;
+extern pg_encname pg_encname_tbl[];
+extern unsigned int pg_encname_tbl_sz;
/*
* Careful:
*/
typedef struct pg_enc2name
{
- char *name;
- pg_enc encoding;
+ char *name;
+ pg_enc encoding;
} pg_enc2name;
-extern pg_enc2name pg_enc2name_tbl[];
+extern pg_enc2name pg_enc2name_tbl[];
-extern pg_encname *pg_char_to_encname_struct(const char *name);
+extern pg_encname *pg_char_to_encname_struct(const char *name);
-extern int pg_char_to_encoding(const char *s);
-extern const char *pg_encoding_to_char(int encoding);
+extern int pg_char_to_encoding(const char *s);
+extern const char *pg_encoding_to_char(int encoding);
typedef void (*to_mic_converter) (unsigned char *l, unsigned char *p, int len);
typedef void (*from_mic_converter) (unsigned char *mic, unsigned char *p, int len);
#ifndef FRONTEND
typedef struct pg_enconv
{
- pg_enc encoding; /* encoding identifier */
- to_mic_converter to_mic; /* client encoding to MIC */
- from_mic_converter from_mic; /* MIC to client encoding */
- to_mic_converter to_unicode; /* client encoding to UTF-8 */
- from_mic_converter from_unicode; /* UTF-8 to client encoding */
+ pg_enc encoding; /* encoding identifier */
+ to_mic_converter to_mic; /* client encoding to MIC */
+ from_mic_converter from_mic; /* MIC to client encoding */
+ to_mic_converter to_unicode; /* client encoding to UTF-8 */
+ from_mic_converter from_unicode; /* UTF-8 to client encoding */
} pg_enconv;
extern pg_enconv pg_enconv_tbl[];
extern pg_enconv *pg_get_enconv_by_encoding(int encoding);
-
-#endif /* FRONTEND */
+#endif /* FRONTEND */
/*
* pg_wchar stuff
*/
typedef int (*mb2wchar_with_len_converter) (const unsigned char *from,
- pg_wchar *to,
- int len);
+ pg_wchar *to,
+ int len);
typedef int (*mblen_converter) (const unsigned char *mbstr);
typedef struct
{
- mb2wchar_with_len_converter mb2wchar_with_len; /* convert a multi-byte string to a wchar */
+ mb2wchar_with_len_converter mb2wchar_with_len; /* convert a multi-byte
+ * string to a wchar */
mblen_converter mblen; /* returns the length of a multi-byte char */
- int maxmblen; /* max bytes for a char in this charset */
+ int maxmblen; /* max bytes for a char in this charset */
} pg_wchar_tbl;
extern pg_wchar_tbl pg_wchar_table[];
*/
typedef struct
{
- unsigned int utf; /* UTF-8 */
- unsigned int code; /* local code */
+ unsigned int utf; /* UTF-8 */
+ unsigned int code; /* local code */
} pg_utf_to_local;
/*
*/
typedef struct
{
- unsigned int code; /* local code */
- unsigned int utf; /* UTF-8 */
+ unsigned int code; /* local code */
+ unsigned int utf; /* UTF-8 */
} pg_local_to_utf;
extern int pg_mb2wchar(const unsigned char *, pg_wchar *);
extern int pg_char_and_wchar_strcmp(const char *, const pg_wchar *);
extern int pg_wchar_strncmp(const pg_wchar *, const pg_wchar *, size_t);
extern int pg_char_and_wchar_strncmp(const char *, const pg_wchar *, size_t);
-extern size_t pg_wchar_strlen(const pg_wchar *);
+extern size_t pg_wchar_strlen(const pg_wchar *);
extern int pg_mblen(const unsigned char *);
extern int pg_encoding_mblen(int, const unsigned char *);
extern int pg_mule_mblen(const unsigned char *);
extern int pg_encoding_max_length(int);
extern int pg_database_encoding_max_length(void);
-extern int pg_set_client_encoding(int);
-extern int pg_get_client_encoding(void);
-extern const char *pg_get_client_encoding_name(void);
+extern int pg_set_client_encoding(int);
+extern int pg_get_client_encoding(void);
+extern const char *pg_get_client_encoding_name(void);
-extern void SetDatabaseEncoding(int);
-extern int GetDatabaseEncoding(void);
-extern const char *GetDatabaseEncodingName(void);
+extern void SetDatabaseEncoding(int);
+extern int GetDatabaseEncoding(void);
+extern const char *GetDatabaseEncodingName(void);
extern int pg_valid_client_encoding(const char *name);
extern int pg_valid_server_encoding(const char *name);
extern int pg_utf_mblen(const unsigned char *);
-extern int pg_find_encoding_converters(int src, int dest,
- to_mic_converter *src_to_mic,
- from_mic_converter *dest_from_mic);
+extern int pg_find_encoding_converters(int src, int dest,
+ to_mic_converter *src_to_mic,
+ from_mic_converter *dest_from_mic);
extern unsigned char *pg_do_encoding_conversion(unsigned char *src, int len,
- to_mic_converter src_to_mic,
- from_mic_converter dest_from_mic);
+ to_mic_converter src_to_mic,
+ from_mic_converter dest_from_mic);
extern unsigned char *pg_client_to_server(unsigned char *, int);
extern unsigned char *pg_server_to_client(unsigned char *, int);
extern unsigned short BIG5toCNS(unsigned short, unsigned char *);
extern unsigned short CNStoBIG5(unsigned short, unsigned char);
-char *pg_verifymbstr(const unsigned char *, int);
-
+char *pg_verifymbstr(const unsigned char *, int);
#endif /* MULTIBYTE */
-
#endif /* PG_WCHAR_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: miscadmin.h,v 1.94 2001/10/21 03:25:35 tgl Exp $
+ * $Id: miscadmin.h,v 1.95 2001/10/25 05:49:54 momjian Exp $
*
* NOTES
* some of the information in this file should be moved to
*
* Special mechanisms are used to let an interrupt be accepted when we are
* waiting for a lock or when we are waiting for command input (but, of
- * course, only if the interrupt holdoff counter is zero). See the
+ * course, only if the interrupt holdoff counter is zero). See the
* related code for details.
*
* A related, but conceptually distinct, mechanism is the "critical section"
extern bool Noversion;
extern char *DataDir;
-extern DLLIMPORT int MyProcPid;
+extern DLLIMPORT int MyProcPid;
extern struct Port *MyProcPort;
extern long MyCancelKey;
*
* extern BackendId MyBackendId;
*/
-extern DLLIMPORT Oid MyDatabaseId;
+extern DLLIMPORT Oid MyDatabaseId;
extern bool IsUnderPostmaster;
/*
* A few postmaster startup options are exported here so the
- * configuration file processor can access them.
+ * configuration file processor can access them.
*/
extern bool NetServer;
/* in utils/misc/superuser.c */
extern bool superuser(void); /* current user is superuser */
-extern bool is_dbadmin(Oid dbid); /* current user is owner of database */
+extern bool is_dbadmin(Oid dbid); /* current user is owner of
+ * database */
/*****************************************************************************
typedef enum ProcessingMode
{
- BootstrapProcessing, /* bootstrap creation of template database */
- InitProcessing, /* initializing system */
- NormalProcessing /* normal processing */
+ BootstrapProcessing, /* bootstrap creation of template
+ * database */
+ InitProcessing, /* initializing system */
+ NormalProcessing/* normal processing */
} ProcessingMode;
extern ProcessingMode Mode;
extern void IgnoreSystemIndexes(bool mode);
extern bool IsIgnoringSystemIndexes(void);
extern bool IsCacheInitialized(void);
-
#endif /* MISCADMIN_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: execnodes.h,v 1.63 2001/09/29 07:57:04 inoue Exp $
+ * $Id: execnodes.h,v 1.64 2001/10/25 05:50:01 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
typedef enum
{
- ExprSingleResult, /* expression does not return a set */
- ExprMultipleResult, /* this result is an element of a set */
- ExprEndResult /* there are no more elements in the set */
+ ExprSingleResult, /* expression does not return a
+ * set */
+ ExprMultipleResult, /* this result is an element of a
+ * set */
+ ExprEndResult /* there are no more elements in the set */
} ExprDoneCond;
/*
* resultSlot: tuple slot that can be used to hold cleaned tuple.
*
* NOTE: the original targetList and tupType are passed to ExecInitJunkFilter,
- * as is the resultSlot. These items do not belong to the JunkFilter. All
+ * as is the resultSlot. These items do not belong to the JunkFilter. All
* the other subsidiary structures are created during ExecInitJunkFilter,
* and all of them can be freed by deleting the memory context junkContext.
* This would not be needed if we had a cleaner approach to managing
int tss_NumTids;
int tss_TidPtr;
int tss_MarkTidPtr;
- ItemPointerData* tss_TidList;
+ ItemPointerData *tss_TidList;
HeapTupleData tss_htup;
} TidScanState;
HeapScanDesc tee_leftScanDesc,
tee_rightScanDesc;
} TeeState;
-
#endif
-
#endif /* EXECNODES_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: makefuncs.h,v 1.27 2001/01/24 19:43:25 momjian Exp $
+ * $Id: makefuncs.h,v 1.28 2001/10/25 05:50:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern Const *makeNullConst(Oid consttype);
extern Attr *makeAttr(char *relname, char *attname);
-
#endif /* MAKEFUNC_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: memnodes.h,v 1.21 2001/03/22 04:00:51 momjian Exp $
+ * $Id: memnodes.h,v 1.22 2001/10/25 05:50:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
((context) != NULL && \
(IsA((context), AllocSetContext)))
-
#endif /* MEMNODES_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeFuncs.h,v 1.13 2001/01/24 19:43:25 momjian Exp $
+ * $Id: nodeFuncs.h,v 1.14 2001/10/25 05:50:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool var_is_outer(Var *var);
extern bool var_is_rel(Var *var);
extern Oper *replace_opid(Oper *oper);
-
#endif /* NODEFUNCS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodes.h,v 1.93 2001/07/16 19:12:58 momjian Exp $
+ * $Id: nodes.h,v 1.94 2001/10/25 05:50:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
typedef enum NodeTag
{
- T_Invalid = 0,
+ T_Invalid = 0,
/*
* TAGS FOR PLAN NODES (plannodes.h)
*/
- T_Plan = 10,
- T_Result,
- T_Append,
- T_Scan,
- T_SeqScan,
- T_IndexScan,
- T_Join,
- T_NestLoop,
- T_MergeJoin,
- T_HashJoin,
- T_Limit,
- T_Material,
- T_Sort,
- T_Agg,
- T_Unique,
- T_Hash,
- T_SetOp,
- T_Group,
- T_SubPlan,
- T_TidScan,
- T_SubqueryScan,
+ T_Plan = 10,
+ T_Result,
+ T_Append,
+ T_Scan,
+ T_SeqScan,
+ T_IndexScan,
+ T_Join,
+ T_NestLoop,
+ T_MergeJoin,
+ T_HashJoin,
+ T_Limit,
+ T_Material,
+ T_Sort,
+ T_Agg,
+ T_Unique,
+ T_Hash,
+ T_SetOp,
+ T_Group,
+ T_SubPlan,
+ T_TidScan,
+ T_SubqueryScan,
/*
* TAGS FOR PRIMITIVE NODES (primnodes.h)
*/
- T_Resdom = 100,
- T_Fjoin,
- T_Expr,
- T_Var,
- T_Oper,
- T_Const,
- T_Param,
- T_Aggref,
- T_SubLink,
- T_Func,
- T_FieldSelect,
- T_ArrayRef,
- T_Iter,
- T_RelabelType,
- T_RangeTblRef,
- T_FromExpr,
- T_JoinExpr,
+ T_Resdom = 100,
+ T_Fjoin,
+ T_Expr,
+ T_Var,
+ T_Oper,
+ T_Const,
+ T_Param,
+ T_Aggref,
+ T_SubLink,
+ T_Func,
+ T_FieldSelect,
+ T_ArrayRef,
+ T_Iter,
+ T_RelabelType,
+ T_RangeTblRef,
+ T_FromExpr,
+ T_JoinExpr,
/*
* TAGS FOR PLANNER NODES (relation.h)
*/
- T_RelOptInfo = 200,
- T_Path,
- T_IndexPath,
- T_NestPath,
- T_MergePath,
- T_HashPath,
- T_TidPath,
- T_AppendPath,
- T_PathKeyItem,
- T_RestrictInfo,
- T_JoinInfo,
- T_Stream,
- T_IndexOptInfo,
+ T_RelOptInfo = 200,
+ T_Path,
+ T_IndexPath,
+ T_NestPath,
+ T_MergePath,
+ T_HashPath,
+ T_TidPath,
+ T_AppendPath,
+ T_PathKeyItem,
+ T_RestrictInfo,
+ T_JoinInfo,
+ T_Stream,
+ T_IndexOptInfo,
/*
* TAGS FOR EXECUTOR NODES (execnodes.h)
*/
- T_IndexInfo = 300,
- T_ResultRelInfo,
- T_TupleCount,
- T_TupleTableSlot,
- T_ExprContext,
- T_ProjectionInfo,
- T_JunkFilter,
- T_EState,
- T_BaseNode,
- T_CommonState,
- T_ResultState,
- T_AppendState,
- T_CommonScanState,
- T_ScanState,
- T_IndexScanState,
- T_JoinState,
- T_NestLoopState,
- T_MergeJoinState,
- T_HashJoinState,
- T_MaterialState,
- T_AggState,
- T_GroupState,
- T_SortState,
- T_UniqueState,
- T_HashState,
- T_TidScanState,
- T_SubqueryScanState,
- T_SetOpState,
- T_LimitState,
+ T_IndexInfo = 300,
+ T_ResultRelInfo,
+ T_TupleCount,
+ T_TupleTableSlot,
+ T_ExprContext,
+ T_ProjectionInfo,
+ T_JunkFilter,
+ T_EState,
+ T_BaseNode,
+ T_CommonState,
+ T_ResultState,
+ T_AppendState,
+ T_CommonScanState,
+ T_ScanState,
+ T_IndexScanState,
+ T_JoinState,
+ T_NestLoopState,
+ T_MergeJoinState,
+ T_HashJoinState,
+ T_MaterialState,
+ T_AggState,
+ T_GroupState,
+ T_SortState,
+ T_UniqueState,
+ T_HashState,
+ T_TidScanState,
+ T_SubqueryScanState,
+ T_SetOpState,
+ T_LimitState,
/*
* TAGS FOR MEMORY NODES (memnodes.h)
*/
- T_MemoryContext = 400,
- T_AllocSetContext,
+ T_MemoryContext = 400,
+ T_AllocSetContext,
/*
* TAGS FOR VALUE NODES (pg_list.h)
*/
- T_Value = 500,
- T_List,
- T_Integer,
- T_Float,
- T_String,
- T_BitString,
- T_Null,
+ T_Value = 500,
+ T_List,
+ T_Integer,
+ T_Float,
+ T_String,
+ T_BitString,
+ T_Null,
/*
* TAGS FOR PARSE TREE NODES (parsenodes.h)
*/
- T_Query = 600,
- T_InsertStmt,
- T_DeleteStmt,
- T_UpdateStmt,
- T_SelectStmt,
- T_AlterTableStmt,
- T_SetOperationStmt,
- T_GrantStmt,
- T_ClosePortalStmt,
- T_ClusterStmt,
- T_CopyStmt,
- T_CreateStmt,
- T_VersionStmt,
- T_DefineStmt,
- T_DropStmt,
- T_TruncateStmt,
- T_CommentStmt,
- T_FetchStmt,
- T_IndexStmt,
- T_ProcedureStmt,
- T_RemoveAggrStmt,
- T_RemoveFuncStmt,
- T_RemoveOperStmt,
- T_RenameStmt,
- T_RuleStmt,
- T_NotifyStmt,
- T_ListenStmt,
- T_UnlistenStmt,
- T_TransactionStmt,
- T_ViewStmt,
- T_LoadStmt,
- T_CreatedbStmt,
- T_DropdbStmt,
- T_VacuumStmt,
- T_ExplainStmt,
- T_CreateSeqStmt,
- T_VariableSetStmt,
- T_VariableShowStmt,
- T_VariableResetStmt,
- T_CreateTrigStmt,
- T_DropTrigStmt,
- T_CreatePLangStmt,
- T_DropPLangStmt,
- T_CreateUserStmt,
- T_AlterUserStmt,
- T_DropUserStmt,
- T_LockStmt,
- T_ConstraintsSetStmt,
- T_CreateGroupStmt,
- T_AlterGroupStmt,
- T_DropGroupStmt,
- T_ReindexStmt,
- T_CheckPointStmt,
-
- T_A_Expr = 700,
- T_Attr,
- T_A_Const,
- T_ParamNo,
- T_Ident,
- T_FuncCall,
- T_A_Indices,
- T_ResTarget,
- T_TypeCast,
- T_RangeSubselect,
- T_SortGroupBy,
- T_RangeVar,
- T_TypeName,
- T_IndexElem,
- T_ColumnDef,
- T_Constraint,
- T_DefElem,
- T_TargetEntry,
- T_RangeTblEntry,
- T_SortClause,
- T_GroupClause,
- T_NullTest,
- T_BooleanTest,
- T_CaseExpr,
- T_CaseWhen,
- T_FkConstraint,
- T_PrivGrantee,
+ T_Query = 600,
+ T_InsertStmt,
+ T_DeleteStmt,
+ T_UpdateStmt,
+ T_SelectStmt,
+ T_AlterTableStmt,
+ T_SetOperationStmt,
+ T_GrantStmt,
+ T_ClosePortalStmt,
+ T_ClusterStmt,
+ T_CopyStmt,
+ T_CreateStmt,
+ T_VersionStmt,
+ T_DefineStmt,
+ T_DropStmt,
+ T_TruncateStmt,
+ T_CommentStmt,
+ T_FetchStmt,
+ T_IndexStmt,
+ T_ProcedureStmt,
+ T_RemoveAggrStmt,
+ T_RemoveFuncStmt,
+ T_RemoveOperStmt,
+ T_RenameStmt,
+ T_RuleStmt,
+ T_NotifyStmt,
+ T_ListenStmt,
+ T_UnlistenStmt,
+ T_TransactionStmt,
+ T_ViewStmt,
+ T_LoadStmt,
+ T_CreatedbStmt,
+ T_DropdbStmt,
+ T_VacuumStmt,
+ T_ExplainStmt,
+ T_CreateSeqStmt,
+ T_VariableSetStmt,
+ T_VariableShowStmt,
+ T_VariableResetStmt,
+ T_CreateTrigStmt,
+ T_DropTrigStmt,
+ T_CreatePLangStmt,
+ T_DropPLangStmt,
+ T_CreateUserStmt,
+ T_AlterUserStmt,
+ T_DropUserStmt,
+ T_LockStmt,
+ T_ConstraintsSetStmt,
+ T_CreateGroupStmt,
+ T_AlterGroupStmt,
+ T_DropGroupStmt,
+ T_ReindexStmt,
+ T_CheckPointStmt,
+
+ T_A_Expr = 700,
+ T_Attr,
+ T_A_Const,
+ T_ParamNo,
+ T_Ident,
+ T_FuncCall,
+ T_A_Indices,
+ T_ResTarget,
+ T_TypeCast,
+ T_RangeSubselect,
+ T_SortGroupBy,
+ T_RangeVar,
+ T_TypeName,
+ T_IndexElem,
+ T_ColumnDef,
+ T_Constraint,
+ T_DefElem,
+ T_TargetEntry,
+ T_RangeTblEntry,
+ T_SortClause,
+ T_GroupClause,
+ T_NullTest,
+ T_BooleanTest,
+ T_CaseExpr,
+ T_CaseWhen,
+ T_FkConstraint,
+ T_PrivGrantee,
/*
* TAGS FOR FUNCTION-CALL CONTEXT AND RESULTINFO NODES (see fmgr.h)
*/
- T_TriggerData = 800, /* in commands/trigger.h */
- T_ReturnSetInfo /* in nodes/execnodes.h */
+ T_TriggerData = 800, /* in commands/trigger.h */
+ T_ReturnSetInfo /* in nodes/execnodes.h */
} NodeTag;
*/
typedef enum CmdType
{
- CMD_UNKNOWN,
- CMD_SELECT, /* select stmt (formerly retrieve) */
- CMD_UPDATE, /* update stmt (formerly replace) */
- CMD_INSERT, /* insert stmt (formerly append) */
- CMD_DELETE,
- CMD_UTILITY, /* cmds like create, destroy, copy,
+ CMD_UNKNOWN,
+ CMD_SELECT, /* select stmt (formerly retrieve) */
+ CMD_UPDATE, /* update stmt (formerly replace) */
+ CMD_INSERT, /* insert stmt (formerly append) */
+ CMD_DELETE,
+ CMD_UTILITY, /* cmds like create, destroy, copy,
* vacuum, etc. */
- CMD_NOTHING /* dummy command for instead nothing rules
+ CMD_NOTHING /* dummy command for instead nothing rules
* with qual */
} CmdType;
*/
typedef enum JoinType
{
-
/*
* The canonical kinds of joins
*/
- JOIN_INNER, /* matching tuple pairs only */
- JOIN_LEFT, /* pairs + unmatched outer tuples */
- JOIN_FULL, /* pairs + unmatched outer + unmatched
+ JOIN_INNER, /* matching tuple pairs only */
+ JOIN_LEFT, /* pairs + unmatched outer tuples */
+ JOIN_FULL, /* pairs + unmatched outer + unmatched
* inner */
- JOIN_RIGHT, /* pairs + unmatched inner tuples */
+ JOIN_RIGHT, /* pairs + unmatched inner tuples */
/*
* SQL92 considers UNION JOIN to be a kind of join, so list it here
* join in the executor. (The planner must convert it to an Append
* plan.)
*/
- JOIN_UNION
+ JOIN_UNION
/*
* Eventually we will have some additional join types for efficient
((jointype) == JOIN_LEFT || \
(jointype) == JOIN_FULL || \
(jointype) == JOIN_RIGHT)
-
#endif /* NODES_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: params.h,v 1.13 2001/01/24 19:43:25 momjian Exp $
+ * $Id: params.h,v 1.14 2001/10/25 05:50:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Datum value;
bool isnull;
} ParamExecData;
-
#endif /* PARAMS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.147 2001/10/18 17:30:16 thomas Exp $
+ * $Id: parsenodes.h,v 1.148 2001/10/25 05:50:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* commit to the exact set of child tables at parse time. This field
* ought to go in some sort of TopPlan plan node, not in the Query.
*/
- List *resultRelations;/* integer list of RT indexes, or NIL */
+ List *resultRelations; /* integer list of RT indexes, or NIL */
/* internal to planner */
List *base_rel_list; /* list of base-relation RelOptInfos */
- List *other_rel_list; /* list of other 1-relation RelOptInfos */
+ List *other_rel_list; /* list of other 1-relation RelOptInfos */
List *join_rel_list; /* list of join-relation RelOptInfos */
List *equi_key_list; /* list of lists of equijoined
* PathKeyItems */
typedef enum InhOption
{
- INH_NO, /* Do NOT scan child tables */
- INH_YES, /* DO scan child tables */
- INH_DEFAULT /* Use current SQL_inheritance option */
+ INH_NO, /* Do NOT scan child tables */
+ INH_YES, /* DO scan child tables */
+ INH_DEFAULT /* Use current SQL_inheritance option */
} InhOption;
/*****************************************************************************
{
NodeTag type;
char subtype; /*------------
- * A = add column
+ * A = add column
* T = alter column default
* S = alter column statistics
* D = drop column
typedef enum ConstrType /* types of constraints */
{
- CONSTR_NULL, /* not SQL92, but a lot of people expect
+ CONSTR_NULL, /* not SQL92, but a lot of people expect
* it */
- CONSTR_NOTNULL,
- CONSTR_DEFAULT,
- CONSTR_CHECK,
- CONSTR_PRIMARY,
- CONSTR_UNIQUE,
- CONSTR_ATTR_DEFERRABLE, /* attributes for previous constraint node */
- CONSTR_ATTR_NOT_DEFERRABLE,
- CONSTR_ATTR_DEFERRED,
- CONSTR_ATTR_IMMEDIATE
+ CONSTR_NOTNULL,
+ CONSTR_DEFAULT,
+ CONSTR_CHECK,
+ CONSTR_PRIMARY,
+ CONSTR_UNIQUE,
+ CONSTR_ATTR_DEFERRABLE, /* attributes for previous
+ * constraint node */
+ CONSTR_ATTR_NOT_DEFERRABLE,
+ CONSTR_ATTR_DEFERRED,
+ CONSTR_ATTR_IMMEDIATE
} ConstrType;
typedef struct Constraint
{
NodeTag type;
char *seqname; /* the relation to create */
- bool istemp; /* is this a temp sequence? */
+ bool istemp; /* is this a temp sequence? */
List *options;
} CreateSeqStmt;
bool analyze; /* do ANALYZE step */
bool freeze; /* early-freeze option */
bool verbose; /* print progress info */
- char *vacrel; /* name of single table to process, or NULL */
+ char *vacrel; /* name of single table to process, or
+ * NULL */
List *va_cols; /* list of column names, or NIL for all */
} VacuumStmt;
*/
typedef enum SetOperation
{
- SETOP_NONE = 0,
- SETOP_UNION,
- SETOP_INTERSECT,
- SETOP_EXCEPT
+ SETOP_NONE = 0,
+ SETOP_UNION,
+ SETOP_INTERSECT,
+ SETOP_EXCEPT
} SetOperation;
typedef struct SelectStmt
typedef enum NullTestType
{
- IS_NULL, IS_NOT_NULL
+ IS_NULL, IS_NOT_NULL
} NullTestType;
typedef struct NullTest
{
- NodeTag type;
- Node *arg; /* input expression */
- NullTestType nulltesttype; /* IS NULL, IS NOT NULL */
+ NodeTag type;
+ Node *arg; /* input expression */
+ NullTestType nulltesttype; /* IS NULL, IS NOT NULL */
} NullTest;
/* ----------------
typedef enum BoolTestType
{
- IS_TRUE, IS_NOT_TRUE, IS_FALSE, IS_NOT_FALSE, IS_UNKNOWN, IS_NOT_UNKNOWN
+ IS_TRUE, IS_NOT_TRUE, IS_FALSE, IS_NOT_FALSE, IS_UNKNOWN, IS_NOT_UNKNOWN
} BoolTestType;
typedef struct BooleanTest
{
- NodeTag type;
- Node *arg; /* input expression */
- BoolTestType booltesttype; /* test type */
+ NodeTag type;
+ Node *arg; /* input expression */
+ BoolTestType booltesttype; /* test type */
} BooleanTest;
/*
typedef struct SortClause
{
NodeTag type;
- Index tleSortGroupRef;/* reference into targetlist */
+ Index tleSortGroupRef; /* reference into targetlist */
Oid sortop; /* the sort operator to use */
} SortClause;
* nodetags...). We have routines that operate interchangeably on both.
*/
typedef SortClause GroupClause;
-
#endif /* PARSENODES_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_list.h,v 1.23 2001/01/24 19:43:26 momjian Exp $
+ * $Id: pg_list.h,v 1.24 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* in copyfuncs.c */
extern List *listCopy(List *list);
-
#endif /* PG_LIST_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: plannodes.h,v 1.50 2001/09/18 01:59:07 tgl Exp $
+ * $Id: plannodes.h,v 1.51 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* individual nodes point to one EState
* for the whole top-level plan */
- struct Instrumentation *instrument; /* Optional runtime stats for this
- * plan node */
+ struct Instrumentation *instrument; /* Optional runtime stats for this
+ * plan node */
/*
* Common structural data for all Plan types. XXX chgParam is runtime
*/
typedef enum SetOpCmd
{
- SETOPCMD_INTERSECT,
- SETOPCMD_INTERSECT_ALL,
- SETOPCMD_EXCEPT,
- SETOPCMD_EXCEPT_ALL
+ SETOPCMD_INTERSECT,
+ SETOPCMD_INTERSECT_ALL,
+ SETOPCMD_EXCEPT,
+ SETOPCMD_EXCEPT_ALL
} SetOpCmd;
typedef struct SetOp
* Tee may be different than the parent
* plans */
} Tee;
-
#endif
/* ---------------------
bool needShutdown; /* TRUE = need to shutdown subplan */
HeapTuple curTuple; /* copy of most recent tuple from subplan */
} SubPlan;
-
#endif /* PLANNODES_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: primnodes.h,v 1.54 2001/05/07 00:43:25 tgl Exp $
+ * $Id: primnodes.h,v 1.55 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
typedef enum OpType
{
- OP_EXPR, FUNC_EXPR, OR_EXPR, AND_EXPR, NOT_EXPR, SUBPLAN_EXPR
+ OP_EXPR, FUNC_EXPR, OR_EXPR, AND_EXPR, NOT_EXPR, SUBPLAN_EXPR
} OpType;
typedef struct Expr
*/
typedef enum SubLinkType
{
- EXISTS_SUBLINK, ALL_SUBLINK, ANY_SUBLINK, MULTIEXPR_SUBLINK, EXPR_SUBLINK
+ EXISTS_SUBLINK, ALL_SUBLINK, ANY_SUBLINK, MULTIEXPR_SUBLINK, EXPR_SUBLINK
} SubLinkType;
List *fromlist; /* List of join subtrees */
Node *quals; /* qualifiers on join, if any */
} FromExpr;
-
#endif /* PRIMNODES_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: print.h,v 1.13 2001/01/24 19:43:26 momjian Exp $
+ * $Id: print.h,v 1.14 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void print_plan_recursive(Plan *p, Query *parsetree,
int indentLevel, char *label);
extern void print_plan(Plan *p, Query *parsetree);
-
#endif /* PRINT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: readfuncs.h,v 1.11 2001/01/24 19:43:26 momjian Exp $
+ * $Id: readfuncs.h,v 1.12 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* prototypes for functions in readfuncs.c
*/
extern Node *parsePlanString(void);
-
#endif /* READFUNCS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: relation.h,v 1.58 2001/08/21 16:36:06 tgl Exp $
+ * $Id: relation.h,v 1.59 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
typedef enum CostSelector
{
- STARTUP_COST, TOTAL_COST
+ STARTUP_COST, TOTAL_COST
} CostSelector;
/*----------
* useful. So now we have a separate IndexOptInfo struct for indexes.
*
* indexoid - OID of the index relation itself
- * pages - number of disk pages in index
- * tuples - number of index tuples in index
+ * pages - number of disk pages in index
+ * tuples - number of index tuples in index
* ncolumns - number of columns in index
- * nkeys - number of keys used by index (input columns)
+ * nkeys - number of keys used by index (input columns)
* classlist - List of PG_OPCLASS OIDs for the index
* indexkeys - List of base-relation attribute numbers that are index keys
* ordering - List of PG_OPERATOR OIDs which order the indexscan result
- * relam - the OID of the pg_am of the index
+ * relam - the OID of the pg_am of the index
* amcostestimate - OID of the relam's cost estimator
* indproc - OID of the function if a functional index, else 0
* indpred - index predicate if a partial index, else NULL
* is the number of table columns passed to the function. classlist[]
* and ordering[] have ncolumns entries, while indexkeys[] has nkeys
* entries.
- *
+ *
* Note: for historical reasons, the arrays classlist, indexkeys and
* ordering have an extra entry that is always zero. Some code scans
* until it sees a zero rather than looking at ncolumns or nkeys.
Oid *ordering; /* OIDs of sort operators for each column */
Oid relam; /* OID of the access method (in pg_am) */
- RegProcedure amcostestimate;/* OID of the access method's cost fcn */
+ RegProcedure amcostestimate; /* OID of the access method's cost fcn */
Oid indproc; /* if a functional index */
List *indpred; /* if a partial index */
{
Path path;
List *tideval;
- Relids unjoined_relids;/* some rels not yet part of my Path */
+ Relids unjoined_relids; /* some rels not yet part of my Path */
} TidPath;
/*
/* cache space for costs (currently only used for join clauses) */
Cost eval_cost; /* eval cost of clause; -1 if not yet set */
- Selectivity this_selec; /* selectivity; -1 if not yet set */
+ Selectivity this_selec; /* selectivity; -1 if not yet set */
/* valid if clause is mergejoinable, else InvalidOid: */
Oid mergejoinoperator; /* copy of clause operator */
typedef struct JoinInfo
{
NodeTag type;
- Relids unjoined_relids; /* some rels not yet part of my RelOptInfo */
+ Relids unjoined_relids; /* some rels not yet part of my RelOptInfo */
List *jinfo_restrictinfo; /* relevant RestrictInfos */
} JoinInfo;
Cost groupcost;
Selectivity groupsel;
} Stream;
-
#endif /* RELATION_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: xfunc.h,v 1.5 2001/01/24 19:43:26 momjian Exp $
+ * $Id: xfunc.h,v 1.6 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* function prototypes for path/predmig.c
*/
extern bool xfunc_do_predmig(Path root);
-
#endif /* XFUNC_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: clauses.h,v 1.45 2001/07/31 17:56:31 tgl Exp $
+ * $Id: clauses.h,v 1.46 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define is_subplan(clause) ((clause) != NULL && \
IsA(clause, Expr) && \
((Expr *) (clause))->opType == SUBPLAN_EXPR)
-
#endif /* CLAUSES_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: cost.h,v 1.40 2001/06/05 05:26:05 tgl Exp $
+ * $Id: cost.h,v 1.41 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool enable_hashjoin;
extern void cost_seqscan(Path *path, Query *root,
- RelOptInfo *baserel);
+ RelOptInfo *baserel);
extern void cost_index(Path *path, Query *root,
- RelOptInfo *baserel, IndexOptInfo *index,
- List *indexQuals, bool is_injoin);
+ RelOptInfo *baserel, IndexOptInfo *index,
+ List *indexQuals, bool is_injoin);
extern void cost_tidscan(Path *path, Query *root,
- RelOptInfo *baserel, List *tideval);
+ RelOptInfo *baserel, List *tideval);
extern void cost_sort(Path *path, Query *root,
- List *pathkeys, double tuples, int width);
+ List *pathkeys, double tuples, int width);
extern void cost_nestloop(Path *path, Query *root,
- Path *outer_path, Path *inner_path,
- List *restrictlist);
+ Path *outer_path, Path *inner_path,
+ List *restrictlist);
extern void cost_mergejoin(Path *path, Query *root,
- Path *outer_path, Path *inner_path,
- List *restrictlist,
- List *mergeclauses,
- List *outersortkeys, List *innersortkeys);
+ Path *outer_path, Path *inner_path,
+ List *restrictlist,
+ List *mergeclauses,
+ List *outersortkeys, List *innersortkeys);
extern void cost_hashjoin(Path *path, Query *root,
- Path *outer_path, Path *inner_path,
- List *restrictlist,
- List *hashclauses);
+ Path *outer_path, Path *inner_path,
+ List *restrictlist,
+ List *hashclauses);
extern Cost cost_qual_eval(List *quals);
extern void set_baserel_size_estimates(Query *root, RelOptInfo *rel);
extern void set_joinrel_size_estimates(Query *root, RelOptInfo *rel,
List *clauses,
int varRelid);
extern Selectivity clause_selectivity(Query *root,
- Node *clause,
- int varRelid);
-
+ Node *clause,
+ int varRelid);
#endif /* COST_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo.h,v 1.24 2001/03/22 04:00:53 momjian Exp $
+ * $Id: geqo.h,v 1.25 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern RelOptInfo *gimme_tree(Query *root, List *initial_rels,
Gene *tour, int num_gene,
int rel_count, RelOptInfo *old_rel);
-
#endif /* GEQO_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_copy.h,v 1.9 2001/01/24 19:43:26 momjian Exp $
+ * $Id: geqo_copy.h,v 1.10 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "optimizer/geqo_gene.h"
extern void geqo_copy(Chromosome *chromo1, Chromosome *chromo2, int string_length);
-
#endif /* GEQO_COPY_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_gene.h,v 1.10 2001/01/24 19:43:26 momjian Exp $
+ * $Id: geqo_gene.h,v 1.11 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int size;
int string_length;
} Pool;
-
#endif /* GEQO_GENE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_misc.h,v 1.15 2001/01/24 19:43:26 momjian Exp $
+ * $Id: geqo_misc.h,v 1.16 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void geqo_print_rel(Query *root, RelOptInfo *rel);
extern void geqo_print_path(Query *root, Path *path, int indent);
extern void geqo_print_joinclauses(Query *root, List *clauses);
-
#endif /* GEQO_MISC_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_mutation.h,v 1.9 2001/01/24 19:43:26 momjian Exp $
+ * $Id: geqo_mutation.h,v 1.10 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "optimizer/geqo_gene.h"
extern void geqo_mutation(Gene *tour, int num_gene);
-
#endif /* GEQO_MUTATION_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_pool.h,v 1.12 2001/03/22 04:00:54 momjian Exp $
+ * $Id: geqo_pool.h,v 1.13 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void spread_chromo(Chromosome *chromo, Pool *pool);
extern void sort_pool(Pool *pool);
-
#endif /* GEQO_POOL_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_random.h,v 1.8 2001/01/24 19:43:26 momjian Exp $
+ * $Id: geqo_random.h,v 1.9 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define geqo_randint(upper,lower) \
( (int) floor( geqo_rand()*(((upper)-(lower))+0.999999) ) + (lower) )
-
#endif /* GEQO_RANDOM_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_recombination.h,v 1.9 2001/01/24 19:43:26 momjian Exp $
+ * $Id: geqo_recombination.h,v 1.10 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* order crossover [OX2] according to Syswerda */
extern void ox2(Gene *mom, Gene *dad, Gene *offspring, int num_gene, City *city_table);
-
#endif /* GEQO_RECOMBINATION_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_selection.h,v 1.9 2001/01/24 19:43:26 momjian Exp $
+ * $Id: geqo_selection.h,v 1.10 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "optimizer/geqo_gene.h"
extern void geqo_selection(Chromosome *momma, Chromosome *daddy, Pool *pool, double bias);
-
#endif /* GEQO_SELECTION_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: joininfo.h,v 1.17 2001/01/24 19:43:26 momjian Exp $
+ * $Id: joininfo.h,v 1.18 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "nodes/relation.h"
extern JoinInfo *find_joininfo_node(RelOptInfo *this_rel, List *join_relids);
-
#endif /* JOININFO_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pathnode.h,v 1.38 2001/06/05 05:26:05 tgl Exp $
+ * $Id: pathnode.h,v 1.39 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
List *pathkeys,
ScanDirection indexscandir);
extern TidPath *create_tidscan_path(Query *root, RelOptInfo *rel,
- List *tideval);
+ List *tideval);
extern AppendPath *create_append_path(RelOptInfo *rel, List *subpaths);
extern Path *create_subqueryscan_path(RelOptInfo *rel);
extern NestPath *create_nestloop_path(Query *root,
- RelOptInfo *joinrel,
- JoinType jointype,
- Path *outer_path,
- Path *inner_path,
- List *restrict_clauses,
- List *pathkeys);
+ RelOptInfo *joinrel,
+ JoinType jointype,
+ Path *outer_path,
+ Path *inner_path,
+ List *restrict_clauses,
+ List *pathkeys);
extern MergePath *create_mergejoin_path(Query *root,
- RelOptInfo *joinrel,
- JoinType jointype,
- Path *outer_path,
- Path *inner_path,
- List *restrict_clauses,
- List *pathkeys,
- List *mergeclauses,
- List *outersortkeys,
- List *innersortkeys);
+ RelOptInfo *joinrel,
+ JoinType jointype,
+ Path *outer_path,
+ Path *inner_path,
+ List *restrict_clauses,
+ List *pathkeys,
+ List *mergeclauses,
+ List *outersortkeys,
+ List *innersortkeys);
extern HashPath *create_hashjoin_path(Query *root,
- RelOptInfo *joinrel,
- JoinType jointype,
- Path *outer_path,
- Path *inner_path,
- List *restrict_clauses,
- List *hashclauses);
+ RelOptInfo *joinrel,
+ JoinType jointype,
+ Path *outer_path,
+ Path *inner_path,
+ List *restrict_clauses,
+ List *hashclauses);
/*
* prototypes for relnode.c
extern RelOptInfo *build_other_rel(Query *root, int relid);
extern RelOptInfo *find_base_rel(Query *root, int relid);
extern RelOptInfo *build_join_rel(Query *root,
- RelOptInfo *outer_rel,
- RelOptInfo *inner_rel,
- JoinType jointype,
- List **restrictlist_ptr);
-
+ RelOptInfo *outer_rel,
+ RelOptInfo *inner_rel,
+ JoinType jointype,
+ List **restrictlist_ptr);
#endif /* PATHNODE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: paths.h,v 1.56 2001/10/18 16:11:42 tgl Exp $
+ * $Id: paths.h,v 1.57 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
extern void create_index_paths(Query *root, RelOptInfo *rel);
extern Oid indexable_operator(Expr *clause, Oid opclass,
- bool indexkey_on_left);
+ bool indexkey_on_left);
extern List *extract_or_indexqual_conditions(RelOptInfo *rel,
IndexOptInfo *index,
Expr *orsubclause);
*/
typedef enum
{
- PATHKEYS_EQUAL, /* pathkeys are identical */
- PATHKEYS_BETTER1, /* pathkey 1 is a superset of pathkey 2 */
- PATHKEYS_BETTER2, /* vice versa */
- PATHKEYS_DIFFERENT /* neither pathkey includes the other */
+ PATHKEYS_EQUAL, /* pathkeys are identical */
+ PATHKEYS_BETTER1, /* pathkey 1 is a superset of
+ * pathkey 2 */
+ PATHKEYS_BETTER2, /* vice versa */
+ PATHKEYS_DIFFERENT /* neither pathkey includes the
+ * other */
} PathKeysComparison;
extern void add_equijoined_keys(Query *root, RestrictInfo *restrictinfo);
extern List *make_pathkeys_for_sortclauses(List *sortclauses,
List *tlist);
extern void cache_mergeclause_pathkeys(Query *root,
- RestrictInfo *restrictinfo);
+ RestrictInfo *restrictinfo);
extern List *find_mergeclauses_for_pathkeys(Query *root,
List *pathkeys,
List *restrictinfos);
extern List *truncate_useless_pathkeys(Query *root,
RelOptInfo *rel,
List *pathkeys);
-
#endif /* PATHS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: plancat.h,v 1.23 2001/05/20 20:28:20 tgl Exp $
+ * $Id: plancat.h,v 1.24 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void get_relation_info(Oid relationObjectId,
- bool *hasindex, long *pages, double *tuples);
+ bool *hasindex, long *pages, double *tuples);
extern List *find_secondary_indexes(Oid relationObjectId);
extern bool has_unique_index(RelOptInfo *rel, AttrNumber attno);
extern Selectivity restriction_selectivity(Query *root,
- Oid operator,
- List *args,
- int varRelid);
+ Oid operator,
+ List *args,
+ int varRelid);
extern Selectivity join_selectivity(Query *root,
- Oid operator,
- List *args);
-
+ Oid operator,
+ List *args);
#endif /* PLANCAT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: planmain.h,v 1.51 2001/06/05 05:26:05 tgl Exp $
+ * $Id: planmain.h,v 1.52 2001/10/25 05:50:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Index scanrelid, Plan *subplan);
extern Append *make_append(List *appendplans, bool isTarget, List *tlist);
extern Sort *make_sort(Query *root, List *tlist,
- Plan *lefttree, int keycount);
+ Plan *lefttree, int keycount);
extern Sort *make_sort_from_pathkeys(Query *root, List *tlist,
- Plan *lefttree, List *pathkeys);
+ Plan *lefttree, List *pathkeys);
extern Agg *make_agg(List *tlist, List *qual, Plan *lefttree);
extern Group *make_group(List *tlist, bool tuplePerGroup, int ngrp,
AttrNumber *grpColIdx, Plan *lefttree);
extern bool _use_keyset_query_optimizer;
extern void transformKeySetQuery(Query *origNode);
-
#endif /* PLANMAIN_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: planner.h,v 1.20 2001/06/05 05:26:05 tgl Exp $
+ * $Id: planner.h,v 1.21 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern Plan *subquery_planner(Query *parse, double tuple_fraction);
extern Plan *make_sortplan(Query *parse, List *tlist,
- Plan *plannode, List *sortcls);
-
+ Plan *plannode, List *sortcls);
#endif /* PLANNER_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: prep.h,v 1.28 2001/05/20 20:28:20 tgl Exp $
+ * $Id: prep.h,v 1.29 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern List *find_all_inheritors(Oid parentrel);
extern List *expand_inherted_rtentry(Query *parse, Index rti,
- bool dup_parent);
+ bool dup_parent);
extern Node *adjust_inherited_attrs(Node *node,
Index old_rt_index, Oid old_relid,
Index new_rt_index, Oid new_relid);
-
#endif /* PREP_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: restrictinfo.h,v 1.11 2001/03/22 04:00:56 momjian Exp $
+ * $Id: restrictinfo.h,v 1.12 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern List *get_actual_clauses(List *restrictinfo_list);
extern void get_actual_join_clauses(List *restrictinfo_list,
List **joinquals, List **otherquals);
-
#endif /* RESTRICTINFO_H */
extern List *SS_finalize_plan(Plan *plan);
extern Node *SS_replace_correlation_vars(Node *expr);
extern Node *SS_process_sublinks(Node *expr);
-
#endif /* SUBSELECT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: tlist.h,v 1.28 2001/01/24 19:43:26 momjian Exp $
+ * $Id: tlist.h,v 1.29 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
List *targetList);
extern Node *get_sortgroupclause_expr(SortClause *sortClause,
List *targetList);
-
#endif /* TLIST_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: var.h,v 1.14 2001/05/09 23:13:36 tgl Exp $
+ * $Id: var.h,v 1.15 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern List *pull_varnos(Node *node);
extern bool contain_var_reference(Node *node, int varno, int varattno,
- int levelsup);
+ int levelsup);
extern bool contain_whole_tuple_var(Node *node, int varno, int levelsup);
extern bool contain_var_clause(Node *node);
extern List *pull_var_clause(Node *node, bool includeUpperVars);
-
#endif /* VAR_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: analyze.h,v 1.15 2001/09/07 21:57:53 momjian Exp $
+ * $Id: analyze.h,v 1.16 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* This was exported to allow ADD CONSTRAINT to make use of it */
extern char *makeObjectName(char *name1, char *name2, char *typename);
-
#endif /* ANALYZE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: gramparse.h,v 1.16 2001/09/20 14:20:28 petere Exp $
+ * $Id: gramparse.h,v 1.17 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int yyparse(void);
extern char *xlateSqlFunc(char *name);
extern char *xlateSqlType(char *name);
-bool exprIsNullConstant(Node *arg);
-
+bool exprIsNullConstant(Node *arg);
#endif /* GRAMPARSE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: keywords.h,v 1.9 2001/01/24 19:43:27 momjian Exp $
+ * $Id: keywords.h,v 1.10 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
} ScanKeyword;
extern ScanKeyword *ScanKeywordLookup(char *text);
-
#endif /* KEYWORDS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_agg.h,v 1.17 2001/01/24 19:43:27 momjian Exp $
+ * $Id: parse_agg.h,v 1.18 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
List *args, bool agg_star, bool agg_distinct,
int precedence);
extern void agg_error(char *caller, char *aggname, Oid basetypeID);
-
#endif /* PARSE_AGG_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_clause.h,v 1.24 2001/03/22 04:00:56 momjian Exp $
+ * $Id: parse_clause.h,v 1.25 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern List *addAllTargetsToSortList(List *sortlist, List *targetlist);
extern Index assignSortGroupRef(TargetEntry *tle, List *tlist);
-
#endif /* PARSE_CLAUSE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_coerce.h,v 1.34 2001/10/03 19:18:42 tgl Exp $
+ * $Id: parse_coerce.h,v 1.35 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef enum CATEGORY
{
- INVALID_TYPE,
- UNKNOWN_TYPE,
- BOOLEAN_TYPE,
- STRING_TYPE,
- BITSTRING_TYPE,
- NUMERIC_TYPE,
- DATETIME_TYPE,
- TIMESPAN_TYPE,
- GEOMETRIC_TYPE,
- NETWORK_TYPE,
- USER_TYPE,
- MIXED_TYPE
+ INVALID_TYPE,
+ UNKNOWN_TYPE,
+ BOOLEAN_TYPE,
+ STRING_TYPE,
+ BITSTRING_TYPE,
+ NUMERIC_TYPE,
+ DATETIME_TYPE,
+ TIMESPAN_TYPE,
+ GEOMETRIC_TYPE,
+ NETWORK_TYPE,
+ USER_TYPE,
+ MIXED_TYPE
} CATEGORY;
extern Node *coerce_to_common_type(ParseState *pstate, Node *node,
Oid targetTypeId,
const char *context);
-
#endif /* PARSE_COERCE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_expr.h,v 1.22 2001/09/20 14:20:28 petere Exp $
+ * $Id: parse_expr.h,v 1.23 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool exprIsLengthCoercion(Node *expr, int32 *coercedTypmod);
extern void parse_expr_init(void);
extern char *TypeNameToInternalName(TypeName *typename);
-
#endif /* PARSE_EXPR_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_func.h,v 1.32 2001/10/04 22:06:46 tgl Exp $
+ * $Id: parse_func.h,v 1.33 2001/10/25 05:50:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* Result codes for func_get_detail */
typedef enum
{
- FUNCDETAIL_NOTFOUND, /* no suitable interpretation */
- FUNCDETAIL_NORMAL, /* found a matching function */
- FUNCDETAIL_COERCION /* it's a type coercion request */
+ FUNCDETAIL_NOTFOUND, /* no suitable interpretation */
+ FUNCDETAIL_NORMAL, /* found a matching function */
+ FUNCDETAIL_COERCION /* it's a type coercion request */
} FuncDetailCode;
int precedence);
extern FuncDetailCode func_get_detail(char *funcname, List *fargs,
- int nargs, Oid *argtypes,
- Oid *funcid, Oid *rettype,
- bool *retset, Oid **true_typeids);
+ int nargs, Oid *argtypes,
+ Oid *funcid, Oid *rettype,
+ bool *retset, Oid **true_typeids);
extern bool typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId);
extern void func_error(char *caller, char *funcname,
int nargs, Oid *argtypes, char *msg);
-
#endif /* PARSE_FUNC_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_node.h,v 1.26 2001/03/22 04:00:57 momjian Exp $
+ * $Id: parse_node.h,v 1.27 2001/10/25 05:50:08 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool forceSlice,
Node *assignFrom);
extern Const *make_const(Value *value);
-
#endif /* PARSE_NODE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_oper.h,v 1.15 2001/03/22 04:00:57 momjian Exp $
+ * $Id: parse_oper.h,v 1.16 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* Extract operator OID or underlying-function OID from an Operator tuple */
extern Oid oprid(Operator op);
extern Oid oprfuncid(Operator op);
-
#endif /* PARSE_OPER_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_relation.h,v 1.25 2001/10/23 17:39:03 tgl Exp $
+ * $Id: parse_relation.h,v 1.26 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int attnameAttNum(Relation rd, char *a);
extern Name attnumAttName(Relation rd, int attid);
extern Oid attnumTypeId(Relation rd, int attid);
-
#endif /* PARSE_RELATION_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_target.h,v 1.20 2001/01/24 19:43:27 momjian Exp $
+ * $Id: parse_target.h,v 1.21 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Oid type_id, Oid attrtype, int32 attrtypmod);
extern List *checkInsertTargets(ParseState *pstate, List *cols,
List **attrnos);
-
#endif /* PARSE_TARGET_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_type.h,v 1.17 2001/10/09 04:15:38 tgl Exp $
+ * $Id: parse_type.h,v 1.18 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void parseTypeString(const char *str, Oid *type_id, int32 *typmod);
#define ISCOMPLEX(typeid) (typeidTypeRelid(typeid) != InvalidOid)
-
#endif /* PARSE_TYPE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parser.h,v 1.8 2001/01/24 19:43:27 momjian Exp $
+ * $Id: parser.h,v 1.9 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "parser/parse_node.h"
extern List *parser(char *str, Oid *typev, int nargs);
-
#endif /* PARSER_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsetree.h,v 1.13 2001/01/24 19:43:27 momjian Exp $
+ * $Id: parsetree.h,v 1.14 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* variable name or alias for that attribute of that RTE.
*/
extern char *get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum);
-
#endif /* PARSETREE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: scansup.h,v 1.8 2001/01/24 19:43:27 momjian Exp $
+ * $Id: scansup.h,v 1.9 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define SCANSUP_H
extern char *scanstr(char *s);
-
#endif /* SCANSUP_H */
*
* Copyright (c) 2001, PostgreSQL Global Development Group
*
- * $Id: pgstat.h,v 1.8 2001/10/21 03:25:36 tgl Exp $
+ * $Id: pgstat.h,v 1.9 2001/10/25 05:49:54 momjian Exp $
* ----------
*/
#ifndef PGSTAT_H
* installations $PGDATA.
* ----------
*/
-#define PGSTAT_STAT_FILENAME "%s/global/pgstat.stat"
-#define PGSTAT_STAT_TMPFILE "%s/global/pgstat.tmp.%d"
+#define PGSTAT_STAT_FILENAME "%s/global/pgstat.stat"
+#define PGSTAT_STAT_TMPFILE "%s/global/pgstat.tmp.%d"
/* ----------
* Timer definitions.
* ----------
*/
#define PGSTAT_STAT_INTERVAL 500 /* How often to write the status */
- /* file, in milliseconds. */
+ /* file, in milliseconds. */
#define PGSTAT_DESTROY_DELAY 10000 /* How long to keep destroyed */
- /* objects known to give delayed */
- /* UDP packets time to arrive, */
- /* in milliseconds. */
+ /* objects known to give delayed */
+ /* UDP packets time to arrive, */
+ /* in milliseconds. */
-#define PGSTAT_DESTROY_COUNT (PGSTAT_DESTROY_DELAY \
+#define PGSTAT_DESTROY_COUNT (PGSTAT_DESTROY_DELAY \
/ PGSTAT_STAT_INTERVAL)
* The types of backend/postmaster -> collector messages
* ----------
*/
-#define PGSTAT_MTYPE_DUMMY 0
-#define PGSTAT_MTYPE_BESTART 1
-#define PGSTAT_MTYPE_BETERM 2
-#define PGSTAT_MTYPE_ACTIVITY 3
-#define PGSTAT_MTYPE_TABSTAT 4
-#define PGSTAT_MTYPE_TABPURGE 5
-#define PGSTAT_MTYPE_DROPDB 6
-#define PGSTAT_MTYPE_RESETCOUNTER 7
+#define PGSTAT_MTYPE_DUMMY 0
+#define PGSTAT_MTYPE_BESTART 1
+#define PGSTAT_MTYPE_BETERM 2
+#define PGSTAT_MTYPE_ACTIVITY 3
+#define PGSTAT_MTYPE_TABSTAT 4
+#define PGSTAT_MTYPE_TABPURGE 5
+#define PGSTAT_MTYPE_DROPDB 6
+#define PGSTAT_MTYPE_RESETCOUNTER 7
/* ----------
* Amount of space reserved in pgstat_recvbuffer().
* ----------
*/
-#define PGSTAT_RECVBUFFERSZ ((int) (1024 * sizeof(PgStat_Msg)))
+#define PGSTAT_RECVBUFFERSZ ((int) (1024 * sizeof(PgStat_Msg)))
/* ----------
* The data type used for counters.
* ----------
*/
-typedef int64 PgStat_Counter;
+typedef int64 PgStat_Counter;
/* ------------------------------------------------------------
* PgStat_StatDBEntry The collectors data per database
* ----------
*/
-typedef struct PgStat_StatDBEntry
+typedef struct PgStat_StatDBEntry
{
- Oid databaseid;
- HTAB *tables;
- int n_backends;
- PgStat_Counter n_connects;
- PgStat_Counter n_xact_commit;
- PgStat_Counter n_xact_rollback;
- PgStat_Counter n_blocks_fetched;
- PgStat_Counter n_blocks_hit;
- int destroy;
+ Oid databaseid;
+ HTAB *tables;
+ int n_backends;
+ PgStat_Counter n_connects;
+ PgStat_Counter n_xact_commit;
+ PgStat_Counter n_xact_rollback;
+ PgStat_Counter n_blocks_fetched;
+ PgStat_Counter n_blocks_hit;
+ int destroy;
} PgStat_StatDBEntry;
* PgStat_StatBeEntry The collectors data per backend
* ----------
*/
-typedef struct PgStat_StatBeEntry
+typedef struct PgStat_StatBeEntry
{
- Oid databaseid;
- Oid userid;
- int procpid;
- char activity[PGSTAT_ACTIVITY_SIZE];
+ Oid databaseid;
+ Oid userid;
+ int procpid;
+ char activity[PGSTAT_ACTIVITY_SIZE];
} PgStat_StatBeEntry;
* in a hash table of these structs.
* ----------
*/
-typedef struct PgStat_StatBeDead
+typedef struct PgStat_StatBeDead
{
- int procpid;
- int backendid;
- int destroy;
+ int procpid;
+ int backendid;
+ int destroy;
} PgStat_StatBeDead;
* PgStat_StatTabEntry The collectors data table data
* ----------
*/
-typedef struct PgStat_StatTabEntry
+typedef struct PgStat_StatTabEntry
{
- Oid tableid;
+ Oid tableid;
- PgStat_Counter numscans;
+ PgStat_Counter numscans;
- PgStat_Counter tuples_returned;
- PgStat_Counter tuples_fetched;
- PgStat_Counter tuples_inserted;
- PgStat_Counter tuples_updated;
- PgStat_Counter tuples_deleted;
+ PgStat_Counter tuples_returned;
+ PgStat_Counter tuples_fetched;
+ PgStat_Counter tuples_inserted;
+ PgStat_Counter tuples_updated;
+ PgStat_Counter tuples_deleted;
- PgStat_Counter blocks_fetched;
- PgStat_Counter blocks_hit;
+ PgStat_Counter blocks_fetched;
+ PgStat_Counter blocks_hit;
- int destroy;
+ int destroy;
} PgStat_StatTabEntry;
* PgStat_MsgHdr The common message header
* ----------
*/
-typedef struct PgStat_MsgHdr
+typedef struct PgStat_MsgHdr
{
- int m_type;
- int m_size;
- int m_backendid;
- int m_procpid;
- Oid m_databaseid;
- Oid m_userid;
+ int m_type;
+ int m_size;
+ int m_backendid;
+ int m_procpid;
+ Oid m_databaseid;
+ Oid m_userid;
} PgStat_MsgHdr;
/* ----------
* PgStat_TabEntry A table slot in a MsgTabstat
* ----------
*/
-typedef struct PgStat_TableEntry
+typedef struct PgStat_TableEntry
{
- Oid t_id;
+ Oid t_id;
- PgStat_Counter t_numscans;
+ PgStat_Counter t_numscans;
- PgStat_Counter t_tuples_returned;
- PgStat_Counter t_tuples_fetched;
- PgStat_Counter t_tuples_inserted;
- PgStat_Counter t_tuples_updated;
- PgStat_Counter t_tuples_deleted;
+ PgStat_Counter t_tuples_returned;
+ PgStat_Counter t_tuples_fetched;
+ PgStat_Counter t_tuples_inserted;
+ PgStat_Counter t_tuples_updated;
+ PgStat_Counter t_tuples_deleted;
- PgStat_Counter t_blocks_fetched;
- PgStat_Counter t_blocks_hit;
+ PgStat_Counter t_blocks_fetched;
+ PgStat_Counter t_blocks_hit;
} PgStat_TableEntry;
* PgStat_MsgDummy A dummy message, ignored by the collector
* ----------
*/
-typedef struct PgStat_MsgDummy
+typedef struct PgStat_MsgDummy
{
- PgStat_MsgHdr m_hdr;
- char m_dummy[512];
+ PgStat_MsgHdr m_hdr;
+ char m_dummy[512];
} PgStat_MsgDummy;
/* ----------
* PgStat_MsgBestart Sent by the backend on startup
* ----------
*/
-typedef struct PgStat_MsgBestart
+typedef struct PgStat_MsgBestart
{
- PgStat_MsgHdr m_hdr;
+ PgStat_MsgHdr m_hdr;
} PgStat_MsgBestart;
/* ----------
* PgStat_MsgBeterm Sent by the postmaster after backend exit
* ----------
*/
-typedef struct PgStat_MsgBeterm
+typedef struct PgStat_MsgBeterm
{
- PgStat_MsgHdr m_hdr;
+ PgStat_MsgHdr m_hdr;
} PgStat_MsgBeterm;
/* ----------
* to parse a query.
* ----------
*/
-typedef struct PgStat_MsgActivity
+typedef struct PgStat_MsgActivity
{
- PgStat_MsgHdr m_hdr;
- char m_what[PGSTAT_ACTIVITY_SIZE];
+ PgStat_MsgHdr m_hdr;
+ char m_what[PGSTAT_ACTIVITY_SIZE];
} PgStat_MsgActivity;
/* ----------
* and buffer access statistics.
* ----------
*/
-typedef struct PgStat_MsgTabstat
+typedef struct PgStat_MsgTabstat
{
- PgStat_MsgHdr m_hdr;
- int m_nentries;
- int m_xact_commit;
- int m_xact_rollback;
- PgStat_TableEntry m_entry[PGSTAT_NUM_TABENTRIES];
+ PgStat_MsgHdr m_hdr;
+ int m_nentries;
+ int m_xact_commit;
+ int m_xact_rollback;
+ PgStat_TableEntry m_entry[PGSTAT_NUM_TABENTRIES];
} PgStat_MsgTabstat;
* about dead tables.
* ----------
*/
-typedef struct PgStat_MsgTabpurge
+typedef struct PgStat_MsgTabpurge
{
- PgStat_MsgHdr m_hdr;
- int m_nentries;
- Oid m_tableid[PGSTAT_NUM_TABPURGE];
+ PgStat_MsgHdr m_hdr;
+ int m_nentries;
+ Oid m_tableid[PGSTAT_NUM_TABPURGE];
} PgStat_MsgTabpurge;
* about dropped database
* ----------
*/
-typedef struct PgStat_MsgDropdb
+typedef struct PgStat_MsgDropdb
{
- PgStat_MsgHdr m_hdr;
- Oid m_databaseid;
+ PgStat_MsgHdr m_hdr;
+ Oid m_databaseid;
} PgStat_MsgDropdb;
* to reset counters
* ----------
*/
-typedef struct PgStat_MsgResetcounter
+typedef struct PgStat_MsgResetcounter
{
- PgStat_MsgHdr m_hdr;
+ PgStat_MsgHdr m_hdr;
} PgStat_MsgResetcounter;
* PgStat_Msg Union over all possible messages.
* ----------
*/
-typedef union PgStat_Msg
+typedef union PgStat_Msg
{
- PgStat_MsgHdr msg_hdr;
- PgStat_MsgDummy msg_dummy;
- PgStat_MsgBestart msg_bestart;
- PgStat_MsgActivity msg_activity;
- PgStat_MsgTabstat msg_tabstat;
- PgStat_MsgTabpurge msg_tabpurge;
- PgStat_MsgDropdb msg_dropdb;
- PgStat_MsgResetcounter msg_resetcounter;
+ PgStat_MsgHdr msg_hdr;
+ PgStat_MsgDummy msg_dummy;
+ PgStat_MsgBestart msg_bestart;
+ PgStat_MsgActivity msg_activity;
+ PgStat_MsgTabstat msg_tabstat;
+ PgStat_MsgTabpurge msg_tabpurge;
+ PgStat_MsgDropdb msg_dropdb;
+ PgStat_MsgResetcounter msg_resetcounter;
} PgStat_Msg;
* Global variables
* ----------
*/
-extern bool pgstat_collect_startcollector;
-extern bool pgstat_collect_resetonpmstart;
-extern bool pgstat_collect_querystring;
-extern bool pgstat_collect_tuplelevel;
-extern bool pgstat_collect_blocklevel;
+extern bool pgstat_collect_startcollector;
+extern bool pgstat_collect_resetonpmstart;
+extern bool pgstat_collect_querystring;
+extern bool pgstat_collect_tuplelevel;
+extern bool pgstat_collect_blocklevel;
/* ----------
* Functions called from postmaster
* ----------
*/
-extern int pgstat_init(void);
-extern int pgstat_start(void);
-extern int pgstat_ispgstat(int pid);
-extern void pgstat_close_sockets(void);
-extern void pgstat_beterm(int pid);
+extern int pgstat_init(void);
+extern int pgstat_start(void);
+extern int pgstat_ispgstat(int pid);
+extern void pgstat_close_sockets(void);
+extern void pgstat_beterm(int pid);
/* ----------
* Functions called from backends
* ----------
*/
-extern void pgstat_bestart(void);
+extern void pgstat_bestart(void);
-extern void pgstat_ping(void);
-extern void pgstat_report_activity(char *what);
-extern void pgstat_report_tabstat(void);
-extern int pgstat_vacuum_tabstat(void);
+extern void pgstat_ping(void);
+extern void pgstat_report_activity(char *what);
+extern void pgstat_report_tabstat(void);
+extern int pgstat_vacuum_tabstat(void);
-extern void pgstat_reset_counters(void);
+extern void pgstat_reset_counters(void);
-extern void pgstat_initstats(PgStat_Info *stats, Relation rel);
+extern void pgstat_initstats(PgStat_Info *stats, Relation rel);
#define pgstat_reset_heap_scan(s) \
} while (0)
#define pgstat_count_heap_scan(s) \
do { \
- if (pgstat_collect_tuplelevel && (s)->tabentry != NULL && \
+ if (pgstat_collect_tuplelevel && (s)->tabentry != NULL && \
!(s)->heap_scan_counted) { \
((PgStat_TableEntry *)((s)->tabentry))->t_numscans++; \
(s)->heap_scan_counted = TRUE; \
#define pgstat_count_heap_fetch(s) \
do { \
if (pgstat_collect_tuplelevel && (s)->tabentry != NULL) \
- ((PgStat_TableEntry *)((s)->tabentry))->t_tuples_fetched++; \
+ ((PgStat_TableEntry *)((s)->tabentry))->t_tuples_fetched++; \
} while (0)
#define pgstat_count_heap_insert(s) \
do { \
#define pgstat_count_heap_update(s) \
do { \
if (pgstat_collect_tuplelevel && (s)->tabentry != NULL) \
- ((PgStat_TableEntry *)((s)->tabentry))->t_tuples_updated++; \
+ ((PgStat_TableEntry *)((s)->tabentry))->t_tuples_updated++; \
} while (0)
#define pgstat_count_heap_delete(s) \
do { \
if (pgstat_collect_tuplelevel && (s)->tabentry != NULL) \
- ((PgStat_TableEntry *)((s)->tabentry))->t_tuples_deleted++; \
+ ((PgStat_TableEntry *)((s)->tabentry))->t_tuples_deleted++; \
} while (0)
#define pgstat_reset_index_scan(s) \
do { \
} while (0)
#define pgstat_count_index_scan(s) \
do { \
- if (pgstat_collect_tuplelevel && (s)->tabentry != NULL && \
+ if (pgstat_collect_tuplelevel && (s)->tabentry != NULL && \
!(s)->index_scan_counted) { \
((PgStat_TableEntry *)((s)->tabentry))->t_numscans++; \
(s)->index_scan_counted = TRUE; \
#define pgstat_count_buffer_read(s,r) \
do { \
if (pgstat_collect_blocklevel && (s)->tabentry != NULL) \
- ((PgStat_TableEntry *)((s)->tabentry))->t_blocks_fetched++; \
+ ((PgStat_TableEntry *)((s)->tabentry))->t_blocks_fetched++; \
else { \
if (pgstat_collect_blocklevel && !(s)->no_stats) { \
pgstat_initstats((s), (r)); \
} while (0)
-extern void pgstat_count_xact_commit(void);
-extern void pgstat_count_xact_rollback(void);
+extern void pgstat_count_xact_commit(void);
+extern void pgstat_count_xact_rollback(void);
/* ----------
* Support functions for the SQL-callable functions to
* generate the pgstat* views.
* ----------
*/
-extern PgStat_StatDBEntry *pgstat_fetch_stat_dbentry(Oid dbid);
+extern PgStat_StatDBEntry *pgstat_fetch_stat_dbentry(Oid dbid);
extern PgStat_StatTabEntry *pgstat_fetch_stat_tabentry(Oid relid);
-extern PgStat_StatBeEntry *pgstat_fetch_stat_beentry(int beid);
-extern int pgstat_fetch_stat_numbackends(void);
+extern PgStat_StatBeEntry *pgstat_fetch_stat_beentry(int beid);
+extern int pgstat_fetch_stat_numbackends(void);
-
-#endif /* PGSTAT_H */
+#endif /* PGSTAT_H */
image_id beos_dl_open(char *filename);
/* Find symbol */
-void beos_dl_sym(image_id im,char* symname,void** fptr);
+void beos_dl_sym(image_id im, char *symname, void **fptr);
/* UnLoad a shared library */
status_t beos_dl_close(image_id im);
#else
typedef unsigned char slock_t;
-
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/include/port/darwin/Attic/sem.h,v 1.2 2001/03/22 04:01:02 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/include/port/darwin/Attic/sem.h,v 1.3 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifdef __cplusplus
}
-
#endif
-
#endif /* _SYS_SEM_H */
typedef unsigned int slock_t;
#define HAS_TEST_AND_SET
-
#endif
#define NEED_I386_TAS_ASM
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
-
#endif
#if defined(__sparc__)
#define NEED_SPARC_TAS_ASM
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
-
#endif
#if defined(__vax__)
#define NEED_VAX_TAS_ASM
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
-
#endif
#if defined(__ns32k__)
#define NEED_NS32K_TAS_ASM
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
-
#endif
#if defined(__m68k__)
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
-
#endif
#if defined(__arm__)
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
-
#endif
#if defined(__mips__)
#if defined(__alpha__)
#define HAS_TEST_AND_SET
typedef unsigned long slock_t;
-
#endif
#if defined(__powerpc__)
#define HAS_TEST_AND_SET
typedef unsigned int slock_t;
-
#endif
#define NEED_I386_TAS_ASM
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
-
#endif
#if defined(__sparc__)
#define NEED_SPARC_TAS_ASM
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
-
#endif
#if defined(__vax__)
#define NEED_VAX_TAS_ASM
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
-
#endif
#if defined(__ns32k__)
#define NEED_NS32K_TAS_ASM
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
-
#endif
#if defined(__m68k__)
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
-
#endif
#if defined(__arm__)
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
-
#endif
#if defined(__mips__)
#if defined(__alpha__)
#define HAS_TEST_AND_SET
typedef unsigned long slock_t;
-
#endif
#if defined(__powerpc__)
#define HAS_TEST_AND_SET
typedef unsigned int slock_t;
-
#endif
-/* $Header: /cvsroot/pgsql/src/include/port/solaris.h,v 1.4 2001/03/22 04:01:00 momjian Exp $ */
+/* $Header: /cvsroot/pgsql/src/include/port/solaris.h,v 1.5 2001/10/25 05:50:09 momjian Exp $ */
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
/* not GNUC and i386 */
#define NAN (0.0/0.0)
-
#endif /* GCC. */
-
#endif /* not NAN */
#include "abi_mutex.h"
typedef abilock_t slock_t;
-
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1995, Regents of the University of California
*
- * $Id: postgres.h,v 1.53 2001/10/03 21:58:28 tgl Exp $
+ * $Id: postgres.h,v 1.54 2001/10/25 05:49:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int32 va_extsize; /* External saved size */
Oid va_valueid; /* Unique identifier of value */
Oid va_toastrelid; /* RelID where to find chunks */
- } va_external;/* External stored attribute */
+ } va_external; /* External stored attribute */
char va_data[1]; /* Plain stored attribute */
} va_content;
#define AssertState(condition) \
Trap(!(condition), BadState)
-
#endif /* USE_ASSERT_CHECKING */
/*
Exception *exceptionP, char *details,
char *fileName, int lineNumber);
-extern char *vararg_format(const char *fmt, ...)
+extern char *
+vararg_format(const char *fmt,...)
/* This lets gcc check the format string for consistency. */
__attribute__((format(printf, 1, 2)));
#ifdef ASSERT_CHECKING_TEST
extern int assertTest(int val);
-
#endif
-
#endif /* USE_ASSERT_CHECKING */
/* ----------------------------------------------------------------
* Section 4: genbki macros used by catalog/pg_xxx.h files
* ----------------------------------------------------------------
*/
-#define CATALOG(x) typedef struct CppConcat(FormData_,x)
+#define CATALOG(x) typedef struct CppConcat(FormData_,x)
#define BOOTSTRAP
typedef int4 aclitem; /* PHONY definition for catalog use only */
-
#endif /* POSTGRES_H */
* use header files that are otherwise internal to Postgres to interface
* with the backend.
*
- * $Id: postgres_ext.h,v 1.7 2001/03/22 04:00:25 momjian Exp $
+ * $Id: postgres_ext.h,v 1.8 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* NOTE that databases with different NAMEDATALEN's cannot interoperate!
*/
#define NAMEDATALEN 32
-
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1995, Regents of the University of California
*
- * $Id: postgres_fe.h,v 1.2 2001/08/24 22:46:28 petere Exp $
+ * $Id: postgres_fe.h,v 1.3 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define POSTGRES_FE_H
#include "c.h"
-
#endif /* POSTGRES_FE_H */
},
{
"alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
- ""
+ ""
},
{
"blank", " \t", ""
{
"graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
- ""
+ ""
},
{
"lower", "abcdefghijklmnopqrstuvwxyz",
- ""
+ ""
},
{
"print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
- ""
+ ""
},
{
"punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
- ""
+ ""
},
{
"space", "\t\n\v\f\r ", ""
},
{
"upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
- ""
+ ""
},
{
"xdigit", "0123456789ABCDEFabcdef",
- ""
+ ""
},
{
NULL, NULL, ""
size_t nmatch,
regmatch_t *pmatch, int eflags);
extern void pg95_regfree(regex_t *preg);
-
#endif /* !_REGEX_H_ */
#define NDEBUG /* no assertions please */
#endif
#endif
-
#endif /* _REGEX_UTILS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: prs2lock.h,v 1.12 2001/01/24 19:43:27 momjian Exp $
+ * $Id: prs2lock.h,v 1.13 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int numLocks;
RewriteRule **rules;
} RuleLock;
-
#endif /* REWRITE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rewriteDefine.h,v 1.10 2001/08/12 21:35:19 tgl Exp $
+ * $Id: rewriteDefine.h,v 1.11 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void DefineQueryRewrite(RuleStmt *args);
extern void RenameRewriteRule(char *oldname, char *newname);
-
#endif /* REWRITEDEFINE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rewriteHandler.h,v 1.15 2001/06/13 18:56:30 tgl Exp $
+ * $Id: rewriteHandler.h,v 1.16 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern List *QueryRewrite(Query *parsetree);
-
#endif /* REWRITEHANDLER_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rewriteManip.h,v 1.27 2001/06/13 18:56:29 tgl Exp $
+ * $Id: rewriteManip.h,v 1.28 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern Node *ResolveNew(Node *node, int target_varno, int sublevels_up,
List *targetlist, int event, int update_varno);
-
#endif /* REWRITEMANIP_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rewriteRemove.h,v 1.7 2001/01/24 19:43:27 momjian Exp $
+ * $Id: rewriteRemove.h,v 1.8 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern char *RewriteGetRuleEventRel(char *rulename);
extern void RemoveRewriteRule(char *ruleName);
extern void RelationRemoveRules(Oid relid);
-
#endif /* REWRITEREMOVE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rewriteSupport.h,v 1.17 2001/08/12 21:35:19 tgl Exp $
+ * $Id: rewriteSupport.h,v 1.18 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void SetRelationRuleStatus(Oid relationId, bool relHasRules,
bool relIsBecomingView);
-
#endif /* REWRITESUPPORT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rusagestub.h,v 1.6 2001/01/24 19:43:19 momjian Exp $
+ * $Id: rusagestub.h,v 1.7 2001/10/25 05:49:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
};
extern int getrusage(int who, struct rusage * rusage);
-
#endif /* RUSAGESTUB_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: backendid.h,v 1.9 2001/01/24 19:43:27 momjian Exp $
+ * $Id: backendid.h,v 1.10 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define InvalidBackendId (-1)
extern BackendId MyBackendId; /* backend id of this backend */
-
#endif /* BACKENDID_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: block.h,v 1.13 2001/07/02 20:50:46 tgl Exp $
+ * $Id: block.h,v 1.14 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
AssertMacro(BlockIdIsValid(blockId)), \
(BlockNumber) (((blockId)->bi_hi << 16) | ((uint16) (blockId)->bi_lo)) \
)
-
#endif /* BLOCK_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: buf.h,v 1.9 2001/06/09 18:16:59 tgl Exp $
+ * $Id: buf.h,v 1.10 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* - plai 9/10/90
*/
#undef NO_BUFFERISVALID
-
#endif /* BUF_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: buf_internals.h,v 1.51 2001/10/01 05:36:17 tgl Exp $
+ * $Id: buf_internals.h,v 1.52 2001/10/25 05:50:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool cntxDirty; /* new way to mark block as dirty */
/*
- * We can't physically remove items from a disk page if another backend
- * has the buffer pinned. Hence, a backend may need to wait for all
- * other pins to go away. This is signaled by setting its own backend ID
- * into wait_backend_id and setting flag bit BM_PIN_COUNT_WAITER.
- * At present, there can be only one such waiter per buffer.
+ * We can't physically remove items from a disk page if another
+ * backend has the buffer pinned. Hence, a backend may need to wait
+ * for all other pins to go away. This is signaled by setting its own
+ * backend ID into wait_backend_id and setting flag bit
+ * BM_PIN_COUNT_WAITER. At present, there can be only one such waiter
+ * per buffer.
*/
- BackendId wait_backend_id; /* backend ID of pin-count waiter */
+ BackendId wait_backend_id; /* backend ID of pin-count waiter */
} BufferDesc;
#define BufferDescriptorGetBuffer(bdesc) ((bdesc)->buf_id + 1)
int bmt_buf;
Oid bmt_dbid;
Oid bmt_relid;
- BlockNumber bmt_blkno;
+ BlockNumber bmt_blkno;
int bmt_op;
#define BMT_NOTUSED 0
#define BMT_DEALLOC 3
} bmtrace;
-
#endif /* BMTRACE */
extern int FlushLocalBuffer(Buffer buffer, bool sync, bool release);
extern void LocalBufferSync(void);
extern void ResetLocalBufferPool(void);
-
#endif /* BUFMGR_INTERNALS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: buffile.h,v 1.8 2001/01/24 19:43:27 momjian Exp $
+ * $Id: buffile.h,v 1.9 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int BufFileSeek(BufFile *file, int fileno, long offset, int whence);
extern void BufFileTell(BufFile *file, int *fileno, long *offset);
extern int BufFileSeekBlock(BufFile *file, long blknum);
-
#endif /* BUFFILE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: bufmgr.h,v 1.54 2001/07/06 21:04:26 tgl Exp $
+ * $Id: bufmgr.h,v 1.55 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int WriteBuffer(Buffer buffer);
extern int WriteNoReleaseBuffer(Buffer buffer);
extern Buffer ReleaseAndReadBuffer(Buffer buffer, Relation relation,
- BlockNumber blockNum);
+ BlockNumber blockNum);
extern int FlushBuffer(Buffer buffer, bool sync, bool release);
extern void InitBufferPool(void);
extern void BufferSync(void);
extern void InitLocalBuffer(void);
-
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: bufpage.h,v 1.43 2001/08/25 18:52:43 tgl Exp $
+ * $Id: bufpage.h,v 1.44 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef enum
{
- ShufflePageManagerMode,
- OverwritePageManagerMode
+ ShufflePageManagerMode,
+ OverwritePageManagerMode
} PageManagerMode;
/* ----------------------------------------------------------------
extern void PageIndexTupleDelete(Page page, OffsetNumber offset);
extern void IndexPageCleanup(Buffer buffer);
-
#endif /* BUFPAGE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: fd.h,v 1.31 2001/09/30 18:57:45 tgl Exp $
+ * $Id: fd.h,v 1.32 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* GUC parameter */
-extern int max_files_per_process;
+extern int max_files_per_process;
/*
extern void RemovePgTempFiles(void);
extern int pg_fsync(int fd);
extern int pg_fdatasync(int fd);
-
#endif /* FD_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: freespace.h,v 1.3 2001/09/29 04:02:26 tgl Exp $
+ * $Id: freespace.h,v 1.4 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern BlockNumber GetPageWithFreeSpace(RelFileNode *rel, Size spaceNeeded);
extern void RecordFreeSpace(RelFileNode *rel, BlockNumber page,
- Size spaceAvail);
+ Size spaceAvail);
extern BlockNumber RecordAndGetPageWithFreeSpace(RelFileNode *rel,
- BlockNumber oldPage,
- Size oldSpaceAvail,
- Size spaceNeeded);
+ BlockNumber oldPage,
+ Size oldSpaceAvail,
+ Size spaceNeeded);
extern void MultiRecordFreeSpace(RelFileNode *rel,
- BlockNumber minPage,
- BlockNumber maxPage,
- int nPages,
- BlockNumber *pages,
- Size *spaceAvail);
+ BlockNumber minPage,
+ BlockNumber maxPage,
+ int nPages,
+ BlockNumber *pages,
+ Size *spaceAvail);
extern void FreeSpaceMapForgetRel(RelFileNode *rel);
extern void FreeSpaceMapForgetDatabase(Oid dbid);
#ifdef FREESPACE_DEBUG
extern void DumpFreeSpace(void);
#endif
-
#endif /* FREESPACE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: ipc.h,v 1.51 2001/09/29 04:02:26 tgl Exp $
+ * $Id: ipc.h,v 1.52 2001/10/25 05:50:10 momjian Exp $
*
* Some files that would normally need to include only sys/ipc.h must
* instead include this file because on Ultrix, sys/ipc.h is not designed
/* ipci.c */
extern void CreateSharedMemoryAndSemaphores(bool makePrivate,
int maxBackends);
-
#endif /* IPC_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: item.h,v 1.7 2001/01/24 19:43:27 momjian Exp $
+ * $Id: item.h,v 1.8 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define ITEM_H
typedef Pointer Item;
-
#endif /* ITEM_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: itemid.h,v 1.16 2001/03/22 04:01:06 momjian Exp $
+ * $Id: itemid.h,v 1.17 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
AssertMacro(ItemIdIsValid(itemId)), \
(bool) (((itemId)->lp_flags & LP_USED) != 0) \
)
-
#endif /* ITEMID_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: itempos.h,v 1.12 2001/01/24 19:43:27 momjian Exp $
+ * $Id: itempos.h,v 1.13 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
#define PSKIP(OBJP, LEN)\
do { (OBJP)->op_cp += (LEN); (OBJP)->op_len -= (LEN); } while (0)
-
#endif /* ITEMPOS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: itemptr.h,v 1.18 2001/03/30 05:25:51 tgl Exp $
+ * $Id: itemptr.h,v 1.19 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* tuple header on disk, it's very important not to waste space with
* structure padding bytes. The struct is designed to be six bytes long
* (it contains three int16 fields) but a few compilers will pad it to
- * eight bytes unless coerced. We apply appropriate persuasion where
+ * eight bytes unless coerced. We apply appropriate persuasion where
* possible, and to cope with unpersuadable compilers, we try to use
* "SizeOfIptrData" rather than "sizeof(ItemPointerData)" when computing
* on-disk sizes.
BlockIdData ip_blkid;
OffsetNumber ip_posid;
}
+
#ifdef __arm__
-__attribute__((packed)) /* Appropriate whack upside the head for ARM */
+__attribute__((packed)) /* Appropriate whack upside the head for
+ * ARM */
#endif
- ItemPointerData;
+ItemPointerData;
#define SizeOfIptrData \
(offsetof(ItemPointerData, ip_posid) + sizeof(OffsetNumber))
*/
extern bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2);
-
#endif /* ITEMPTR_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: large_object.h,v 1.21 2001/03/22 04:01:07 momjian Exp $
+ * $Id: large_object.h,v 1.22 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int inv_tell(LargeObjectDesc *obj_desc);
extern int inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes);
extern int inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes);
-
#endif /* LARGE_OBJECT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: lmgr.h,v 1.32 2001/07/09 22:18:34 tgl Exp $
+ * $Id: lmgr.h,v 1.33 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* ROW SHARE */
#define ExclusiveLock 7 /* blocks ROW SHARE/SELECT...FOR
* UPDATE */
-#define AccessExclusiveLock 8 /* ALTER TABLE, DROP TABLE,
- * VACUUM FULL, and unqualified LOCK
+#define AccessExclusiveLock 8 /* ALTER TABLE, DROP TABLE, VACUUM
+ * FULL, and unqualified LOCK
* TABLE */
/*
/* Lock an XID (used to wait for a transaction to finish) */
extern void XactLockTableInsert(TransactionId xid);
extern void XactLockTableWait(TransactionId xid);
-
#endif /* LMGR_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: lock.h,v 1.56 2001/10/01 05:36:17 tgl Exp $
+ * $Id: lock.h,v 1.57 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void DumpLocks(void);
extern void DumpAllLocks(void);
#endif
-
#endif /* LOCK_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: lwlock.h,v 1.1 2001/09/29 04:02:26 tgl Exp $
+ * $Id: lwlock.h,v 1.2 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* We have a number of predefined LWLocks, plus a bunch of LWLocks that are
* dynamically assigned (for shared buffers). The LWLock structures live
* in shared memory (since they contain shared data) and are identified by
- * values of this enumerated type. We abuse the notion of an enum somewhat
+ * values of this enumerated type. We abuse the notion of an enum somewhat
* by allowing values not listed in the enum declaration to be assigned.
* The extra value MaxDynamicLWLock is there to keep the compiler from
* deciding that the enum can be represented as char or short ...
*/
typedef enum LWLockId
{
- BufMgrLock,
- LockMgrLock,
- OidGenLock,
- XidGenLock,
- ShmemIndexLock,
- SInvalLock,
- FreeSpaceLock,
- MMCacheLock,
- WALInsertLock,
- WALWriteLock,
- ControlFileLock,
- CheckpointLock,
- CLogControlLock,
+ BufMgrLock,
+ LockMgrLock,
+ OidGenLock,
+ XidGenLock,
+ ShmemIndexLock,
+ SInvalLock,
+ FreeSpaceLock,
+ MMCacheLock,
+ WALInsertLock,
+ WALWriteLock,
+ ControlFileLock,
+ CheckpointLock,
+ CLogControlLock,
- NumFixedLWLocks, /* must be last except for MaxDynamicLWLock */
+ NumFixedLWLocks,/* must be last except for
+ * MaxDynamicLWLock */
- MaxDynamicLWLock = 1000000000
+ MaxDynamicLWLock = 1000000000
} LWLockId;
typedef enum LWLockMode
{
- LW_EXCLUSIVE,
- LW_SHARED
+ LW_EXCLUSIVE,
+ LW_SHARED
} LWLockMode;
extern int NumLWLocks(void);
extern int LWLockShmemSize(void);
extern void CreateLWLocks(void);
-
#endif /* LWLOCK_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: off.h,v 1.10 2001/01/24 19:43:28 momjian Exp $
+ * $Id: off.h,v 1.11 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
((OffsetNumber) (1 + (offsetNumber)))
#define OffsetNumberPrev(offsetNumber) \
((OffsetNumber) (-1 + (offsetNumber)))
-
#endif /* OFF_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: page.h,v 1.8 2001/01/24 19:43:28 momjian Exp $
+ * $Id: page.h,v 1.9 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* True iff page is valid.
*/
#define PageIsValid(page) PointerIsValid(page)
-
#endif /* PAGE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pos.h,v 1.10 2001/01/24 19:43:28 momjian Exp $
+ * $Id: pos.h,v 1.11 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
#define PositionIdGetOffsetNumber(positionId) \
((OffsetNumber) *(positionId))
-
#endif /* POS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: proc.h,v 1.50 2001/09/30 00:45:48 momjian Exp $
+ * $Id: proc.h,v 1.51 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* info about a single set of per-process semaphores */
IpcSemaphoreId procSemId;
int32 freeSemMap;
+
/*
- * In freeSemMap, bit i is set if the i'th semaphore of this sema
- * set is allocated to a process. (i counts from 0 at the LSB)
+ * In freeSemMap, bit i is set if the i'th semaphore of this sema set
+ * is allocated to a process. (i counts from 0 at the LSB)
*/
} SEM_MAP_ENTRY;
/* Info about semaphore sets used for per-process semaphores */
int semMapEntries;
+
/*
- * VARIABLE LENGTH ARRAY: actual length is semMapEntries.
- * THIS MUST BE LAST IN THE STRUCT DECLARATION.
+ * VARIABLE LENGTH ARRAY: actual length is semMapEntries. THIS MUST BE
+ * LAST IN THE STRUCT DECLARATION.
*/
- SEM_MAP_ENTRY procSemMap[1];
+ SEM_MAP_ENTRY procSemMap[1];
} PROC_HDR;
extern bool enable_sigalrm_interrupt(int delayms);
extern bool disable_sigalrm_interrupt(void);
-
#endif /* PROC_H */
#define RelFileNodeEquals(node1, node2) \
((node1).relNode == (node2).relNode && \
(node1).tblNode == (node2).tblNode)
-
#endif /* RELFILENODE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: shmem.h,v 1.33 2001/10/05 17:28:13 tgl Exp $
+ * $Id: shmem.h,v 1.34 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern Pointer SHMQueueNext(SHM_QUEUE *queue, SHM_QUEUE *curElem,
Size linkOffset);
extern bool SHMQueueEmpty(SHM_QUEUE *queue);
-
#endif /* SHMEM_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: sinval.h,v 1.22 2001/09/29 04:02:27 tgl Exp $
+ * $Id: sinval.h,v 1.23 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
ItemPointerData tuplePtr; /* tuple identifier in cached relation */
} SharedInvalCatcacheMsg;
-#define SHAREDINVALRELCACHE_ID (-1)
+#define SHAREDINVALRELCACHE_ID (-1)
typedef struct
{
extern void InitBackendSharedInvalidationState(void);
extern void SendSharedInvalidMessage(SharedInvalidationMessage *msg);
extern void ReceiveSharedInvalidMessages(
- void (*invalFunction) (SharedInvalidationMessage *msg),
- void (*resetFunction) (void));
+ void (*invalFunction) (SharedInvalidationMessage *msg),
+ void (*resetFunction) (void));
extern bool DatabaseHasActiveBackends(Oid databaseId, bool ignoreMyself);
extern bool TransactionIdIsInProgress(TransactionId xid);
extern TransactionId GetOldestXmin(bool allDbs);
extern int CountActiveBackends(void);
+
/* Use "struct PROC", not PROC, to avoid including proc.h here */
extern struct PROC *BackendIdGetProc(BackendId procId);
-
#endif /* SINVAL_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: sinvaladt.h,v 1.27 2001/06/19 19:42:16 tgl Exp $
+ * $Id: sinvaladt.h,v 1.28 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool SIInsertDataEntry(SISeg *segP, SharedInvalidationMessage *data);
extern int SIGetDataEntry(SISeg *segP, int backendId,
- SharedInvalidationMessage *data);
+ SharedInvalidationMessage *data);
extern void SIDelExpiredDataEntries(SISeg *segP);
-
#endif /* SINVALADT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: smgr.h,v 1.31 2001/09/29 04:02:27 tgl Exp $
+ * $Id: smgr.h,v 1.32 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int smgrinit(void);
extern int smgrcreate(int16 which, Relation reln);
extern int smgrunlink(int16 which, Relation reln);
-extern int smgrextend(int16 which, Relation reln, BlockNumber blocknum,
- char *buffer);
+extern int smgrextend(int16 which, Relation reln, BlockNumber blocknum,
+ char *buffer);
extern int smgropen(int16 which, Relation reln, bool failOK);
extern int smgrclose(int16 which, Relation reln);
extern int smgrread(int16 which, Relation reln, BlockNumber blocknum,
extern int smgrmarkdirty(int16 which, Relation reln, BlockNumber blkno);
extern BlockNumber smgrnblocks(int16 which, Relation reln);
extern BlockNumber smgrtruncate(int16 which, Relation reln,
- BlockNumber nblocks);
+ BlockNumber nblocks);
extern int smgrDoPendingDeletes(bool isCommit);
extern int smgrcommit(void);
extern int smgrabort(void);
extern Datum smgrin(PG_FUNCTION_ARGS);
extern Datum smgreq(PG_FUNCTION_ARGS);
extern Datum smgrne(PG_FUNCTION_ARGS);
-
#endif /* SMGR_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: spin.h,v 1.16 2001/09/29 04:02:27 tgl Exp $
+ * $Id: spin.h,v 1.17 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
S_LOCK(lock); \
} while (0)
-#define SpinLockAcquire_NoHoldoff(lock) S_LOCK(lock)
+#define SpinLockAcquire_NoHoldoff(lock) S_LOCK(lock)
#define SpinLockRelease(lock) \
do { \
RESUME_INTERRUPTS(); \
} while (0)
-#define SpinLockRelease_NoHoldoff(lock) S_UNLOCK(lock)
+#define SpinLockRelease_NoHoldoff(lock) S_UNLOCK(lock)
#define SpinLockFree(lock) S_LOCK_FREE(lock)
extern void CreateSpinlocks(void);
-
#endif /* SPIN_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: dest.h,v 1.25 2001/01/24 19:43:28 momjian Exp $
+ * $Id: dest.h,v 1.26 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
typedef enum
{
- None, /* results are discarded */
- Debug, /* results go to debugging output */
- Remote, /* results sent to frontend process */
- RemoteInternal, /* results sent to frontend process in
+ None, /* results are discarded */
+ Debug, /* results go to debugging output */
+ Remote, /* results sent to frontend process */
+ RemoteInternal, /* results sent to frontend process in
* internal (binary) form */
- SPI /* results sent to SPI manager */
+ SPI /* results sent to SPI manager */
} CommandDest;
/* ----------------
extern void NullCommand(CommandDest dest);
extern void ReadyForQuery(CommandDest dest);
extern void UpdateCommandInfo(int operation, Oid lastoid, uint32 tuples);
-
#endif /* DEST_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: fastpath.h,v 1.9 2001/06/01 15:45:42 tgl Exp $
+ * $Id: fastpath.h,v 1.10 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define FASTPATH_H
extern int HandleFunctionRequest(void);
-
#endif /* FASTPATH_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pquery.h,v 1.16 2001/01/24 19:43:28 momjian Exp $
+ * $Id: pquery.h,v 1.17 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern EState *CreateExecutorState(void);
extern Portal PreparePortal(char *portalName);
-
#endif /* PQUERY_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: tcopdebug.h,v 1.6 2001/01/24 19:43:28 momjian Exp $
+ * $Id: tcopdebug.h,v 1.7 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* #defines controlled by above definitions
* ----------------------------------------------------------------
*/
-
#endif /* TCOPDEBUG_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: tcopprot.h,v 1.43 2001/10/21 03:25:36 tgl Exp $
+ * $Id: tcopprot.h,v 1.44 2001/10/25 05:50:10 momjian Exp $
*
* OLD COMMENTS
* This file was created so that other c files could get the two
extern void pg_exec_query_string(char *query_string,
CommandDest dest,
MemoryContext parse_context);
-
#endif /* BOOTSTRAP_INCLUDE */
extern void die(SIGNAL_ARGS);
extern void quickdie(SIGNAL_ARGS);
extern void authdie(SIGNAL_ARGS);
-extern int PostgresMain(int argc, char *argv[], const char *username);
+extern int PostgresMain(int argc, char *argv[], const char *username);
extern void ResetUsage(void);
extern void ShowUsage(void);
extern FILE *StatFp;
-
#endif /* TCOPPROT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: utility.h,v 1.10 2001/01/24 19:43:28 momjian Exp $
+ * $Id: utility.h,v 1.11 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "executor/execdesc.h"
extern void ProcessUtility(Node *parsetree, CommandDest dest);
-
#endif /* UTILITY_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: acl.h,v 1.36 2001/06/12 16:34:27 momjian Exp $
+ * $Id: acl.h,v 1.37 2001/10/25 05:50:10 momjian Exp $
*
* NOTES
* For backward-compatibility purposes we have to allow there
#define ACL_MODECHG_ADD_CHR '+'
#define ACL_MODECHG_DEL_CHR '-'
#define ACL_MODECHG_EQL_CHR '='
-#define ACL_MODE_STR "arwdRxt" /* list of valid characters */
-#define ACL_MODE_INSERT_CHR 'a' /* formerly known as "append" */
-#define ACL_MODE_SELECT_CHR 'r' /* formerly known as "read" */
-#define ACL_MODE_UPDATE_CHR 'w' /* formerly known as "write" */
+#define ACL_MODE_STR "arwdRxt" /* list of valid
+ * characters */
+#define ACL_MODE_INSERT_CHR 'a' /* formerly known as "append" */
+#define ACL_MODE_SELECT_CHR 'r' /* formerly known as "read" */
+#define ACL_MODE_UPDATE_CHR 'w' /* formerly known as "write" */
#define ACL_MODE_DELETE_CHR 'd'
#define ACL_MODE_RULE_CHR 'R'
-#define ACL_MODE_REFERENCES_CHR 'x'
+#define ACL_MODE_REFERENCES_CHR 'x'
#define ACL_MODE_TRIGGER_CHR 't'
/* result codes for pg_aclcheck */
extern bool pg_ownercheck(Oid userid, const char *name, int cacheid);
extern bool pg_oper_ownercheck(Oid userid, Oid oprid);
extern bool pg_func_ownercheck(Oid userid, char *funcname,
- int nargs, Oid *arglist);
+ int nargs, Oid *arglist);
extern bool pg_aggr_ownercheck(Oid userid, char *aggname,
- Oid basetypeID);
-
+ Oid basetypeID);
#endif /* ACL_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: array.h,v 1.29 2001/03/22 04:01:10 momjian Exp $
+ * $Id: array.h,v 1.30 2001/10/25 05:50:10 momjian Exp $
*
* NOTES
* XXX the data array should be MAXALIGN'd -- currently we only INTALIGN
extern void mda_get_offset_values(int n, int *dist, int *prod, int *span);
extern int mda_next_tuple(int n, int *curr, int *span);
-
#endif /* ARRAY_H */
/* -----------------------------------------------------------------------
* ascii.h
*
- * $Id: ascii.h,v 1.5 2001/03/22 04:01:10 momjian Exp $
+ * $Id: ascii.h,v 1.6 2001/10/25 05:50:10 momjian Exp $
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
*
extern char *pg_to_ascii(unsigned char *src, unsigned char *src_end,
unsigned char *desc, int enc);
-
#endif /* MULTIBYTE */
-
#endif /* _ASCII_H_ */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: bit.h,v 1.9 2001/01/24 19:43:28 momjian Exp $
+ * $Id: bit.h,v 1.10 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* True iff the bit is set (1) in a bit array.
*/
extern bool BitArrayBitIsSet(BitArray bitArray, BitIndex bitIndex);
-
#endif /* BIT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: builtins.h,v 1.168 2001/10/13 23:32:34 tgl Exp $
+ * $Id: builtins.h,v 1.169 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "fmgr.h"
#include "nodes/primnodes.h"
-#include "storage/itemptr.h" /* for setLastTid() */
+#include "storage/itemptr.h" /* for setLastTid() */
/*
* Defined in adt/
extern List *deparse_context_for(char *relname, Oid relid);
/* tid.c */
-extern void setLastTid(const ItemPointer tid);
+extern void setLastTid(const ItemPointer tid);
extern Datum tidin(PG_FUNCTION_ARGS);
extern Datum tidout(PG_FUNCTION_ARGS);
extern Datum tideq(PG_FUNCTION_ARGS);
/* format_type.c */
extern Datum format_type(PG_FUNCTION_ARGS);
-extern char * format_type_be(Oid type_oid);
-extern char * format_type_with_typemod(Oid type_oid, int32 typemod);
+extern char *format_type_be(Oid type_oid);
+extern char *format_type_with_typemod(Oid type_oid, int32 typemod);
extern Datum oidvectortypes(PG_FUNCTION_ARGS);
extern int32 type_maximum_size(Oid type_oid, int32 typemod);
/* quote.c */
extern Datum quote_ident(PG_FUNCTION_ARGS);
extern Datum quote_literal(PG_FUNCTION_ARGS);
-
#endif /* BUILTINS_H */
extern Datum cashsmaller(PG_FUNCTION_ARGS);
extern Datum cash_words(PG_FUNCTION_ARGS);
-
#endif /* CASH_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: catcache.h,v 1.34 2001/06/19 19:42:16 tgl Exp $
+ * $Id: catcache.h,v 1.35 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
char *cc_relname; /* name of relation the tuples come from */
char *cc_indname; /* name of index matching cache keys */
int cc_reloidattr; /* AttrNumber of relation OID, or 0 */
- bool cc_relisshared; /* is relation shared? */
+ bool cc_relisshared; /* is relation shared? */
TupleDesc cc_tupdesc; /* tuple descriptor (copied from reldesc) */
int cc_ntup; /* # of tuples currently in this cache */
int cc_size; /* # of hash buckets in this cache */
int ct_magic; /* for Assert checks */
#define CT_MAGIC 0x57261502
CatCache *my_cache; /* link to owning catcache */
+
/*
* Each tuple in a cache is a member of two lists: one lists all the
* elements in all the caches in LRU order, and the other lists just
extern void AtEOXact_CatCache(bool isCommit);
extern CatCache *InitCatCache(int id, char *relname, char *indname,
- int reloidattr,
- int nkeys, int *key);
+ int reloidattr,
+ int nkeys, int *key);
extern HeapTuple SearchCatCache(CatCache *cache,
Datum v1, Datum v2,
extern void CatalogCacheIdInvalidate(int cacheId, Index hashIndex,
ItemPointer pointer);
extern void PrepareToInvalidateCacheTuple(Relation relation,
- HeapTuple tuple,
- void (*function) (int, Index, ItemPointer, Oid));
-
+ HeapTuple tuple,
+ void (*function) (int, Index, ItemPointer, Oid));
#endif /* CATCACHE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: date.h,v 1.14 2001/10/18 17:30:16 thomas Exp $
+ * $Id: date.h,v 1.15 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern Datum timetz_izone(PG_FUNCTION_ARGS);
extern Datum timetz_pl_interval(PG_FUNCTION_ARGS);
extern Datum timetz_mi_interval(PG_FUNCTION_ARGS);
-
#endif /* DATE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: datetime.h,v 1.23 2001/10/23 20:17:27 tgl Exp $
+ * $Id: datetime.h,v 1.24 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void ClearDateCache(bool);
extern int j2day(int jd);
-
#endif /* DATETIME_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: datum.h,v 1.13 2001/03/22 04:01:11 momjian Exp $
+ * $Id: datum.h,v 1.14 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
extern bool datumIsEqual(Datum value1, Datum value2,
bool typByVal, int typLen);
-
#endif /* DATUM_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: dynahash.h,v 1.8 2001/01/24 19:43:28 momjian Exp $
+ * $Id: dynahash.h,v 1.9 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define DYNAHASH_H
extern int my_log2(long num);
-
#endif /* DYNAHASH_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: dynamic_loader.h,v 1.17 2001/02/10 02:31:29 tgl Exp $
+ * $Id: dynamic_loader.h,v 1.18 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern PGFunction pg_dlsym(void *handle, char *funcname);
extern void pg_dlclose(void *handle);
extern char *pg_dlerror(void);
-
#endif /* DYNAMIC_LOADER_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: elog.h,v 1.27 2001/06/08 21:16:49 petere Exp $
+ * $Id: elog.h,v 1.28 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool Log_pid;
-extern void elog(int lev, const char *fmt,...)
+extern void
+elog(int lev, const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with
the supplied arguments. */
__attribute__((format(printf, 2, 3)));
extern int DebugFileOpen(void);
-
#endif /* ELOG_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: exc.h,v 1.19 2001/02/10 02:31:29 tgl Exp $
+ * $Id: exc.h,v 1.20 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
extern void ExcAbort(const Exception *excP, ExcDetail detail, ExcData data,
ExcMessage message);
-
#endif /* EXC_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: excid.h,v 1.10 2001/03/23 18:26:01 tgl Exp $
+ * $Id: excid.h,v 1.11 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern DLLIMPORT Exception BadArg;
extern DLLIMPORT Exception Unimplemented;
-extern DLLIMPORT Exception CatalogFailure;/* XXX inconsistent naming style */
-extern DLLIMPORT Exception InternalError; /* XXX inconsistent naming style */
-extern DLLIMPORT Exception SemanticError; /* XXX inconsistent naming style */
-extern DLLIMPORT Exception SystemError; /* XXX inconsistent naming style */
-
+extern DLLIMPORT Exception CatalogFailure; /* XXX inconsistent naming
+ * style */
+extern DLLIMPORT Exception InternalError; /* XXX inconsistent naming
+ * style */
+extern DLLIMPORT Exception SemanticError; /* XXX inconsistent naming
+ * style */
+extern DLLIMPORT Exception SystemError; /* XXX inconsistent naming style */
#endif /* EXCID_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: fcache.h,v 1.17 2001/09/21 00:11:31 tgl Exp $
+ * $Id: fcache.h,v 1.18 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* We store the fmgr lookup info to avoid recomputing it on each call.
*
* We also need to store argument values across calls when evaluating a
- * function-returning-set. This is pretty ugly (and not re-entrant);
+ * function-returning-set. This is pretty ugly (and not re-entrant);
* current-evaluation info should be somewhere in the econtext, not in
* the querytree. As it stands, a function-returning-set can't safely be
* recursive, at least not if it's in plpgsql which will try to re-use
- * the querytree at multiple execution nesting levels. FIXME someday.
+ * the querytree at multiple execution nesting levels. FIXME someday.
*/
typedef struct FunctionCache
extern FunctionCachePtr init_fcache(Oid foid, int nargs,
MemoryContext fcacheCxt);
-
#endif /* FCACHE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: fmgrtab.h,v 1.16 2001/03/22 04:01:12 momjian Exp $
+ * $Id: fmgrtab.h,v 1.17 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern const FmgrBuiltin fmgr_builtins[];
-extern const int fmgr_nbuiltins;/* number of entries in table */
-
+extern const int fmgr_nbuiltins; /* number of entries in table */
#endif /* FMGRTAB_H */
/* -----------------------------------------------------------------------
* formatting.h
*
- * $Id: formatting.h,v 1.9 2001/09/28 08:09:14 thomas Exp $
+ * $Id: formatting.h,v 1.10 2001/10/25 05:50:10 momjian Exp $
*
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
extern Datum int8_to_char(PG_FUNCTION_ARGS);
extern Datum float4_to_char(PG_FUNCTION_ARGS);
extern Datum float8_to_char(PG_FUNCTION_ARGS);
-
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: geo_decls.h,v 1.34 2001/03/22 04:01:12 momjian Exp $
+ * $Id: geo_decls.h,v 1.35 2001/10/25 05:50:10 momjian Exp $
*
* NOTE
* These routines do *not* use the float types from adt/.
extern Datum positionjoinsel(PG_FUNCTION_ARGS);
extern Datum contsel(PG_FUNCTION_ARGS);
extern Datum contjoinsel(PG_FUNCTION_ARGS);
-
#endif /* GEO_DECLS_H */
* External declarations pertaining to backend/utils/misc/guc.c and
* backend/utils/misc/guc-file.l
*
- * $Id: guc.h,v 1.10 2001/09/30 20:16:21 tgl Exp $
+ * $Id: guc.h,v 1.11 2001/10/25 05:50:10 momjian Exp $
*/
#ifndef GUC_H
#define GUC_H
*/
typedef enum
{
- PGC_POSTMASTER,
- PGC_SIGHUP,
- PGC_BACKEND,
- PGC_SUSET,
- PGC_USERSET
+ PGC_POSTMASTER,
+ PGC_SIGHUP,
+ PGC_BACKEND,
+ PGC_SUSET,
+ PGC_USERSET
} GucContext;
extern void SetConfigOption(const char *name, const char *value,
- GucContext context, bool makeDefault);
+ GucContext context, bool makeDefault);
extern const char *GetConfigOption(const char *name);
extern void ProcessConfigFile(GucContext context);
extern void ResetAllOptions(bool isStartup);
extern void ParseLongOption(const char *string, char **name, char **value);
extern bool set_config_option(const char *name, const char *value,
- GucContext context, bool DoIt, bool makeDefault);
+ GucContext context, bool DoIt, bool makeDefault);
extern void ShowAllGUCConfig(void);
extern bool SQL_inheritance;
extern bool Australian_timezones;
-
#endif /* GUC_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: hsearch.h,v 1.22 2001/10/05 17:28:13 tgl Exp $
+ * $Id: hsearch.h,v 1.23 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* tables, the initial directory size can be left at the default.
*/
#define DEF_SEGSIZE 256
-#define DEF_SEGSIZE_SHIFT 8 /* must be log2(DEF_SEGSIZE) */
+#define DEF_SEGSIZE_SHIFT 8/* must be log2(DEF_SEGSIZE) */
#define DEF_DIRSIZE 256
-#define DEF_FFACTOR 1 /* default fill factor */
+#define DEF_FFACTOR 1/* default fill factor */
#define PRIME1 37 /* for the hash function */
#define PRIME2 1048583
*/
typedef struct HTAB
{
- HASHHDR *hctl; /* shared control information */
+ HASHHDR *hctl; /* shared control information */
HASHSEGMENT *dir; /* directory of segment starts */
- long (*hash) (void *key, int keysize); /* Hash Function */
- void *(*alloc) (Size);/* memory allocator */
- MemoryContext hcxt; /* memory context if default allocator used */
+ long (*hash) (void *key, int keysize); /* Hash Function */
+ void *(*alloc) (Size); /* memory allocator */
+ MemoryContext hcxt; /* memory context if default allocator
+ * used */
char *tabname; /* table name (for error messages) */
bool isshared; /* true if table is in shared memory */
} HTAB;
long ssize; /* Segment Size */
long dsize; /* (initial) Directory Size */
long ffactor; /* Fill factor */
- long (*hash) (void *key, int keysize); /* Hash Function */
+ long (*hash) (void *key, int keysize); /* Hash Function */
long keysize; /* hash key length in bytes */
long entrysize; /* total user element size in bytes */
long max_dsize; /* limit to dsize if directory size is
* limited */
- void *(*alloc) (Size);/* memory allocation function */
+ void *(*alloc) (Size); /* memory allocation function */
HASHSEGMENT *dir; /* directory of segment starts */
- HASHHDR *hctl; /* location of header in shared mem */
+ HASHHDR *hctl; /* location of header in shared mem */
MemoryContext hcxt; /* memory context to use for allocations */
} HASHCTL;
/* hash_search operations */
typedef enum
{
- HASH_FIND,
- HASH_ENTER,
- HASH_REMOVE,
- HASH_FIND_SAVE,
- HASH_REMOVE_SAVED
+ HASH_FIND,
+ HASH_ENTER,
+ HASH_REMOVE,
+ HASH_FIND_SAVE,
+ HASH_REMOVE_SAVED
} HASHACTION;
/* hash_seq status (should be considered an opaque type by callers) */
* prototypes for functions in dynahash.c
*/
extern HTAB *hash_create(const char *tabname, long nelem,
- HASHCTL *info, int flags);
+ HASHCTL *info, int flags);
extern void hash_destroy(HTAB *hashp);
extern void hash_stats(const char *where, HTAB *hashp);
extern void *hash_search(HTAB *hashp, void *keyPtr, HASHACTION action,
*/
extern long string_hash(void *key, int keysize);
extern long tag_hash(void *key, int keysize);
-
#endif /* HSEARCH_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: inet.h,v 1.10 2001/03/22 04:01:12 momjian Exp $
+ * $Id: inet.h,v 1.11 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define PG_GETARG_MACADDR_P(n) DatumGetMacaddrP(PG_GETARG_DATUM(n))
#define PG_RETURN_MACADDR_P(x) return MacaddrPGetDatum(x)
-
#endif /* INET_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: int8.h,v 1.27 2001/08/14 22:21:59 tgl Exp $
+ * $Id: int8.h,v 1.28 2001/10/25 05:50:10 momjian Exp $
*
* NOTES
* These data types are supported on all 64-bit architectures, and may
extern Datum int8_text(PG_FUNCTION_ARGS);
extern Datum text_int8(PG_FUNCTION_ARGS);
-
#endif /* INT8_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: inval.h,v 1.20 2001/06/19 19:42:16 tgl Exp $
+ * $Id: inval.h,v 1.21 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple);
extern void RelationMark4RollbackHeapTuple(Relation relation, HeapTuple tuple);
-
#endif /* INVAL_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: logtape.h,v 1.4 2001/01/24 19:43:28 momjian Exp $
+ * $Id: logtape.h,v 1.5 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
long blocknum, int offset);
extern void LogicalTapeTell(LogicalTapeSet *lts, int tapenum,
long *blocknum, int *offset);
-
#endif /* LOGTAPE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: lsyscache.h,v 1.36 2001/09/06 02:07:42 tgl Exp $
+ * $Id: lsyscache.h,v 1.37 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool get_attisset(Oid relid, char *attname);
extern int32 get_atttypmod(Oid relid, AttrNumber attnum);
extern void get_atttypetypmod(Oid relid, AttrNumber attnum,
- Oid *typid, int32 *typmod);
+ Oid *typid, int32 *typmod);
extern bool opclass_is_btree(Oid opclass);
extern RegProcedure get_opcode(Oid opno);
extern char *get_opname(Oid opno);
extern int32 get_typavgwidth(Oid typid, int32 typmod);
extern int32 get_attavgwidth(Oid relid, AttrNumber attnum);
extern bool get_attstatsslot(HeapTuple statstuple,
- Oid atttype, int32 atttypmod,
- int reqkind, Oid reqop,
- Datum **values, int *nvalues,
- float4 **numbers, int *nnumbers);
+ Oid atttype, int32 atttypmod,
+ int reqkind, Oid reqop,
+ Datum **values, int *nvalues,
+ float4 **numbers, int *nnumbers);
extern void free_attstatsslot(Oid atttype,
- Datum *values, int nvalues,
- float4 *numbers, int nnumbers);
+ Datum *values, int nvalues,
+ float4 *numbers, int nnumbers);
extern int32 get_usesysid(const char *username);
#define TypeIsToastable(typid) (get_typstorage(typid) != 'p')
-
#endif /* LSYSCACHE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: memutils.h,v 1.43 2001/03/22 04:01:13 momjian Exp $
+ * $Id: memutils.h,v 1.44 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define ALLOCSET_DEFAULT_INITSIZE (8 * 1024)
#define ALLOCSET_DEFAULT_MAXSIZE (8 * 1024 * 1024)
-
#endif /* MEMUTILS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nabstime.h,v 1.32 2001/10/18 17:30:16 thomas Exp $
+ * $Id: nabstime.h,v 1.33 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern AbsoluteTime GetCurrentAbsoluteTime(void);
extern AbsoluteTime GetCurrentAbsoluteTimeUsec(int *usec);
extern void abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char **tzn);
-
#endif /* NABSTIME_H */
*
* 1998 Jan Wieck
*
- * $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.12 2001/03/22 04:01:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.13 2001/10/25 05:50:10 momjian Exp $
*
* ----------
*/
#define PG_GETARG_NUMERIC(n) DatumGetNumeric(PG_GETARG_DATUM(n))
#define PG_GETARG_NUMERIC_COPY(n) DatumGetNumericCopy(PG_GETARG_DATUM(n))
#define PG_RETURN_NUMERIC(x) return NumericGetDatum(x)
-
#endif /* _PG_NUMERIC_H_ */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: palloc.h,v 1.16 2001/03/22 04:01:13 momjian Exp $
+ * $Id: palloc.h,v 1.17 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define pstrdup(str) MemoryContextStrdup(CurrentMemoryContext, (str))
-
#endif /* PALLOC_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_crc.h,v 1.3 2001/03/23 18:42:12 tgl Exp $
+ * $Id: pg_crc.h,v 1.4 2001/10/25 05:50:10 momjian Exp $
*/
#ifndef PG_CRC_H
#define PG_CRC_H
/* Constant table for CRC calculation */
extern const uint64 crc_table[];
-
#endif /* INT64_IS_BUSTED */
-
#endif /* PG_CRC_H */
* The PostgreSQL locale utils.
*
*
- * $Id: pg_locale.h,v 1.8 2001/09/29 21:16:30 tgl Exp $
+ * $Id: pg_locale.h,v 1.9 2001/10/25 05:50:10 momjian Exp $
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
*
*lc_collate,
*lc_monetary,
*lc_messages;
-} PG_LocaleCategories;
+} PG_LocaleCategories;
/*
- * Save locale category settings into PG memory
+ * Save locale category settings into PG memory
*/
-extern void PGLC_current(PG_LocaleCategories * lc);
+extern void PGLC_current(PG_LocaleCategories *lc);
+
/*
* Free memory allocated in PGLC_current()
*/
-extern void PGLC_free_categories(PG_LocaleCategories * lc);
+extern void PGLC_free_categories(PG_LocaleCategories *lc);
/*------
* Return the POSIX lconv struct (contains number/money formatting information)
*/
extern struct lconv *PGLC_localeconv(void);
-
#endif /* USE_LOCALE */
-
#endif /* _PG_LOCALE_ */
/* ----------
* pg_lzcompress.h -
*
- * $Header: /cvsroot/pgsql/src/include/utils/pg_lzcompress.h,v 1.5 2000/04/12 17:16:55 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/include/utils/pg_lzcompress.h,v 1.6 2001/10/25 05:50:10 momjian Exp $
*
* Definitions for the builtin LZ compressor
* ----------
*/
extern int pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate);
extern int pglz_get_next_decomp_char_from_plain(PGLZ_DecompState *dstate);
-
#endif /* _PG_LZCOMPRESS_H_ */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: portal.h,v 1.29 2001/10/05 17:28:13 tgl Exp $
+ * $Id: portal.h,v 1.30 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool atStart; /* T => fetch backwards is not allowed */
bool atEnd; /* T => fetch forwards is not allowed */
void (*cleanup) (Portal); /* Cleanup routine (optional) */
-} PortalData;
+} PortalData;
/*
* PortalIsValid
TupleDesc attinfo, EState *state,
void (*cleanup) (Portal portal));
-
#endif /* PORTAL_H */
*
* Declarations for backend/utils/misc/ps_status.c
*
- * $Id: ps_status.h,v 1.20 2001/10/21 03:25:36 tgl Exp $
+ * $Id: ps_status.h,v 1.21 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void save_ps_display_args(int argc, char *argv[]);
extern void init_ps_display(const char *username, const char *dbname,
- const char *host_info);
+ const char *host_info);
extern void set_ps_display(const char *activity);
extern const char *get_ps_display(void);
-
#endif /* PS_STATUS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rel.h,v 1.52 2001/10/06 23:21:44 tgl Exp $
+ * $Id: rel.h,v 1.53 2001/10/25 05:50:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef struct TriggerDesc
{
/*
- * Index data to identify which triggers are which. Since each trigger
- * can appear in more than one class, for each class we provide a list
- * of integer indexes into the triggers array.
+ * Index data to identify which triggers are which. Since each
+ * trigger can appear in more than one class, for each class we
+ * provide a list of integer indexes into the triggers array.
*/
#define TRIGGER_NUM_EVENT_CLASSES 4
* Same for the statistics collector data in Relation and scan data.
* ----------
*/
-typedef struct PgStat_Info
+typedef struct PgStat_Info
{
- void *tabentry;
- bool no_stats;
- bool heap_scan_counted;
- bool index_scan_counted;
+ void *tabentry;
+ bool no_stats;
+ bool heap_scan_counted;
+ bool index_scan_counted;
} PgStat_Info;
/*
{
File rd_fd; /* open file descriptor, or -1 if none */
RelFileNode rd_node; /* file node (physical identifier) */
- BlockNumber rd_nblocks; /* number of blocks in rel */
- BlockNumber rd_targblock; /* current insertion target block,
- * or InvalidBlockNumber */
+ BlockNumber rd_nblocks; /* number of blocks in rel */
+ BlockNumber rd_targblock; /* current insertion target block, or
+ * InvalidBlockNumber */
int rd_refcnt; /* reference count */
bool rd_myxactonly; /* rel uses the local buffer mgr */
bool rd_isnailed; /* rel is nailed in cache */
MemoryContext rd_indexcxt; /* private memory cxt for this stuff */
IndexStrategy rd_istrat; /* operator strategy map */
RegProcedure *rd_support; /* OIDs of support procedures */
- struct FmgrInfo *rd_supportinfo; /* lookup info for support procedures */
+ struct FmgrInfo *rd_supportinfo; /* lookup info for support
+ * procedures */
/* "struct FmgrInfo" avoids need to include fmgr.h here */
/* statistics collection area */
- PgStat_Info pgstat_info;
+ PgStat_Info pgstat_info;
} RelationData;
typedef RelationData *Relation;
/* added to prevent circular dependency. bjm 1999/11/15 */
extern char *get_temp_rel_by_physicalname(const char *relname);
-
#endif /* REL_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: relcache.h,v 1.26 2001/10/06 23:21:44 tgl Exp $
+ * $Id: relcache.h,v 1.27 2001/10/25 05:50:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* Routine to create a relcache entry for an about-to-be-created relation
*/
extern Relation RelationBuildLocalRelation(const char *relname,
- TupleDesc tupDesc,
- Oid relid, Oid dbid,
- bool nailit);
+ TupleDesc tupDesc,
+ Oid relid, Oid dbid,
+ bool nailit);
/*
* Routines for flushing/rebuilding relcache entries in various scenarios
*/
#define RELCACHE_INIT_FILENAME "pg_internal.init"
-
#endif /* RELCACHE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: selfuncs.h,v 1.1 2001/06/25 21:11:45 tgl Exp $
+ * $Id: selfuncs.h,v 1.2 2001/10/25 05:50:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef enum
{
- Pattern_Type_Like, Pattern_Type_Like_IC,
- Pattern_Type_Regex, Pattern_Type_Regex_IC
+ Pattern_Type_Like, Pattern_Type_Like_IC,
+ Pattern_Type_Regex, Pattern_Type_Regex_IC
} Pattern_Type;
typedef enum
{
- Pattern_Prefix_None, Pattern_Prefix_Partial, Pattern_Prefix_Exact
+ Pattern_Prefix_None, Pattern_Prefix_Partial, Pattern_Prefix_Exact
} Pattern_Prefix_Status;
extern Datum rtcostestimate(PG_FUNCTION_ARGS);
extern Datum hashcostestimate(PG_FUNCTION_ARGS);
extern Datum gistcostestimate(PG_FUNCTION_ARGS);
-
#endif /* SELFUNCS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: sets.h,v 1.9 2001/01/24 19:43:29 momjian Exp $
+ * $Id: sets.h,v 1.10 2001/10/25 05:50:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern Oid SetDefine(char *querystr, char *typename);
extern Datum seteval(PG_FUNCTION_ARGS);
-
#endif /* SETS_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: syscache.h,v 1.33 2001/08/21 16:36:06 tgl Exp $
+ * $Id: syscache.h,v 1.34 2001/10/25 05:50:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern HeapTuple SearchSysCacheCopy(int cacheId,
Datum key1, Datum key2, Datum key3, Datum key4);
extern bool SearchSysCacheExists(int cacheId,
- Datum key1, Datum key2, Datum key3, Datum key4);
+ Datum key1, Datum key2, Datum key3, Datum key4);
extern Oid GetSysCacheOid(int cacheId,
Datum key1, Datum key2, Datum key3, Datum key4);
extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
AttrNumber attributeNumber, bool *isNull);
-
#endif /* SYSCACHE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: temprel.h,v 1.17 2001/06/19 12:03:41 momjian Exp $
+ * $Id: temprel.h,v 1.18 2001/10/25 05:50:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern char *get_temp_rel_by_physicalname(const char *relname);
#define is_temp_rel_name(relname) (get_temp_rel_by_username(relname) != NULL)
-
#endif /* TEMPREL_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: timestamp.h,v 1.21 2001/10/18 17:30:16 thomas Exp $
+ * $Id: timestamp.h,v 1.22 2001/10/25 05:50:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef struct
{
- double time; /* all time units other than months and years */
- int32 month; /* months and years, after time for alignment */
+ double time; /* all time units other than months and
+ * years */
+ int32 month; /* months and years, after time for
+ * alignment */
} Interval;
* Therefore Timestamp is pass-by-reference if and only if float8 is!
*/
#define DatumGetTimestamp(X) ((Timestamp) DatumGetFloat8(X))
-#define DatumGetTimestampTz(X) ((TimestampTz) DatumGetFloat8(X))
+#define DatumGetTimestampTz(X) ((TimestampTz) DatumGetFloat8(X))
#define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X))
#define TimestampGetDatum(X) Float8GetDatum(X)
/* Internal routines (not fmgr-callable) */
extern int tm2timestamp(struct tm * tm, double fsec, int *tzp, Timestamp *dt);
-extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm,
- double *fsec, char **tzn);
-extern void dt2time(Timestamp dt, int *hour, int *min, double *sec);
+extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm,
+ double *fsec, char **tzn);
+extern void dt2time(Timestamp dt, int *hour, int *min, double *sec);
extern int interval2tm(Interval span, struct tm * tm, float8 *fsec);
extern int tm2interval(struct tm * tm, double fsec, Interval *span);
extern void isoweek2date(int woy, int *year, int *mon, int *mday);
extern int date2isoweek(int year, int mon, int mday);
-
#endif /* TIMESTAMP_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: tqual.h,v 1.34 2001/08/26 16:56:03 tgl Exp $
+ * $Id: tqual.h,v 1.35 2001/10/25 05:50:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* Result codes for HeapTupleSatisfiesVacuum */
typedef enum
{
- HEAPTUPLE_DEAD, /* tuple is dead and deletable */
- HEAPTUPLE_LIVE, /* tuple is live (committed, no deleter) */
- HEAPTUPLE_RECENTLY_DEAD, /* tuple is dead, but not deletable yet */
- HEAPTUPLE_INSERT_IN_PROGRESS, /* inserting xact is still in progress */
- HEAPTUPLE_DELETE_IN_PROGRESS /* deleting xact is still in progress */
+ HEAPTUPLE_DEAD, /* tuple is dead and deletable */
+ HEAPTUPLE_LIVE, /* tuple is live (committed, no deleter) */
+ HEAPTUPLE_RECENTLY_DEAD, /* tuple is dead, but not
+ * deletable yet */
+ HEAPTUPLE_INSERT_IN_PROGRESS, /* inserting xact is still
+ * in progress */
+ HEAPTUPLE_DELETE_IN_PROGRESS /* deleting xact is still
+ * in progress */
} HTSV_Result;
extern bool HeapTupleSatisfiesItself(HeapTupleHeader tuple);
Snapshot snapshot);
extern int HeapTupleSatisfiesUpdate(HeapTuple tuple);
extern HTSV_Result HeapTupleSatisfiesVacuum(HeapTupleHeader tuple,
- TransactionId OldestXmin);
+ TransactionId OldestXmin);
extern Snapshot GetSnapshotData(bool serializable);
extern void SetQuerySnapshot(void);
extern void FreeXactSnapshot(void);
-
#endif /* TQUAL_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: tuplesort.h,v 1.8 2001/06/02 19:01:52 tgl Exp $
+ * $Id: tuplesort.h,v 1.9 2001/10/25 05:50:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
extern Tuplesortstate *tuplesort_begin_heap(TupleDesc tupDesc,
- int nkeys,
- Oid *sortOperators, AttrNumber *attNums,
- bool randomAccess);
+ int nkeys,
+ Oid *sortOperators, AttrNumber *attNums,
+ bool randomAccess);
extern Tuplesortstate *tuplesort_begin_index(Relation indexRel,
bool enforceUnique,
bool randomAccess);
*/
typedef enum
{
- SORTFUNC_LT, /* raw "<" operator */
- SORTFUNC_REVLT, /* raw "<" operator, but reverse NULLs */
- SORTFUNC_CMP, /* -1 / 0 / 1 three-way comparator */
- SORTFUNC_REVCMP /* 1 / 0 / -1 (reversed) 3-way comparator */
+ SORTFUNC_LT, /* raw "<" operator */
+ SORTFUNC_REVLT, /* raw "<" operator, but reverse NULLs */
+ SORTFUNC_CMP, /* -1 / 0 / 1 three-way comparator */
+ SORTFUNC_REVCMP /* 1 / 0 / -1 (reversed) 3-way comparator */
} SortFunctionKind;
extern void SelectSortFunction(Oid sortOperator,
- RegProcedure *sortFunction,
- SortFunctionKind *kind);
+ RegProcedure *sortFunction,
+ SortFunctionKind *kind);
/*
* Apply a sort function (by now converted to fmgr lookup form)
* NULLs and sort ordering direction properly.
*/
extern int32 ApplySortFunction(FmgrInfo *sortFunction, SortFunctionKind kind,
- Datum datum1, bool isNull1,
- Datum datum2, bool isNull2);
-
+ Datum datum1, bool isNull1,
+ Datum datum2, bool isNull2);
#endif /* TUPLESORT_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: tuplestore.h,v 1.3 2001/03/22 04:01:15 momjian Exp $
+ * $Id: tuplestore.h,v 1.4 2001/10/25 05:50:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void tuplestore_rescan(Tuplestorestate *state);
extern void tuplestore_markpos(Tuplestorestate *state);
extern void tuplestore_restorepos(Tuplestorestate *state);
-
#endif /* TUPLESTORE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: varbit.h,v 1.11 2001/05/22 16:37:17 petere Exp $
+ * $Id: varbit.h,v 1.12 2001/10/25 05:50:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern Datum bitfromint4(PG_FUNCTION_ARGS);
extern Datum bittoint4(PG_FUNCTION_ARGS);
extern Datum bitposition(PG_FUNCTION_ARGS);
-
#endif
int print_err(SQLSMALLINT handletype, SQLINTEGER handle);
int
-example1(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen)
+example1(SQLCHAR * server, SQLCHAR * uid, SQLCHAR * authen)
{
SQLHENV henv;
SQLHDBC hdbc;
/* this time, explicitly allocate an application row descriptor */
SQLAllocHandle(SQL_HANDLE_DESC, hdbc, &hdesc);
SQLSetDescRec(hdesc, 1, SQL_INTEGER, 0, 0L, 0, 0,
- (SQLPOINTER) & id, (SQLINTEGER *) NULL, (SQLSMALLINT *) &idind);
+ (SQLPOINTER) & id, (SQLINTEGER *) NULL, (SQLSMALLINT *) & idind);
SQLSetDescRec(hdesc, 2, SQL_
CHAR, 0, (SQLINTEGER) sizeof(name),
- 0, 0, (SQLPOINTER) & name, (SQLINTEGER *) &namelen,
- (SQLSMALLINT *) &nameind);
+ 0, 0, (SQLPOINTER) & name, (SQLINTEGER *) & namelen,
+ (SQLSMALLINT *) & nameind);
/* associate descriptor with statement handle */
SQLSetStmtAttr(hstmt, SQL_ATTR_APP_ROW_DESC, &hdesc, 0);
/* execute the fetch */
#define max(a,b) (a>b?a:b)
int print_err(SQLSMALLINT handletype, SQLINTEGER handle);
-int build_indicator_message(SQLCHAR *errmsg,
+int build_indicator_message(SQLCHAR * errmsg,
SQLPOINTER * data,
SQLINTEGER collen,
- SQLINTEGER *outlen,
+ SQLINTEGER * outlen,
SQLSMALLINT colnum);
SQLINTEGER display_length(SQLSMALLINT coltype,
SQLINTEGER collen,
- SQLCHAR *colname);
+ SQLCHAR * colname);
-example2(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen, SQLCHAR *sqlstr)
+example2(SQLCHAR * server, SQLCHAR * uid, SQLCHAR * authen, SQLCHAR * sqlstr)
{
int i;
SQLHENV henv;
SQLINTEGER
display_length(SQLSMALLINT coltype, SQLINTEGER collen,
- SQLCHAR *colname)
+ SQLCHAR * colname)
{
switch (coltype)
{
- case SQL_VARCHAR:
- case SQL_CHAR:
+ case SQL_VARCHAR:
+ case SQL_CHAR:
return (max(collen, strlen((char *) colname)));
break;
}
int
-build_indicator_message(SQLCHAR *errmsg, SQLPOINTER * data,
- SQLINTEGER collen, SQLINTEGER *outlen, SQLSMALLINT colnum)
+build_indicator_message(SQLCHAR * errmsg, SQLPOINTER * data,
+ SQLINTEGER collen, SQLINTEGER * outlen, SQLSMALLINT colnum)
{
if (*outlen == SQL_NULL_DATA)
{
SQLRETURN SQLAllocHandle(SQLSMALLINT HandleType,
SQLINTEGER InputHandle,
- SQLINTEGER *OutputHandle);
+ SQLINTEGER * OutputHandle);
SQLRETURN SQLAllocStmt(SQLHDBC ConnectionHandle,
SQLSTMT * StatementHandle);
SQLSMALLINT BufferType,
SQLPOINTER Data,
SQLINTEGER BufferLength,
- SQLINTEGER *DataLength);
+ SQLINTEGER * DataLength);
SQLRETURN SQLBindParam(SQLHSTMT StatementHandle,
SQLSMALLINT ParamNumber,
SQLINTEGER ParamLength,
SQLSMALLINT Scale,
SQLPOINTER Data,
- SQLINTEGER *DataLength);
+ SQLINTEGER * DataLength);
SQLRETURN SQLCancel(SQLHSTMT StatementHandle);
SQLRETURN SQLColAttribute(SQLHSTMT StatementHandle,
SQLSMALLINT ColumnNumber,
SQLSMALLINT FieldIdentifier,
- SQLCHAR *CharacterAttribute,
+ SQLCHAR * CharacterAttribute,
SQLINTEGER BufferLength,
- SQLINTEGER *AttributetLength,
- SQLINTEGER *NumericAttribute);
+ SQLINTEGER * AttributetLength,
+ SQLINTEGER * NumericAttribute);
SQLRETURN SQLConnect(SQLHDBC ConnectionHandle,
- SQLCHAR *ServerName,
+ SQLCHAR * ServerName,
SQLSMALLINT NameLength1,
- SQLCHAR *UserName,
+ SQLCHAR * UserName,
SQLSMALLINT NameLength2,
- SQLCHAR *Authentication,
+ SQLCHAR * Authentication,
SQLSMALLINT NameLength3);
SQLRETURN SQLCopyDesc(SQLHDESC SourceDescHandle,
SQLRETURN SQLDataSources(SQLHENV EnvironmentHandle,
SQLSMALLINT Direction,
- SQLCHAR *ServerName,
+ SQLCHAR * ServerName,
SQLSMALLINT BufferLength1,
- SQLSMALLINT *NameLength1,
- SQLCHAR *Description,
+ SQLSMALLINT * NameLength1,
+ SQLCHAR * Description,
SQLSMALLINT BufferLength2,
- SQLSMALLINT *NameLength2);
+ SQLSMALLINT * NameLength2);
SQLRETURN SQLDescribeCol(SQLHSTMT StatementHandle,
SQLSMALLINT ColumnNumber,
- SQLCHAR *ColumnName,
+ SQLCHAR * ColumnName,
SQLSMALLINT BufferLength,
- SQLSMALLINT *ColumnNameLength,
- SQLSMALLINT *ColumnType,
- SQLINTEGER *ColumnLength,
- SQLSMALLINT *ColumnScale,
- SQLSMALLINT *Nullable);
+ SQLSMALLINT * ColumnNameLength,
+ SQLSMALLINT * ColumnType,
+ SQLINTEGER * ColumnLength,
+ SQLSMALLINT * ColumnScale,
+ SQLSMALLINT * Nullable);
SQLRETURN SQLDisconnect(SQLHDBC ConnectionHandle);
SQLRETURN SQLError(SQLHENV EnvironmentHandle,
SQLHDBC ConnectionHandle,
SQLSTMT StatementHandle,
- SQLCHAR *Sqlstate,
- SQLINTEGER *NativeError,
- SQLCHAR *MessageText,
+ SQLCHAR * Sqlstate,
+ SQLINTEGER * NativeError,
+ SQLCHAR * MessageText,
SQLINTEGER BufferLength,
- SQLINTEGER *TextLength);
+ SQLINTEGER * TextLength);
SQLRETURN SQLExecDirect(SQLHSTMT StatementHandle,
- SQLCHAR *StatementText,
+ SQLCHAR * StatementText,
SQLSMALLINT StringLength);
SQLRETURN SQLExecute(SQLHSTMT StatementHandle);
SQLINTEGER Attribute,
SQLPOINTER Value,
SQLINTEGER BufferLength,
- SQLINTEGER *StringLength);
+ SQLINTEGER * StringLength);
SQLRETURN SQLGetCursorName(SQLHSTMT StatementHandle,
- SQLCHAR *CursorName,
+ SQLCHAR * CursorName,
SQLSMALLINT BufferLength,
- SQLSMALLINT *NameLength);
+ SQLSMALLINT * NameLength);
SQLRETURN SQLGetData(SQLHSTMT StatementHandle,
SQLSMALLINT ColumnNumber,
SQLSMALLINT TargetType,
SQLPOINTER TargetValue,
SQLINTEGER BufferLength,
- SQLINTEGER *IndicatorValue);
+ SQLINTEGER * IndicatorValue);
SQLRETURN SQLGetDescField(SQLHDESC DescriptorHandle,
SQLSMALLINT RecordNumber,
SQLSMALLINT FieldIdentifier,
SQLPOINTER Value,
SQLINTEGER BufferLength,
- SQLINTEGER *StringLength);
+ SQLINTEGER * StringLength);
SQLRETURN SQLGetDescRec(SQLHDESC DescriptorHandle,
SQLSMALLINT RecordNumber,
- SQLCHAR *Name,
+ SQLCHAR * Name,
SQLSMALLINT BufferLength,
- SQLSMALLINT *StringLength,
- SQLSMALLINT *Type,
- SQLSMALLINT *SubType,
- SQLINTEGER *Length,
- SQLSMALLINT *Precision,
- SQLSMALLINT *Scale,
- SQLSMALLINT *Nullable);
+ SQLSMALLINT * StringLength,
+ SQLSMALLINT * Type,
+ SQLSMALLINT * SubType,
+ SQLINTEGER * Length,
+ SQLSMALLINT * Precision,
+ SQLSMALLINT * Scale,
+ SQLSMALLINT * Nullable);
SQLRETURN SQLGetDiagField(SQLSMALLINT HandleType,
SQLINTEGER Handle,
SQLSMALLINT DiagIdentifier,
SQLPOINTER DiagInfo,
SQLSMALLINT BufferLength,
- SQLSMALLINT *StringLength);
+ SQLSMALLINT * StringLength);
SQLRETURN SQLGetDiagRec(SQLSMALLINT HandleType,
SQLINTEGER Handle,
SQLSMALLINT RecordNumber,
- SQLCHAR *Sqlstate,
- SQLINTEGER *NativeError,
- SQLCHAR *MessageText,
+ SQLCHAR * Sqlstate,
+ SQLINTEGER * NativeError,
+ SQLCHAR * MessageText,
SQLSMALLINT BufferLength,
- SQLSMALLINT *StringLength);
+ SQLSMALLINT * StringLength);
SQLRETURN SQLGetEnvAttr(SQLHENV EnvironmentHandle,
SQLINTEGER Attribute,
SQLPOINTER Value,
SQLINTEGER BufferLength,
- SQLINTEGER *StringLength);
+ SQLINTEGER * StringLength);
SQLRETURN SQLGetFunctions(SQLHDBC ConnectionHandle,
SQLSMALLINT FunctionId,
- SQLSMALLINT *Supported);
+ SQLSMALLINT * Supported);
SQLRETURN SQLGetInfo(SQLHDBC ConnectionHandle,
SQLSMALLINT InfoType,
SQLPOINTER InfoValue,
SQLSMALLINT BufferLength,
- SQLSMALLINT *StringLength);
+ SQLSMALLINT * StringLength);
SQLRETURN SQLGetStmtAttr(SQLHSTMT StatementHandle,
SQLINTEGER Attribute,
SQLPOINTER Value,
SQLINTEGER BufferLength,
- SQLINTEGER *StringLength);
+ SQLINTEGER * StringLength);
SQLRETURN SQLGetTypeInfo(SQLHSTMT StatementHandle,
SQLSMALLINT DataType);
SQLRETURN SQLNumResultCols(SQLHSTMT StatementHandle,
- SQLINTEGER *ColumnCount);
+ SQLINTEGER * ColumnCount);
SQLRETURN SQLParamData(SQLHSTMT StatementHandle,
SQLPOINTER * Value);
SQLRETURN SQLPrepare(SQLHSTMT StatementHandle,
- SQLCHAR *StatementText,
+ SQLCHAR * StatementText,
SQLSMALLINT StringLength);
SQLINTEGER StringLength);
SQLRETURN SQLRowCount(SQLHSTMT StatementHandle,
- SQLINTEGER *RowCount);
+ SQLINTEGER * RowCount);
SQLRETURN SQLSetConnectAttr(SQLHDBC ConnectionHandle,
SQLINTEGER AttributeCursorName,
SQLINTEGER StringLength);
SQLRETURN SQLSetCursorName(SQLHSTMT StatementHandle,
- SQLCHAR *CursorName,
+ SQLCHAR * CursorName,
SQLSMALLINT NameLength);
SQLRETURN SQLSetDescField(SQLHDESC DescriptorHandle,
SQLSMALLINT Precision,
SQLSMALLINT Scale,
SQLPOINTER Data,
- SQLINTEGER *StringLength,
- SQLSMALLINT *Indicator);
+ SQLINTEGER * StringLength,
+ SQLSMALLINT * Indicator);
SQLRETURN SQLSetEnvAttr(SQLHENV EnvironmentHandle,
SQLINTEGER Attribute,
#define ECPG_NOTICE_NO_TRANSACTION -604
/* NOTICE: BlankPortalAssignName: portal * already exists */
#define ECPG_NOTICE_PORTAL_EXISTS -605
-
#endif /* !_ECPG_ERROR_H */
#ifdef __cplusplus
}
-
#endif
ECPGt_EORT, /* End of result types. */
ECPGt_NO_INDICATOR, /* no indicator */
ECPGt_long_long, ECPGt_unsigned_long_long,
- ECPGt_descriptor /* sql descriptor, no C variable */
+ ECPGt_descriptor /* sql descriptor, no C variable */
};
/* descriptor items */
#ifdef __cplusplus
}
-
#endif
*
* Copyright (c) 2000, Christof Petig
*
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/include/sql3types.h,v 1.5 2001/09/19 14:09:32 meskes Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/include/sql3types.h,v 1.6 2001/10/25 05:50:11 momjian Exp $
*/
/* chapter 13.1 table 2: Codes used for SQL data types in Dynamic SQL */
enum
{
- SQL3_CHARACTER = 1,
- SQL3_NUMERIC,
- SQL3_DECIMAL,
- SQL3_INTEGER,
- SQL3_SMALLINT,
- SQL3_FLOAT,
- SQL3_REAL,
- SQL3_DOUBLE_PRECISION,
- SQL3_DATE_TIME_TIMESTAMP,
- SQL3_INTERVAL, /* 10 */
- SQL3_CHARACTER_VARYING = 12,
- SQL3_ENUMERATED,
- SQL3_BIT,
- SQL3_BIT_VARYING,
- SQL3_BOOLEAN,
- SQL3_abstract
+ SQL3_CHARACTER = 1,
+ SQL3_NUMERIC,
+ SQL3_DECIMAL,
+ SQL3_INTEGER,
+ SQL3_SMALLINT,
+ SQL3_FLOAT,
+ SQL3_REAL,
+ SQL3_DOUBLE_PRECISION,
+ SQL3_DATE_TIME_TIMESTAMP,
+ SQL3_INTERVAL, /* 10 */
+ SQL3_CHARACTER_VARYING = 12,
+ SQL3_ENUMERATED,
+ SQL3_BIT,
+ SQL3_BIT_VARYING,
+ SQL3_BOOLEAN,
+ SQL3_abstract
/* the rest is xLOB stuff */
};
enum
{
- SQL3_DDT_DATE = 1,
- SQL3_DDT_TIME,
- SQL3_DDT_TIMESTAMP,
- SQL3_DDT_TIME_WITH_TIME_ZONE,
- SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE,
+ SQL3_DDT_DATE = 1,
+ SQL3_DDT_TIME,
+ SQL3_DDT_TIMESTAMP,
+ SQL3_DDT_TIME_WITH_TIME_ZONE,
+ SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE,
- SQL3_DDT_ILLEGAL /* not a datetime data type (not part of
+ SQL3_DDT_ILLEGAL/* not a datetime data type (not part of
* standard) */
};
#define DLLIMPORT __declspec (dllimport)
#else
#define DLLIMPORT
-#endif /* __CYGWIN__ */
-#endif /* DLLIMPORT */
+#endif /* __CYGWIN__ */
+#endif /* DLLIMPORT */
#define SQLERRMC_LEN 70
/*
* 2: if 'W' a (hopefully) non-fatal notice occured
- *//* 3: empty */
+*//* 3: empty */
/* 4: empty */
/* 5: empty */
/* 6: empty */
#ifdef __cplusplus
}
-
#endif
-
#endif
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.12 2001/09/19 14:09:32 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.13 2001/10/25 05:50:11 momjian Exp $ */
#include "postgres_fe.h"
/*------
* new style:
- * :postgresql://server[:port|:/unixsocket/path:]
+ * :postgresql://server[:port|:/unixsocket/path:]
* [/db name][?options]
*------
*/
/* dynamic SQL support routines
*
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.16 2001/09/19 14:09:32 meskes Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.17 2001/10/25 05:50:11 momjian Exp $
*/
#include "postgres_fe.h"
*
ECPGresultByDescriptor(int line, const char *name)
{
- PGresult **resultpp = ECPGdescriptor_lvalue ( line, name );
- if (resultpp) return *resultpp;
+ PGresult **resultpp = ECPGdescriptor_lvalue(line, name);
+
+ if (resultpp)
+ return *resultpp;
return NULL;
}
{
switch (type)
{
- case 1082:return SQL3_DDT_DATE; /* date */
+ case 1082:
+ return SQL3_DDT_DATE; /* date */
case 1083:
return SQL3_DDT_TIME; /* time */
case 1184:
{
switch (vartype)
{
- case ECPGt_char:
- case ECPGt_unsigned_char:
+ case ECPGt_char:
+ case ECPGt_unsigned_char:
strncpy((char *) var, value, varcharsize);
break;
case ECPGt_varchar:
va_list args;
PGresult *ECPGresult = ECPGresultByDescriptor(lineno, desc_name);
enum ECPGdtype type;
- bool Indicator_seen = false,
- Data_seen = false;
- int ntuples, act_tuple;
+ bool Indicator_seen = false,
+ Data_seen = false;
+ int ntuples,
+ act_tuple;
va_start(args, index);
if (!ECPGresult)
switch (type)
{
case (ECPGd_indicator):
- /* this is like ECPGexecute
- * missing : allocate arrays, perhaps this should go into
- * a common function !!
+
+ /*
+ * this is like ECPGexecute missing : allocate arrays,
+ * perhaps this should go into a common function !!
*/
if (ntuples > arrsize)
- { ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
- lineno, ntuples, arrsize);
+ {
+ ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
+ lineno, ntuples, arrsize);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL);
return false;
}
Indicator_seen = true;
- for (act_tuple = 0; act_tuple < ntuples ; act_tuple++)
- { if (!get_int_item(lineno, var, vartype, -PQgetisnull(ECPGresult, act_tuple, index)))
+ for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
+ {
+ if (!get_int_item(lineno, var, vartype, -PQgetisnull(ECPGresult, act_tuple, index)))
return (false);
- var = (char*)var + offset;
+ var = (char *) var + offset;
ECPGlog("ECPGget_desc: INDICATOR[%d] = %d\n", act_tuple, -PQgetisnull(ECPGresult, act_tuple, index));
}
break;
case ECPGd_ret_length:
case ECPGd_ret_octet:
- /* this is like ECPGexecute
- * missing : allocate arrays, perhaps this should go into
- * a common function !!
+
+ /*
+ * this is like ECPGexecute missing : allocate arrays,
+ * perhaps this should go into a common function !!
*/
if (ntuples > arrsize)
- { ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
- lineno, ntuples, arrsize);
+ {
+ ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
+ lineno, ntuples, arrsize);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL);
return false;
}
- for (act_tuple = 0; act_tuple < ntuples ; act_tuple++)
- { if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, act_tuple, index)))
+ for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
+ {
+ if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, act_tuple, index)))
return (false);
- var = (char*)var + offset;
+ var = (char *) var + offset;
ECPGlog("ECPGget_desc: RETURNED[%d] = %d\n", act_tuple, PQgetlength(ECPGresult, act_tuple, index));
}
break;
ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType_DDT(PQftype(ECPGresult, index)));
break;
case ECPGd_data:
- /* this is like ECPGexecute
- * missing : allocate arrays, perhaps this should go into
- * a common function !!
+
+ /*
+ * this is like ECPGexecute missing : allocate arrays,
+ * perhaps this should go into a common function !!
*/
if (ntuples > arrsize)
- { ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
- lineno, ntuples, arrsize);
+ {
+ ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
+ lineno, ntuples, arrsize);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL);
return false;
}
Data_seen = true;
- for (act_tuple = 0; act_tuple < ntuples ; act_tuple++)
- { if (PQgetisnull(ECPGresult, act_tuple, index))
- continue; /* do not touch data on null value */
- if (!get_data(ECPGresult, act_tuple, index, lineno,
- vartype, ECPGt_NO_INDICATOR, var, NULL,
- varcharsize, offset, false))
+ for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
+ {
+ if (PQgetisnull(ECPGresult, act_tuple, index))
+ continue; /* do not touch data on null value */
+ if (!get_data(ECPGresult, act_tuple, index, lineno,
+ vartype, ECPGt_NO_INDICATOR, var, NULL,
+ varcharsize, offset, false))
return (false);
}
break;
-
+
case ECPGd_cardinality:
if (!get_int_item(lineno, var, vartype, PQntuples(ECPGresult)))
return (false);
}
if (Data_seen && !Indicator_seen)
- {
- for (act_tuple = 0; act_tuple < ntuples ; act_tuple++)
- { if (PQgetisnull(ECPGresult, act_tuple, index))
+ {
+ for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
+ {
+ if (PQgetisnull(ECPGresult, act_tuple, index))
{
ECPGraise(lineno, ECPG_MISSING_INDICATOR, NULL);
return (false);
return true;
}
-PGresult **
+PGresult **
ECPGdescriptor_lvalue(int line, const char *descriptor)
{
struct descriptor *i;
for (i = all_descriptors; i != NULL; i = i->next)
{
- if (!strcmp(descriptor, i->name))
+ if (!strcmp(descriptor, i->name))
return &i->result;
}
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.28 2001/10/05 17:37:07 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.29 2001/10/25 05:50:11 momjian Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
/* variables visible to the programs */
struct sqlca sqlca =
{
- {'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '},
- sizeof(struct sqlca),
- 0,
- {0, {0}},
- {'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '},
- {0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0}
+ {
+ 'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '
+ } ,
+ sizeof(struct sqlca),
+ 0,
+ {
+ 0,
+ {
+ 0
+ }
+ },
+ {
+ 'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '
+ },
+ {
+ 0, 0, 0, 0, 0, 0
+ },
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0
+ },
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0
+ }
};
struct variable
if ((stmt->connection->cache_head) == NULL)
{
-
/*
* Text like types are not an array for ecpg, but postgres counts
* them as an array. This define reminds you to not 'correct'
if (ECPGDynamicType(type) == SQL3_CHARACTER ||
ECPGDynamicType(type) == SQL3_CHARACTER_VARYING)
{
-
/*
* arrays of character strings are not yet implemented
*/
bool
-ECPGstore_result(const PGresult *results, int act_field,
- const struct statement * stmt, struct variable *var)
-{ int isarray,
- act_tuple,
- ntuples = PQntuples(results);
- bool status = true;
-
- isarray = ECPGis_type_an_array(PQftype(results, act_field), stmt, var);
-
- if (!isarray)
- {
+ECPGstore_result(const PGresult *results, int act_field,
+ const struct statement * stmt, struct variable * var)
+{
+ int isarray,
+ act_tuple,
+ ntuples = PQntuples(results);
+ bool status = true;
- /*
- * if we don't have enough space, we cannot read
- * all tuples
- */
- if ((var->arrsize > 0 && ntuples > var->arrsize) || (var->ind_arrsize > 0 && ntuples > var->ind_arrsize))
- {
- ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d don't fit into array of %d\n",
- stmt->lineno, ntuples, var->arrsize);
- ECPGraise(stmt->lineno, ECPG_TOO_MANY_MATCHES, NULL);
- return false;
- }
- }
- else
- {
+ isarray = ECPGis_type_an_array(PQftype(results, act_field), stmt, var);
- /*
- * since we read an array, the variable has to be
- * an array too
- */
- if (var->arrsize == 0)
- {
- ECPGraise(stmt->lineno, ECPG_NO_ARRAY, NULL);
- return false;
- }
- }
+ if (!isarray)
+ {
+ /*
+ * if we don't have enough space, we cannot read all tuples
+ */
+ if ((var->arrsize > 0 && ntuples > var->arrsize) || (var->ind_arrsize > 0 && ntuples > var->ind_arrsize))
+ {
+ ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d don't fit into array of %d\n",
+ stmt->lineno, ntuples, var->arrsize);
+ ECPGraise(stmt->lineno, ECPG_TOO_MANY_MATCHES, NULL);
+ return false;
+ }
+ }
+ else
+ {
+ /*
+ * since we read an array, the variable has to be an array too
+ */
+ if (var->arrsize == 0)
+ {
+ ECPGraise(stmt->lineno, ECPG_NO_ARRAY, NULL);
+ return false;
+ }
+ }
- /*
- * allocate memory for NULL pointers
- */
- if ((var->arrsize == 0 || var->varcharsize == 0) && var->value == NULL)
- {
- int len = 0;
+ /*
+ * allocate memory for NULL pointers
+ */
+ if ((var->arrsize == 0 || var->varcharsize == 0) && var->value == NULL)
+ {
+ int len = 0;
- switch (var->type)
- {
- case ECPGt_char:
- case ECPGt_unsigned_char:
- var->varcharsize = 0;
- /* check strlen for each tuple */
- for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
- {
- int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
-
- if (len > var->varcharsize)
- var->varcharsize = len;
- }
- var->offset *= var->varcharsize;
- len = var->offset * ntuples;
- break;
- case ECPGt_varchar:
- len = ntuples * (var->varcharsize + sizeof(int));
- break;
- default:
- len = var->offset * ntuples;
- break;
- }
- var->value = (void *) ecpg_alloc(len, stmt->lineno);
- *((void **) var->pointer) = var->value;
- add_mem(var->value, stmt->lineno);
- }
+ switch (var->type)
+ {
+ case ECPGt_char:
+ case ECPGt_unsigned_char:
+ var->varcharsize = 0;
+ /* check strlen for each tuple */
+ for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
+ {
+ int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
- for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++)
- {
- if (!get_data(results, act_tuple, act_field, stmt->lineno,
- var->type, var->ind_type, var->value,
- var->ind_value, var->varcharsize, var->offset, isarray))
- status = false;
- }
+ if (len > var->varcharsize)
+ var->varcharsize = len;
+ }
+ var->offset *= var->varcharsize;
+ len = var->offset * ntuples;
+ break;
+ case ECPGt_varchar:
+ len = ntuples * (var->varcharsize + sizeof(int));
+ break;
+ default:
+ len = var->offset * ntuples;
+ break;
+ }
+ var->value = (void *) ecpg_alloc(len, stmt->lineno);
+ *((void **) var->pointer) = var->value;
+ add_mem(var->value, stmt->lineno);
+ }
+
+ for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++)
+ {
+ if (!get_data(results, act_tuple, act_field, stmt->lineno,
+ var->type, var->ind_type, var->value,
+ var->ind_value, var->varcharsize, var->offset, isarray))
+ status = false;
+ }
return status;
}
static bool
-ECPGstore_input(const struct statement * stmt, const struct variable *var,
- const char **tobeinserted_p, bool *malloced_p)
+ECPGstore_input(const struct statement * stmt, const struct variable * var,
+ const char **tobeinserted_p, bool *malloced_p)
{
- char *mallocedval = NULL;
- char *newcopy = NULL;
+ char *mallocedval = NULL;
+ char *newcopy = NULL;
- /*
- * Some special treatment is needed for records since we want
- * their contents to arrive in a comma-separated list on insert (I
- * think).
- */
-
- *malloced_p=false;
- *tobeinserted_p="";
+ /*
+ * Some special treatment is needed for records since we want their
+ * contents to arrive in a comma-separated list on insert (I think).
+ */
- /* check for null value and set input buffer accordingly */
- switch (var->ind_type)
- {
- case ECPGt_short:
- case ECPGt_unsigned_short:
- if (*(short *) var->ind_value < 0)
- *tobeinserted_p="null";
- break;
- case ECPGt_int:
- case ECPGt_unsigned_int:
- if (*(int *) var->ind_value < 0)
- *tobeinserted_p="null";
- break;
- case ECPGt_long:
- case ECPGt_unsigned_long:
- if (*(long *) var->ind_value < 0L)
- *tobeinserted_p="null";
- break;
+ *malloced_p = false;
+ *tobeinserted_p = "";
+
+ /* check for null value and set input buffer accordingly */
+ switch (var->ind_type)
+ {
+ case ECPGt_short:
+ case ECPGt_unsigned_short:
+ if (*(short *) var->ind_value < 0)
+ *tobeinserted_p = "null";
+ break;
+ case ECPGt_int:
+ case ECPGt_unsigned_int:
+ if (*(int *) var->ind_value < 0)
+ *tobeinserted_p = "null";
+ break;
+ case ECPGt_long:
+ case ECPGt_unsigned_long:
+ if (*(long *) var->ind_value < 0L)
+ *tobeinserted_p = "null";
+ break;
#ifdef HAVE_LONG_LONG_INT_64
- case ECPGt_long_long:
- case ECPGt_unsigned_long_long:
- if (*(long long int *) var->ind_value < (long long) 0)
- *tobeinserted_p="null";
- break;
+ case ECPGt_long_long:
+ case ECPGt_unsigned_long_long:
+ if (*(long long int *) var->ind_value < (long long) 0)
+ *tobeinserted_p = "null";
+ break;
#endif /* HAVE_LONG_LONG_INT_64 */
- default:
- break;
- }
+ default:
+ break;
+ }
- if (**tobeinserted_p == '\0')
+ if (**tobeinserted_p == '\0')
+ {
+ switch (var->type)
{
- switch (var->type)
- {
- int element;
+ int element;
- case ECPGt_short:
- if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
- return false;
+ case ECPGt_short:
+ if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+ return false;
- if (var->arrsize > 1)
- {
- strncpy(mallocedval, "'{", sizeof("'{"));
+ if (var->arrsize > 1)
+ {
+ strncpy(mallocedval, "'{", sizeof("'{"));
- for (element = 0; element < var->arrsize; element++)
- sprintf(mallocedval + strlen(mallocedval), "%hd,", ((short *) var->value)[element]);
+ for (element = 0; element < var->arrsize; element++)
+ sprintf(mallocedval + strlen(mallocedval), "%hd,", ((short *) var->value)[element]);
- strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
- }
- else
- sprintf(mallocedval, "%hd", *((short *) var->value));
+ strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
+ }
+ else
+ sprintf(mallocedval, "%hd", *((short *) var->value));
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- break;
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ break;
- case ECPGt_int:
- if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
- return false;
+ case ECPGt_int:
+ if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+ return false;
- if (var->arrsize > 1)
- {
- strncpy(mallocedval, "'{", sizeof("'{"));
+ if (var->arrsize > 1)
+ {
+ strncpy(mallocedval, "'{", sizeof("'{"));
- for (element = 0; element < var->arrsize; element++)
- sprintf(mallocedval + strlen(mallocedval), "%d,", ((int *) var->value)[element]);
+ for (element = 0; element < var->arrsize; element++)
+ sprintf(mallocedval + strlen(mallocedval), "%d,", ((int *) var->value)[element]);
- strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
- }
- else
- sprintf(mallocedval, "%d", *((int *) var->value));
+ strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
+ }
+ else
+ sprintf(mallocedval, "%d", *((int *) var->value));
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- break;
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ break;
- case ECPGt_unsigned_short:
- if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
- return false;
+ case ECPGt_unsigned_short:
+ if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+ return false;
- if (var->arrsize > 1)
- {
- strncpy(mallocedval, "'{", sizeof("'{"));
+ if (var->arrsize > 1)
+ {
+ strncpy(mallocedval, "'{", sizeof("'{"));
- for (element = 0; element < var->arrsize; element++)
- sprintf(mallocedval + strlen(mallocedval), "%hu,", ((unsigned short *) var->value)[element]);
+ for (element = 0; element < var->arrsize; element++)
+ sprintf(mallocedval + strlen(mallocedval), "%hu,", ((unsigned short *) var->value)[element]);
- strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
- }
- else
- sprintf(mallocedval, "%hu", *((unsigned short *) var->value));
+ strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
+ }
+ else
+ sprintf(mallocedval, "%hu", *((unsigned short *) var->value));
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- break;
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ break;
- case ECPGt_unsigned_int:
- if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
- return false;
+ case ECPGt_unsigned_int:
+ if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+ return false;
- if (var->arrsize > 1)
- {
- strncpy(mallocedval, "'{", sizeof("'{"));
+ if (var->arrsize > 1)
+ {
+ strncpy(mallocedval, "'{", sizeof("'{"));
- for (element = 0; element < var->arrsize; element++)
- sprintf(mallocedval + strlen(mallocedval), "%u,", ((unsigned int *) var->value)[element]);
+ for (element = 0; element < var->arrsize; element++)
+ sprintf(mallocedval + strlen(mallocedval), "%u,", ((unsigned int *) var->value)[element]);
- strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
- }
- else
- sprintf(mallocedval, "%u", *((unsigned int *) var->value));
+ strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
+ }
+ else
+ sprintf(mallocedval, "%u", *((unsigned int *) var->value));
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- break;
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ break;
- case ECPGt_long:
- if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
- return false;
+ case ECPGt_long:
+ if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+ return false;
- if (var->arrsize > 1)
- {
- strncpy(mallocedval, "'{", sizeof("'{"));
+ if (var->arrsize > 1)
+ {
+ strncpy(mallocedval, "'{", sizeof("'{"));
- for (element = 0; element < var->arrsize; element++)
- sprintf(mallocedval + strlen(mallocedval), "%ld,", ((long *) var->value)[element]);
+ for (element = 0; element < var->arrsize; element++)
+ sprintf(mallocedval + strlen(mallocedval), "%ld,", ((long *) var->value)[element]);
- strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
- }
- else
- sprintf(mallocedval, "%ld", *((long *) var->value));
+ strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
+ }
+ else
+ sprintf(mallocedval, "%ld", *((long *) var->value));
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- break;
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ break;
- case ECPGt_unsigned_long:
- if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
- return false;
+ case ECPGt_unsigned_long:
+ if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+ return false;
- if (var->arrsize > 1)
- {
- strncpy(mallocedval, "'{", sizeof("'{"));
+ if (var->arrsize > 1)
+ {
+ strncpy(mallocedval, "'{", sizeof("'{"));
- for (element = 0; element < var->arrsize; element++)
- sprintf(mallocedval + strlen(mallocedval), "%lu,", ((unsigned long *) var->value)[element]);
+ for (element = 0; element < var->arrsize; element++)
+ sprintf(mallocedval + strlen(mallocedval), "%lu,", ((unsigned long *) var->value)[element]);
- strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
- }
- else
- sprintf(mallocedval, "%lu", *((unsigned long *) var->value));
+ strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
+ }
+ else
+ sprintf(mallocedval, "%lu", *((unsigned long *) var->value));
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- break;
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ break;
#ifdef HAVE_LONG_LONG_INT_64
- case ECPGt_long_long:
- if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno)))
- return false;
+ case ECPGt_long_long:
+ if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno)))
+ return false;
- if (var->arrsize > 1)
- {
- strncpy(mallocedval, "'{", sizeof("'{"));
+ if (var->arrsize > 1)
+ {
+ strncpy(mallocedval, "'{", sizeof("'{"));
- for (element = 0; element < var->arrsize; element++)
- sprintf(mallocedval + strlen(mallocedval), "%lld,", ((long long *) var->value)[element]);
+ for (element = 0; element < var->arrsize; element++)
+ sprintf(mallocedval + strlen(mallocedval), "%lld,", ((long long *) var->value)[element]);
- strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
- }
- else
- sprintf(mallocedval, "%lld", *((long long *) var->value));
+ strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
+ }
+ else
+ sprintf(mallocedval, "%lld", *((long long *) var->value));
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- break;
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ break;
- case ECPGt_unsigned_long_long:
- if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno)))
- return false;
+ case ECPGt_unsigned_long_long:
+ if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno)))
+ return false;
- if (var->arrsize > 1)
- {
- strncpy(mallocedval, "'{", sizeof("'{"));
+ if (var->arrsize > 1)
+ {
+ strncpy(mallocedval, "'{", sizeof("'{"));
- for (element = 0; element < var->arrsize; element++)
- sprintf(mallocedval + strlen(mallocedval), "%llu,", ((unsigned long long *) var->value)[element]);
+ for (element = 0; element < var->arrsize; element++)
+ sprintf(mallocedval + strlen(mallocedval), "%llu,", ((unsigned long long *) var->value)[element]);
- strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
- }
- else
- sprintf(mallocedval, "%llu", *((unsigned long long *) var->value));
+ strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
+ }
+ else
+ sprintf(mallocedval, "%llu", *((unsigned long long *) var->value));
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- break;
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ break;
#endif /* HAVE_LONG_LONG_INT_64 */
- case ECPGt_float:
- if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
- return false;
+ case ECPGt_float:
+ if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+ return false;
- if (var->arrsize > 1)
- {
- strncpy(mallocedval, "'{", sizeof("'{"));
+ if (var->arrsize > 1)
+ {
+ strncpy(mallocedval, "'{", sizeof("'{"));
- for (element = 0; element < var->arrsize; element++)
- sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((float *) var->value)[element]);
+ for (element = 0; element < var->arrsize; element++)
+ sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((float *) var->value)[element]);
- strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
- }
- else
- sprintf(mallocedval, "%.14g", *((float *) var->value));
+ strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
+ }
+ else
+ sprintf(mallocedval, "%.14g", *((float *) var->value));
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- break;
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ break;
- case ECPGt_double:
- if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
- return false;
+ case ECPGt_double:
+ if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+ return false;
- if (var->arrsize > 1)
- {
- strncpy(mallocedval, "'{", sizeof("'{"));
+ if (var->arrsize > 1)
+ {
+ strncpy(mallocedval, "'{", sizeof("'{"));
- for (element = 0; element < var->arrsize; element++)
- sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((double *) var->value)[element]);
+ for (element = 0; element < var->arrsize; element++)
+ sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((double *) var->value)[element]);
- strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
- }
- else
- sprintf(mallocedval, "%.14g", *((double *) var->value));
+ strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
+ }
+ else
+ sprintf(mallocedval, "%.14g", *((double *) var->value));
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- break;
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ break;
- case ECPGt_bool:
- if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
- return false;
+ case ECPGt_bool:
+ if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+ return false;
- if (var->arrsize > 1)
- {
- strncpy(mallocedval, "'{", sizeof("'{"));
-
- if (var->offset == sizeof(char))
- for (element = 0; element < var->arrsize; element++)
- sprintf(mallocedval + strlen(mallocedval), "%c,", (((char *) var->value)[element]) ? 't' : 'f');
-
- /*
- * this is necessary since sizeof(C++'s
- * bool)==sizeof(int)
- */
- else if (var->offset == sizeof(int))
- for (element = 0; element < var->arrsize; element++)
- sprintf(mallocedval + strlen(mallocedval), "%c,", (((int *) var->value)[element]) ? 't' : 'f');
- else
- ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size");
-
- strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
- }
+ if (var->arrsize > 1)
+ {
+ strncpy(mallocedval, "'{", sizeof("'{"));
+
+ if (var->offset == sizeof(char))
+ for (element = 0; element < var->arrsize; element++)
+ sprintf(mallocedval + strlen(mallocedval), "%c,", (((char *) var->value)[element]) ? 't' : 'f');
+
+ /*
+ * this is necessary since sizeof(C++'s
+ * bool)==sizeof(int)
+ */
+ else if (var->offset == sizeof(int))
+ for (element = 0; element < var->arrsize; element++)
+ sprintf(mallocedval + strlen(mallocedval), "%c,", (((int *) var->value)[element]) ? 't' : 'f');
else
- {
- if (var->offset == sizeof(char))
- sprintf(mallocedval, "'%c'", (*((char *) var->value)) ? 't' : 'f');
- else if (var->offset == sizeof(int))
- sprintf(mallocedval, "'%c'", (*((int *) var->value)) ? 't' : 'f');
- else
- ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size");
- }
+ ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size");
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- break;
+ strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
+ }
+ else
+ {
+ if (var->offset == sizeof(char))
+ sprintf(mallocedval, "'%c'", (*((char *) var->value)) ? 't' : 'f');
+ else if (var->offset == sizeof(int))
+ sprintf(mallocedval, "'%c'", (*((int *) var->value)) ? 't' : 'f');
+ else
+ ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size");
+ }
- case ECPGt_char:
- case ECPGt_unsigned_char:
- {
- /* set slen to string length if type is char * */
- int slen = (var->varcharsize == 0) ? strlen((char *) var->value) : var->varcharsize;
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ break;
+
+ case ECPGt_char:
+ case ECPGt_unsigned_char:
+ {
+ /* set slen to string length if type is char * */
+ int slen = (var->varcharsize == 0) ? strlen((char *) var->value) : var->varcharsize;
- if (!(newcopy = ecpg_alloc(slen + 1, stmt->lineno)))
- return false;
+ if (!(newcopy = ecpg_alloc(slen + 1, stmt->lineno)))
+ return false;
- strncpy(newcopy, (char *) var->value, slen);
- newcopy[slen] = '\0';
+ strncpy(newcopy, (char *) var->value, slen);
+ newcopy[slen] = '\0';
- mallocedval = quote_postgres(newcopy, stmt->lineno);
- if (!mallocedval)
- return false;
+ mallocedval = quote_postgres(newcopy, stmt->lineno);
+ if (!mallocedval)
+ return false;
- free(newcopy);
+ free(newcopy);
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- }
- break;
- case ECPGt_char_variable:
- {
- int slen = strlen((char *) var->value);
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ }
+ break;
+ case ECPGt_char_variable:
+ {
+ int slen = strlen((char *) var->value);
- if (!(mallocedval = ecpg_alloc(slen + 1, stmt->lineno)))
- return false;
+ if (!(mallocedval = ecpg_alloc(slen + 1, stmt->lineno)))
+ return false;
- strncpy(mallocedval, (char *) var->value, slen);
- mallocedval[slen] = '\0';
+ strncpy(mallocedval, (char *) var->value, slen);
+ mallocedval[slen] = '\0';
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- }
- break;
- case ECPGt_varchar:
- {
- struct ECPGgeneric_varchar *variable =
- (struct ECPGgeneric_varchar *) (var->value);
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ }
+ break;
+ case ECPGt_varchar:
+ {
+ struct ECPGgeneric_varchar *variable =
+ (struct ECPGgeneric_varchar *) (var->value);
- if (!(newcopy = (char *) ecpg_alloc(variable->len + 1, stmt->lineno)))
- return false;
+ if (!(newcopy = (char *) ecpg_alloc(variable->len + 1, stmt->lineno)))
+ return false;
- strncpy(newcopy, variable->arr, variable->len);
- newcopy[variable->len] = '\0';
+ strncpy(newcopy, variable->arr, variable->len);
+ newcopy[variable->len] = '\0';
- mallocedval = quote_postgres(newcopy, stmt->lineno);
- if (!mallocedval)
- return false;
+ mallocedval = quote_postgres(newcopy, stmt->lineno);
+ if (!mallocedval)
+ return false;
- free(newcopy);
+ free(newcopy);
- *tobeinserted_p = mallocedval;
- *malloced_p = true;
- }
- break;
+ *tobeinserted_p = mallocedval;
+ *malloced_p = true;
+ }
+ break;
- default:
- /* Not implemented yet */
- ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, (char *) ECPGtype_name(var->type));
- return false;
- break;
- }
+ default:
+ /* Not implemented yet */
+ ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, (char *) ECPGtype_name(var->type));
+ return false;
+ break;
}
+ }
return true;
}
var = stmt->inlist;
while (var)
{
- char *newcopy = NULL;
+ char *newcopy = NULL;
const char *tobeinserted = NULL;
char *p;
- bool malloced=FALSE;
- int hostvarl = 0;
+ bool malloced = FALSE;
+ int hostvarl = 0;
if (!ECPGstore_input(stmt, var, &tobeinserted, &malloced))
return false;
-
+
/*
* Now tobeinserted points to an area that is to be inserted at
* the first %s
strcpy(newcopy, copiedquery);
if ((p = next_insert(newcopy + hostvarl)) == NULL)
{
-
/*
* We have an argument but we dont have the matched up string
* in the string
*/
if (malloced)
{
- free((char*)tobeinserted);
+ free((char *) tobeinserted);
tobeinserted = NULL;
}
ECPGraise(stmt->lineno, ECPG_PGSQL, PQerrorMessage(stmt->connection->connection));
}
else
- /* note: since some of the following code is duplicated in descriptor.c
- * it should go into a separate function
- */
+
+ /*
+ * note: since some of the following code is duplicated in
+ * descriptor.c it should go into a separate function
+ */
{
- bool clear_result = TRUE;
+ bool clear_result = TRUE;
+
var = stmt->outlist;
switch (PQresultStatus(results))
{
if (ntuples < 1)
{
- if (ntuples) ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n",
- stmt->lineno, ntuples);
+ if (ntuples)
+ ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n",
+ stmt->lineno, ntuples);
ECPGraise(stmt->lineno, ECPG_NOT_FOUND, NULL);
status = false;
break;
}
- if (var != NULL && var->type==ECPGt_descriptor)
- { PGresult **resultpp = ECPGdescriptor_lvalue(stmt->lineno, (const char*)var->pointer);
- if (resultpp == NULL) status = false;
+ if (var != NULL && var->type == ECPGt_descriptor)
+ {
+ PGresult **resultpp = ECPGdescriptor_lvalue(stmt->lineno, (const char *) var->pointer);
+
+ if (resultpp == NULL)
+ status = false;
else
- { if (*resultpp)
- PQclear(*resultpp);
- *resultpp=results;
+ {
+ if (*resultpp)
+ PQclear(*resultpp);
+ *resultpp = results;
clear_result = FALSE;
- ECPGlog("ECPGexecute putting result (%d tuples) into descriptor '%s'\n", PQntuples(results), (const char*)var->pointer);
+ ECPGlog("ECPGexecute putting result (%d tuples) into descriptor '%s'\n", PQntuples(results), (const char *) var->pointer);
}
var = var->next;
}
- else for (act_field = 0; act_field < nfields && status; act_field++)
- {
- if (var == NULL)
+ else
+ for (act_field = 0; act_field < nfields && status; act_field++)
{
- ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, NULL);
- return (false);
- }
-
- status = ECPGstore_result(results, act_field, stmt, var);
+ if (var == NULL)
+ {
+ ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, NULL);
+ return (false);
+ }
- var = var->next;
- }
+ status = ECPGstore_result(results, act_field, stmt, var);
+
+ var = var->next;
+ }
if (status && var != NULL)
{
status = false;
break;
}
- if (clear_result) PQclear(results);
+ if (clear_result)
+ PQclear(results);
}
/* check for asynchronous returns */
struct statement *stmt;
struct connection *con = get_connection(connection_name);
bool status;
- char *oldlocale;
+ char *oldlocale;
/* Make sure we do NOT honor the locale for numeric input/output */
/* since the database wants the standard decimal point */
return (status);
}
-/* old descriptor interface */
+/* old descriptor interface */
bool
ECPGdo_descriptor(int line, const char *connection,
const char *descriptor, const char *query)
{
- return ECPGdo(line, connection, (char *)query, ECPGt_EOIT,
- ECPGt_descriptor, descriptor, 0L, 0L, 0L,
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ return ECPGdo(line, connection, (char *) query, ECPGt_EOIT,
+ ECPGt_descriptor, descriptor, 0L, 0L, 0L,
+ ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
}
struct descriptor *next;
};
-PGresult **
-ECPGdescriptor_lvalue(int line, const char *descriptor);
+PGresult **
+ ECPGdescriptor_lvalue(int line, const char *descriptor);
-bool
-ECPGstore_result(const PGresult *results, int act_field,
- const struct statement * stmt, struct variable *var);
+bool ECPGstore_result(const PGresult *results, int act_field,
+ const struct statement * stmt, struct variable * var);
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.6 2001/10/05 17:37:07 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.7 2001/10/25 05:50:12 momjian Exp $ */
#include "postgres_fe.h"
static struct sqlca sqlca_init =
{
- {'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '},
- sizeof(struct sqlca),
- 0,
- {0, {0}},
- {'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '},
- {0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0}
+ {
+ 'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '
+ } ,
+ sizeof(struct sqlca),
+ 0,
+ {
+ 0,
+ {
+ 0
+ }
+ },
+ {
+ 'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '
+ },
+ {
+ 0, 0, 0, 0, 0, 0
+ },
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0
+ },
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0
+ }
};
static int simple_debug = 0;
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_type.h,v 1.2 2001/01/24 19:43:29 momjian Exp $
+ * $Id: pg_type.h,v 1.3 2001/10/25 05:50:12 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
#define ZPBITOID 1560
#define VARBITOID 1562
#define NUMERICOID 1700
-
#endif /* PG_TYPE_H */
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/typename.c,v 1.19 2001/09/19 14:09:32 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/typename.c,v 1.20 2001/10/25 05:50:12 momjian Exp $ */
#include "postgres_fe.h"
{
switch (typ)
{
- case ECPGt_char:
+ case ECPGt_char:
return "char";
case ECPGt_unsigned_char:
return "unsigned char";
{
switch (type)
{
- case BOOLOID:return SQL3_BOOLEAN; /* bool */
+ case BOOLOID:
+ return SQL3_BOOLEAN; /* bool */
case INT2OID:
return SQL3_SMALLINT; /* int2 */
case INT4OID:
- return SQL3_INTEGER;/* int4 */
+ return SQL3_INTEGER; /* int4 */
case TEXTOID:
return SQL3_CHARACTER; /* text */
case FLOAT4OID:
case TIMESTAMPOID:
return SQL3_DATE_TIME_TIMESTAMP; /* datetime */
case NUMERICOID:
- return SQL3_NUMERIC;/* numeric */
+ return SQL3_NUMERIC; /* numeric */
default:
return -type;
}
add_descriptor(char *name, char *connection)
{
struct descriptor *new;
-
- if (name[0]!='"') return;
-
+
+ if (name[0] != '"')
+ return;
+
new = (struct descriptor *) mm_alloc(sizeof(struct descriptor));
new->next = descriptors;
struct descriptor *i;
struct descriptor **lastptr = &descriptors;
- if (name[0]!='"') return;
+ if (name[0] != '"')
+ return;
for (i = descriptors; i; lastptr = &i->next, i = i->next)
{
{
struct descriptor *i;
- if (name[0]!='"') return NULL;
+ if (name[0] != '"')
+ return NULL;
for (i = descriptors; i; i = i->next)
{
/* I consider dynamic allocation overkill since at most two descriptor
variables are possible per statement. (input and output descriptor)
- And descriptors are no normal variables, so they don't belong into
+ And descriptors are no normal variables, so they don't belong into
the variable list.
*/
-
+
#define MAX_DESCRIPTOR_NAMELEN 128
-struct variable *descriptor_variable(const char *name,int input)
-{ static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
+struct variable *
+descriptor_variable(const char *name, int input)
+{
+ static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
static const struct ECPGtype descriptor_type =
- { ECPGt_descriptor, 0 };
+ {ECPGt_descriptor, 0};
static const struct variable varspace[2] =
- {{ descriptor_names[0], (struct ECPGtype*)&descriptor_type, 0, NULL },
- { descriptor_names[1], (struct ECPGtype*)&descriptor_type, 0, NULL }
+ {{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
+ {descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
};
-
- strncpy(descriptor_names[input],name,MAX_DESCRIPTOR_NAMELEN);
- descriptor_names[input][MAX_DESCRIPTOR_NAMELEN-1]=0;
- return (struct variable*)&varspace[input];
+
+ strncpy(descriptor_names[input], name, MAX_DESCRIPTOR_NAMELEN);
+ descriptor_names[input][MAX_DESCRIPTOR_NAMELEN - 1] = 0;
+ return (struct variable *) & varspace[input];
}
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.49 2001/09/19 14:09:32 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.50 2001/10/25 05:50:12 momjian Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes Feb 5th, 1998 */
/* printf is a macro some places; don't #ifdef inside its arguments */
#ifdef YYDEBUG
printf("Usage:\n"
- " %s [-d] [-I DIRECTORY] [-o OUTFILE] [-t] file1 [file2...]\n\n",
+ " %s [-d] [-I DIRECTORY] [-o OUTFILE] [-t] file1 [file2...]\n\n",
progname);
#else
printf("Usage:\n"
printf(" -o OUTFILE write result to OUTFILE\n");
printf(" -t turn on autocommit of transactions\n");
printf("\nIf no output file is specified, the name is formed by adding .c\n"
- "to the input file name, after stripping off .pgc if present.\n");
+ "to the input file name, after stripping off .pgc if present.\n");
printf("\nReport bugs to
.\n");
}
if (argc > 1)
{
- if (strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-?")==0)
+ if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
{
help(progname);
exit(0);
}
- else if (strcmp(argv[1], "--version")==0)
+ else if (strcmp(argv[1], "--version") == 0)
{
printf("ecpg (PostgreSQL %s) %d.%d.%d\n", PG_VERSION,
MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
#ifdef YYDEBUG
extern int yydebug;
-
#endif
extern int yylineno,
yyleng;
extern void add_descriptor(char *, char *);
extern void drop_descriptor(char *, char *);
extern struct descriptor *lookup_descriptor(char *, char *);
-extern struct variable *descriptor_variable(const char *name,int input);
+extern struct variable *descriptor_variable(const char *name, int input);
extern void add_variable(struct arguments **, struct variable *, struct variable *);
extern void append_variable(struct arguments **, struct variable *, struct variable *);
extern void dump_variables(struct arguments *, int);
{
switch (w->code)
{
- case W_SQLPRINT:fprintf(yyout, "sqlprint();");
+ case W_SQLPRINT:
+ fprintf(yyout, "sqlprint();");
break;
case W_GOTO:
fprintf(yyout, "goto %s;", w->command);
{
switch (typ)
{
- case ECPGt_char:
+ case ECPGt_char:
return ("ECPGt_char");
break;
case ECPGt_unsigned_char:
switch (typ->typ)
{
- case ECPGt_array:
+ case ECPGt_array:
switch (typ->u.element->typ)
{
- case ECPGt_array:
+ case ECPGt_array:
yyerror("No nested arrays allowed (except strings)"); /* array of array */
break;
case ECPGt_struct:
static void
ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz, struct ECPGtype * typ, struct ECPGtype * ind_typ, const char *offsetarg, const char *prefix, const char *ind_prefix)
{
-
/*
* If offset is NULL, then this is the first recursive level. If not
* then we are in a struct in a struct and the offset is used as
{
switch (typ->typ)
{
- case ECPGt_array:
+ case ECPGt_array:
switch (typ->u.element->typ)
{
- case ECPGt_array:
+ case ECPGt_array:
yyerror("internal error, found multi-dimensional array\n");
break;
case ECPGt_struct:
{
switch (typ)
{
- case ECPGd_count:
+ case ECPGd_count:
return ("ECPGd_countr");
break;
case ECPGd_data:
/* some stuff for whenever statements */
enum WHEN_TYPE
{
- W_NOTHING,
- W_CONTINUE,
- W_BREAK,
- W_SQLPRINT,
- W_GOTO,
- W_DO,
- W_STOP
+ W_NOTHING,
+ W_CONTINUE,
+ W_BREAK,
+ W_SQLPRINT,
+ W_GOTO,
+ W_DO,
+ W_STOP
};
struct when
enum errortype
{
- ET_NOTICE, ET_ERROR, ET_FATAL
+ ET_NOTICE, ET_ERROR, ET_FATAL
};
struct fetch_desc
** doquery - returns PGresult structure
**
*/
-PGresult *
+PGresult *
doquery(char *query)
{
if (res != NULL &&
** get_result
**
*/
-PGresult *
+PGresult *
get_result()
{
char *cmdstatus = PQcmdStatus(res);
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpgtcl.h,v 1.11 2001/01/24 19:43:29 momjian Exp $
+ * $Id: libpgtcl.h,v 1.12 2001/10/25 05:50:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int Pgtcl_Init(Tcl_Interp *interp);
extern int Pgtcl_SafeInit(Tcl_Interp *interp);
-
#endif /* LIBPGTCL_H */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.23 2001/09/17 00:42:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.24 2001/10/25 05:50:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int
Pgtcl_Init(Tcl_Interp *interp)
{
- double tclversion;
+ double tclversion;
/*
* finish off the ChannelType struct. Much easier to do it here then
#endif
/*
- * Tcl versions >= 8.1 use UTF-8 for their internal string representation.
- * Therefore PGCLIENTENCODING must be set to UNICODE for these versions.
+ * Tcl versions >= 8.1 use UTF-8 for their internal string
+ * representation. Therefore PGCLIENTENCODING must be set to UNICODE
+ * for these versions.
*/
Tcl_GetDouble(interp, Tcl_GetVar(interp, "tcl_version", TCL_GLOBAL_ONLY), &tclversion);
if (tclversion >= 8.1)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.57 2001/09/06 02:54:56 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.58 2001/10/25 05:50:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
if (*p == '\\')
{
-
/*
* escape sequence, translate it
*/
#endif
return value;
}
-
#endif /* TCL_ARRAYS */
if (!strcmp("-conninfo", argv[1]))
{
-
/*
* Establish a connection using the new PQconnectdb() interface
*/
}
else
{
-
/*
* Establish a connection using the old PQsetdb() interface
*/
#else
PQgetvalue(result, tupno, 0);
-
#endif
char *workspace = malloc(strlen(field0) + strlen(appendstr) + 210);
if (strcmp(argv[i], "-array") == 0)
{
-
/*
* The rows should appear in an array vs. to single variables
*/
if (strcmp(argv[i], "-oid") == 0)
{
-
/*
* We should place PQoidValue() somewhere
*/
*/
if (i == argc)
{
-
/*
* We don't have a loop body. If we have at least one result row,
* we set all the variables to the first one and return.
return TCL_OK;
}
-
#endif
/***********************************
sprintf(interp->result, "%d", nbytes);
return TCL_OK;
}
-
#endif
/***********************************
if (callback)
{
-
/*
* Create or update a callback for a relation
*/
}
else
{
-
/*
* Remove a callback for a relation
*/
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pgtclCmds.h,v 1.22 2001/09/06 02:54:56 momjian Exp $
+ * $Id: pgtclCmds.h,v 1.23 2001/10/25 05:50:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int res_copyStatus; /* Copying status */
PGresult **results; /* The results */
- Pg_TclNotifies *notify_list;/* head of list of notify info */
+ Pg_TclNotifies *notify_list; /* head of list of notify info */
int notifier_running; /* notify event source is live */
#if TCL_MAJOR_VERSION >= 8
- Tcl_Channel notifier_channel;/* Tcl_Channel on which notifier is listening */
+ Tcl_Channel notifier_channel; /* Tcl_Channel on which notifier
+ * is listening */
#else
- int notifier_socket;/* PQsocket on which notifier is listening */
+ int notifier_socket; /* PQsocket on which notifier is listening */
#endif
} Pg_ConnectionId;
ClientData cData, Tcl_Interp *interp, int argc, char *argv[]);
extern int Pg_lo_write(
ClientData cData, Tcl_Interp *interp, int argc, char *argv[]);
-
#endif
extern int Pg_lo_lseek(
ClientData cData, Tcl_Interp *interp, int argc, char *argv[]);
ClientData cData, Tcl_Interp *interp, int argc, char *argv[]);
extern int Pg_listen(
ClientData cData, Tcl_Interp *interp, int argc, char *argv[]);
-
#endif /* PGTCLCMDS_H */
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.27 2001/09/07 21:55:00 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.28 2001/10/25 05:50:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
return (Tcl_File) NULL;
}
-
#endif
/*
}
static int
PgGetHandleProc(ClientData instanceData, int direction,
- ClientData *handlePtr)
+ ClientData *handlePtr)
{
return TCL_ERROR;
}
NULL, /* GetOptionProc, Not used */
PgWatchProc, /* WatchProc, must be defined */
PgGetHandleProc, /* GetHandleProc, must be defined */
- NULL /* Close2Proc, Not used */
+ NULL /* Close2Proc, Not used */
};
/*
/*
* Get back the result pointer from the Id
*/
-PGresult *
+PGresult *
PgGetResultId(Tcl_Interp *interp, char *id)
{
Pg_ConnectionId *connid;
{
#if TCL_MAJOR_VERSION >= 8
Tcl_CreateChannelHandler(connid->notifier_channel, TCL_READABLE,
- Pg_Notify_FileHandler, (ClientData) connid);
+ Pg_Notify_FileHandler, (ClientData) connid);
#else
/* In Tcl 7.5 and 7.6, we need to gin up a Tcl_File. */
Tcl_File tclfile = Tcl_GetFile((ClientData) pqsock, TCL_UNIX_FD);
{
#if TCL_MAJOR_VERSION >= 8
Tcl_DeleteChannelHandler(connid->notifier_channel,
- Pg_Notify_FileHandler, (ClientData) connid);
+ Pg_Notify_FileHandler, (ClientData) connid);
#else
/* In Tcl 7.5 and 7.6, we need to gin up a Tcl_File. */
Tcl_File tclfile = Tcl_GetFile((ClientData) connid->notifier_socket,
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pgtclId.h,v 1.16 2001/01/24 19:43:29 momjian Exp $
+ * $Id: pgtclId.h,v 1.17 2001/10/25 05:50:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#if HAVE_TCL_GETFILEPROC
extern Tcl_File PgGetFileProc(ClientData cData, int direction);
-
#endif
extern Tcl_ChannelType Pg_ConnType;
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.61 2001/09/26 19:54:12 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.62 2001/10/25 05:50:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
return STATUS_OK;
}
-
#endif /* KRB4 */
#ifdef KRB5
if (retval == KRB5_SENDAUTH_REJECTED && err_ret)
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("Kerberos 5 authentication rejected: %*s\n"),
+ libpq_gettext("Kerberos 5 authentication rejected: %*s\n"),
err_ret->text.length, err_ret->text.data);
}
else
return ret;
}
-
#endif /* KRB5 */
static int
pg_local_sendauth(char *PQerrormsg, PGconn *conn)
{
#if defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS))
- char buf;
+ char buf;
struct iovec iov;
struct msghdr msg;
+
#ifdef HAVE_STRUCT_CMSGCRED
/* Prevent padding */
- char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct cmsgcred)];
+ char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct cmsgcred)];
+
/* Point to start of first structure */
- struct cmsghdr *cmsg = (struct cmsghdr *)cmsgmem;
+ struct cmsghdr *cmsg = (struct cmsghdr *) cmsgmem;
#endif
#ifdef HAVE_STRUCT_SOCKCRED
/* Prevent padding */
- char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct sockcred)];
+ char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct sockcred)];
+
/* Point to start of first structure */
- struct cmsghdr *cmsg = (struct cmsghdr *)cmsgmem;
+ struct cmsghdr *cmsg = (struct cmsghdr *) cmsgmem;
#endif
/*
- * The backend doesn't care what we send here, but it wants
- * exactly one character to force recvmsg() to block and wait
- * for us.
+ * The backend doesn't care what we send here, but it wants exactly
+ * one character to force recvmsg() to block and wait for us.
*/
buf = '\0';
iov.iov_base = &buf;
if (sendmsg(conn->sock, &msg, 0) == -1)
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pg_local_sendauth: sendmsg: %s\n", strerror(errno));
+ "pg_local_sendauth: sendmsg: %s\n", strerror(errno));
return STATUS_ERROR;
}
return STATUS_OK;
#else
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("SCM_CRED authentication method not supported\n"));
+ libpq_gettext("SCM_CRED authentication method not supported\n"));
return STATUS_ERROR;
#endif
}
static int
pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
{
- int ret;
- char *crypt_pwd;
+ int ret;
+ char *crypt_pwd;
/* Encrypt the password if needed. */
switch (areq)
{
case AUTH_REQ_MD5:
- {
- char *crypt_pwd2;
-
- if (!(crypt_pwd = malloc(MD5_PASSWD_LEN+1)) ||
- !(crypt_pwd2 = malloc(MD5_PASSWD_LEN+1)))
- {
- perror("malloc");
- return STATUS_ERROR;
- }
- if (!EncryptMD5(password, conn->pguser,
- strlen(conn->pguser), crypt_pwd2))
{
- free(crypt_pwd);
+ char *crypt_pwd2;
+
+ if (!(crypt_pwd = malloc(MD5_PASSWD_LEN + 1)) ||
+ !(crypt_pwd2 = malloc(MD5_PASSWD_LEN + 1)))
+ {
+ perror("malloc");
+ return STATUS_ERROR;
+ }
+ if (!EncryptMD5(password, conn->pguser,
+ strlen(conn->pguser), crypt_pwd2))
+ {
+ free(crypt_pwd);
+ free(crypt_pwd2);
+ return STATUS_ERROR;
+ }
+ if (!EncryptMD5(crypt_pwd2 + strlen("md5"), conn->md5Salt,
+ sizeof(conn->md5Salt), crypt_pwd))
+ {
+ free(crypt_pwd);
+ free(crypt_pwd2);
+ return STATUS_ERROR;
+ }
free(crypt_pwd2);
- return STATUS_ERROR;
+ break;
}
- if (!EncryptMD5(crypt_pwd2 + strlen("md5"), conn->md5Salt,
- sizeof(conn->md5Salt), crypt_pwd))
- {
- free(crypt_pwd);
- free(crypt_pwd2);
- return STATUS_ERROR;
- }
- free(crypt_pwd2);
- break;
- }
case AUTH_REQ_CRYPT:
- {
- char salt[3];
+ {
+ char salt[3];
- StrNCpy(salt, conn->cryptSalt,3);
- crypt_pwd = crypt(password, salt);
- break;
- }
+ StrNCpy(salt, conn->cryptSalt, 3);
+ crypt_pwd = crypt(password, salt);
+ break;
+ }
case AUTH_REQ_PASSWORD:
/* discard const so we can assign it */
- crypt_pwd = (char *)password;
+ crypt_pwd = (char *) password;
break;
default:
return STATUS_ERROR;
hostname) != STATUS_OK)
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("Kerberos 4 authentication failed\n"));
+ libpq_gettext("Kerberos 4 authentication failed\n"));
return STATUS_ERROR;
}
break;
#else
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("Kerberos 4 authentication not supported\n"));
+ libpq_gettext("Kerberos 4 authentication not supported\n"));
return STATUS_ERROR;
#endif
hostname) != STATUS_OK)
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("Kerberos 5 authentication failed\n"));
+ libpq_gettext("Kerberos 5 authentication failed\n"));
return STATUS_ERROR;
}
break;
#else
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("Kerberos 5 authentication not supported\n"));
+ libpq_gettext("Kerberos 5 authentication not supported\n"));
return STATUS_ERROR;
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: fe-auth.h,v 1.12 2001/01/24 19:43:30 momjian Exp $
+ * $Id: fe-auth.h,v 1.13 2001/10/25 05:50:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define PG_KRB4_VERSION "PGVER4.1" /* at most KRB_SENDAUTH_VLEN chars */
#define PG_KRB5_VERSION "PGVER5.1"
-
#endif /* FE_AUTH_H */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.177 2001/09/06 04:57:30 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.178 2001/10/25 05:50:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
inp->s_addr = a;
return 1;
}
-
#endif
#ifdef USE_SSL
static SSL_CTX *SSL_context = NULL;
-
#endif
#define NOTIFYLIST_INITIAL_SIZE 10
* ----------
*/
static const PQconninfoOption PQconninfoOptions[] = {
-
/*
* "authtype" is no longer used, so mark it "don't show". We keep it
* in the array so as not to reject conninfo strings from old apps
PQExpBuffer errorMessage);
-/*
+/*
* Connecting to a Database
*
* There are now four different ways a user of this API can connect to the
/*-------
* new style:
- * :postgresql://server[:port|:/unixsocket/path:]
+ * :postgresql://server[:port|:/unixsocket/path:]
* [/db name][?options]
*-------
*/
}
else
{
-
/*
* Why do we default only this value from the environment
* again?
return 0;
}
-
#endif /* NOT_USED */
#if defined(WIN32)
if (ioctlsocket(conn->sock, FIONBIO, &on) != 0)
#elif defined(__BEOS__)
- if (ioctl(conn->sock, FIONBIO, &on) != 0)
+ if (ioctl(conn->sock, FIONBIO, &on) != 0)
#else
if (fcntl(conn->sock, F_SETFL, O_NONBLOCK) < 0)
#endif
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not set socket to non-blocking mode: %s\n"),
+ libpq_gettext("could not set socket to non-blocking mode: %s\n"),
SOCK_STRERROR(SOCK_ERRNO));
return 0;
}
sizeof(on)) < 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not set socket to TCP no delay mode: %s\n"),
+ libpq_gettext("could not set socket to TCP no delay mode: %s\n"),
SOCK_STRERROR(SOCK_ERRNO));
return 0;
}
if (conn->raddr.sa.sa_family == AF_UNIX)
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "could not connect to server: %s\n"
- "\tIs the server running locally and accepting\n"
- "\tconnections on Unix domain socket \"%s\"?\n"
- ),
+ "could not connect to server: %s\n"
+ "\tIs the server running locally and accepting\n"
+ "\tconnections on Unix domain socket \"%s\"?\n"
+ ),
SOCK_STRERROR(errorno),
conn->raddr.un.sun_path);
else
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "could not connect to server: %s\n"
- "\tIs the server running on host %s and accepting\n"
- "\tTCP/IP connections on port %s?\n"
- ),
+ "could not connect to server: %s\n"
+ "\tIs the server running on host %s and accepting\n"
+ "\tTCP/IP connections on port %s?\n"
+ ),
SOCK_STRERROR(errorno),
conn->pghost
? conn->pghost
#ifdef USE_SSL
StartupPacket np; /* Used to negotiate SSL connection */
char SSLok;
-
#endif
if (!conn)
if (pqPacketSend(conn, (char *) &np, sizeof(StartupPacket)) != STATUS_OK)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not send SSL negotiation packet: %s\n"),
+ libpq_gettext("could not send SSL negotiation packet: %s\n"),
SOCK_STRERROR(SOCK_ERRNO));
goto connect_errReturn;
}
if (!SSL_context)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not create SSL context: %s\n"),
- ERR_reason_error_string(ERR_get_error()));
+ libpq_gettext("could not create SSL context: %s\n"),
+ ERR_reason_error_string(ERR_get_error()));
goto connect_errReturn;
}
}
SSL_connect(conn->ssl) <= 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not establish SSL connection: %s\n"),
- ERR_reason_error_string(ERR_get_error()));
+ libpq_gettext("could not establish SSL connection: %s\n"),
+ ERR_reason_error_string(ERR_get_error()));
goto connect_errReturn;
}
/* SSL connection finished. Continue to send startup packet */
for (;;)
{
-
/*
* Wait, if necessary. Note that the initial state (just after
* PQconnectStart) is to wait for the socket to select for
/* Get the new data */
switch (conn->status)
{
-
/*
* We really shouldn't have been polled in these two cases,
* but we can handle it.
default:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "invalid connection state, "
- "probably indicative of memory corruption\n"
- ));
+ "invalid connection state, "
+ "probably indicative of memory corruption\n"
+ ));
goto error_return;
}
sizeof(StartupPacket)) != STATUS_OK)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not send startup packet: %s\n"),
+ libpq_gettext("could not send startup packet: %s\n"),
SOCK_STRERROR(SOCK_ERRNO));
goto error_return;
}
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "expected authentication request from "
- "server, but received %c\n"
- ),
+ "expected authentication request from "
+ "server, but received %c\n"
+ ),
beresp);
goto error_return;
}
case CONNECTION_AUTH_OK:
{
-
/*
* Now we expect to hear from the backend. A ReadyForQuery
* message indicates that startup is successful, but we
default:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "invalid connection state %c, "
- "probably indicative of memory corruption\n"
- ),
+ "invalid connection state %c, "
+ "probably indicative of memory corruption\n"
+ ),
conn->status);
goto error_return;
}
#ifdef MULTIBYTE
static const char envname[] = "PGCLIENTENCODING";
-
#endif
if (conn == NULL || conn->status == CONNECTION_BAD)
default:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "invalid setenv state %c, "
- "probably indicative of memory corruption\n"
- ),
+ "invalid setenv state %c, "
+ "probably indicative of memory corruption\n"
+ ),
conn->setenv_state);
goto error_return;
}
env = getenv(envname);
if (!env || *env == '\0')
{
-
/*
* query server encoding if PGCLIENTENCODING is not
* specified
default:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("invalid state %c, "
- "probably indicative of memory corruption\n"),
+ "probably indicative of memory corruption\n"),
conn->setenv_state);
goto error_return;
}
for (;;)
{
-
/*
* Wait, if necessary. Note that the initial state (just after
* PQsetenvStart) is to wait for the socket to select for writing.
flag = PQsetenvPoll(conn);
}
}
-
#endif /* NOT_USED */
static void
closePGconn(PGconn *conn)
{
- /* Note that the protocol doesn't allow us to send Terminate
- messages during the startup phase. */
+ /*
+ * Note that the protocol doesn't allow us to send Terminate messages
+ * during the startup phase.
+ */
if (conn->sock >= 0 && conn->status == CONNECTION_OK)
{
-
/*
* Try to send "close connection" message to backend. Ignore any
* error. Note: this routine used to go to substantial lengths to
{
if (group_found)
{
-
/*
* Finally, we are in the right group and can parse
* the line
if (option->keyword == NULL)
{
printfPQExpBuffer(errorMessage,
- libpq_gettext("invalid connection option \"%s\"\n"),
+ libpq_gettext("invalid connection option \"%s\"\n"),
pname);
PQconninfoFree(options);
free(buf);
return (status);
}
-#else /* without multibytle support */
+#else /* without multibytle support */
int
PQsetClientEncoding(PGconn *conn, const char *encoding)
{
return -1;
}
-
#endif
#ifdef USE_SSL
return NULL;
return conn->ssl;
}
-
#endif
void
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.112 2001/09/14 17:46:40 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.113 2001/10/25 05:50:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
size_t
-PQescapeString (char *to, const char *from, size_t length)
+PQescapeString(char *to, const char *from, size_t length)
{
const char *source = from;
- char *target = to;
+ char *target = to;
unsigned int remaining = length;
- while (remaining > 0) {
- switch (*source) {
- case '\\':
- *target = '\\';
- target++;
- *target = '\\';
- /* target and remaining are updated below. */
- break;
+ while (remaining > 0)
+ {
+ switch (*source)
+ {
+ case '\\':
+ *target = '\\';
+ target++;
+ *target = '\\';
+ /* target and remaining are updated below. */
+ break;
- case '\'':
- *target = '\'';
- target++;
- *target = '\'';
- /* target and remaining are updated below. */
- break;
+ case '\'':
+ *target = '\'';
+ target++;
+ *target = '\'';
+ /* target and remaining are updated below. */
+ break;
- default:
- *target = *source;
- /* target and remaining are updated below. */
+ default:
+ *target = *source;
+ /* target and remaining are updated below. */
}
source++;
target++;
/* Write the terminating NUL character. */
*target = '\0';
-
+
return target - to;
}
unsigned char *
PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen)
{
- unsigned char *vp;
- unsigned char *rp;
- unsigned char *result;
- size_t i;
- size_t len;
+ unsigned char *vp;
+ unsigned char *rp;
+ unsigned char *result;
+ size_t i;
+ size_t len;
/*
* empty string has 1 char ('\0')
* and the Perl5 interface, so maybe it's not so unreasonable.
*/
-PGresult *
+PGresult *
PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
{
PGresult *result;
}
/* If there's enough space in the current block, no problem. */
- if (nBytes <= (size_t)res->spaceLeft)
+ if (nBytes <= (size_t) res->spaceLeft)
{
space = res->curBlock->space + res->curOffset;
res->curOffset += nBytes;
space = block->space + PGRESULT_BLOCK_OVERHEAD;
if (res->curBlock)
{
-
/*
* Tuck special block below the active block, so that we don't
* have to waste the free space in the active block.
static void
saveErrorResult(PGconn *conn)
{
-
/*
* If no old async result, just let PQmakeEmptyPGresult make one.
* Likewise if old result is not an error message.
res = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR);
else
{
-
/*
* Make sure PQerrorMessage agrees with result; it could be
* different if we have concatenated messages.
{
if (res->ntups >= res->tupArrSize)
{
-
/*
* Try to grow the array.
*
if (!query)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("command string is a null pointer\n"));
+ libpq_gettext("command string is a null pointer\n"));
return 0;
}
if (conn->asyncStatus != PGASYNC_IDLE)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("another command is already in progress\n"));
+ libpq_gettext("another command is already in progress\n"));
return 0;
}
*/
if (pqIsnonblocking(conn))
{
-
/*
* the buffer must have emptied completely before we allow a new
* query to be buffered
}
else
{
-
/*
* the frontend-backend protocol uses 'Q' to designate queries
*/
static void
handleSendFailure(PGconn *conn)
{
-
/*
* Accept any available input data, ignoring errors. Note that if
* pqReadData decides the backend has closed the channel, it will
*/
if (pqReadData(conn) < 0)
{
-
/*
* for non-blocking connections try to flush the send-queue
* otherwise we may never get a responce for something that may
*/
for (;;)
{
-
/*
* Quit if in COPY_OUT state: we expect raw data from the server
* until PQendcopy is called. Don't try to parse it according to
}
else
{
-
/*
* In BUSY state, we can process everything.
*/
}
else
{
-
/*
* A new 'T' message is treated as the start of
* another PGresult. (It is not clear that this
default:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "unexpected response from server; first received character was \"%c\"\n"),
+ "unexpected response from server; first received character was \"%c\"\n"),
id);
/* build an error result holding the error message */
saveErrorResult(conn);
vlen = 0;
if (tup[i].value == NULL)
{
- tup[i].value = (char *) pqResultAlloc(result, vlen + 1, (bool)binary);
+ tup[i].value = (char *) pqResultAlloc(result, vlen + 1, (bool) binary);
if (tup[i].value == NULL)
goto outOfMemory;
}
* Returns NULL if and only if no query work remains.
*/
-PGresult *
+PGresult *
PQgetResult(PGconn *conn)
{
PGresult *res;
if (pqWait(TRUE, FALSE, conn) ||
pqReadData(conn) < 0)
{
-
/*
* conn->errorMessage has been set by pqWait or pqReadData. We
* want to append it to any already-received error message.
break;
default:
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unexpected asyncStatus: %d\n"),
+ libpq_gettext("unexpected asyncStatus: %d\n"),
(int) conn->asyncStatus);
res = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR);
break;
* when done with it.
*/
-PGresult *
+PGresult *
PQexec(PGconn *conn, const char *query)
{
PGresult *result;
{
PQclear(result);
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("COPY state must be terminated first\n"));
+ libpq_gettext("COPY state must be terminated first\n"));
/* restore blocking status */
goto errout;
}
* the CALLER is responsible for FREE'ing the structure returned
*/
-PGnotify *
+PGnotify *
PQnotifies(PGconn *conn)
{
Dlelem *e;
* ----------------
*/
-PGresult *
+PGresult *
PQfn(PGconn *conn,
int fnid,
int *result_buf,
return NULL;
}
- if (pqPuts("F ", conn) != 0 || /* function */
- pqPutInt(fnid, 4, conn) != 0 || /* function id */
- pqPutInt(nargs, 4, conn) != 0) /* # of args */
+ if (pqPuts("F ", conn) != 0 || /* function */
+ pqPutInt(fnid, 4, conn) != 0 || /* function id */
+ pqPutInt(nargs, 4, conn) != 0) /* # of args */
{
handleSendFailure(conn);
return NULL;
{
/* The backend violates the protocol. */
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("protocol error: id=0x%x\n"),
+ libpq_gettext("protocol error: id=0x%x\n"),
id);
saveErrorResult(conn);
conn->inStart = conn->inCursor;
default:
/* The backend violates the protocol. */
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("protocol error: id=0x%x\n"),
+ libpq_gettext("protocol error: id=0x%x\n"),
id);
saveErrorResult(conn);
conn->inStart = conn->inCursor;
if (res->noticeHook)
{
snprintf(noticeBuf, sizeof(noticeBuf),
- libpq_gettext("column number %d is out of range 0..%d\n"),
+ libpq_gettext("column number %d is out of range 0..%d\n"),
field_num, res->numAttributes - 1);
DONOTICE(res, noticeBuf);
}
if (res->noticeHook)
{
snprintf(noticeBuf, sizeof(noticeBuf),
- libpq_gettext("row number %d is out of range 0..%d\n"),
- tup_num, res->ntups - 1);
+ libpq_gettext("row number %d is out of range 0..%d\n"),
+ tup_num, res->ntups - 1);
DONOTICE(res, noticeBuf);
}
return FALSE;
if (res->noticeHook)
{
snprintf(noticeBuf, sizeof(noticeBuf),
- libpq_gettext("column number %d is out of range 0..%d\n"),
- field_num, res->numAttributes - 1);
+ libpq_gettext("column number %d is out of range 0..%d\n"),
+ field_num, res->numAttributes - 1);
DONOTICE(res, noticeBuf);
}
return FALSE;
char *
PQoidStatus(const PGresult *res)
{
-
/*
* This must be enough to hold the result. Don't laugh, this is better
* than what this function used to do.
return InvalidOid;
#ifdef WIN32
- SetLastError(0);
+ SetLastError(0);
#else
errno = 0;
#endif
if (res->noticeHook)
{
snprintf(noticeBuf, sizeof(noticeBuf),
- libpq_gettext("could not interpret result from server: %s\n"),
- res->cmdStatus);
+ libpq_gettext("could not interpret result from server: %s\n"),
+ res->cmdStatus);
DONOTICE(res, noticeBuf);
}
return "";
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.39 2001/09/17 20:05:47 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.40 2001/10/25 05:50:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (fd < 0)
{ /* error */
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not open file \"%s\": %s\n"),
+ libpq_gettext("could not open file \"%s\": %s\n"),
filename, strerror(errno));
return InvalidOid;
}
if (lobjOid == InvalidOid)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not create large object for file \"%s\"\n"),
+ libpq_gettext("could not create large object for file \"%s\"\n"),
filename);
(void) close(fd);
return InvalidOid;
if (lobj == -1)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not open large object %u\n"),
+ libpq_gettext("could not open large object %u\n"),
lobjOid);
(void) close(fd);
return InvalidOid;
if (tmp < nbytes)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("error while reading file \"%s\"\n"),
+ libpq_gettext("error while reading file \"%s\"\n"),
filename);
(void) close(fd);
(void) lo_close(conn, lobj);
if (lobj == -1)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not open large object %u\n"), lobjId);
+ libpq_gettext("could not open large object %u\n"), lobjId);
return -1;
}
if (fd < 0)
{ /* error */
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not open file \"%s\": %s\n"),
+ libpq_gettext("could not open file \"%s\": %s\n"),
filename, strerror(errno));
(void) lo_close(conn, lobj);
return -1;
if (tmp < nbytes)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("error while writing to file \"%s\"\n"),
+ libpq_gettext("error while writing to file \"%s\"\n"),
filename);
(void) lo_close(conn, lobj);
(void) close(fd);
if (lobjfuncs->fn_lo_open == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lo_open\n"));
+ libpq_gettext("cannot determine OID of function lo_open\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_close == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lo_close\n"));
+ libpq_gettext("cannot determine OID of function lo_close\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_creat == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lo_creat\n"));
+ libpq_gettext("cannot determine OID of function lo_creat\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_unlink == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lo_unlink\n"));
+ libpq_gettext("cannot determine OID of function lo_unlink\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_lseek == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lo_lseek\n"));
+ libpq_gettext("cannot determine OID of function lo_lseek\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_tell == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lo_tell\n"));
+ libpq_gettext("cannot determine OID of function lo_tell\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_read == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function loread\n"));
+ libpq_gettext("cannot determine OID of function loread\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_write == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lowrite\n"));
+ libpq_gettext("cannot determine OID of function lowrite\n"));
free(lobjfuncs);
return -1;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.57 2001/09/30 16:23:30 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.58 2001/10/25 05:50:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define DONOTICE(conn,message) \
((*(conn)->noticeHook) ((conn)->noticeArg, (message)))
-static int pqPutBytes(const char *s, size_t nbytes, PGconn *conn);
+static int pqPutBytes(const char *s, size_t nbytes, PGconn *conn);
/*
* pqGetc:
- * get a character from the connection
+ * get a character from the connection
*
- * All these routines return 0 on success, EOF on error.
- * Note that for the Get routines, EOF only means there is not enough
- * data in the buffer, not that there is necessarily a hard error.
+ * All these routines return 0 on success, EOF on error.
+ * Note that for the Get routines, EOF only means there is not enough
+ * data in the buffer, not that there is necessarily a hard error.
*/
int
pqGetc(char *result, PGconn *conn)
*/
if (pqIsnonblocking(conn) && nbytes > avail && pqFlush(conn))
{
-
/*
* even if the flush failed we may still have written some data,
* recalculate the size of the send-queue relative to the amount
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not flush enough data (space available: %d, space needed %d)\n"),
- Max(conn->outBufSize - conn->outCount, 0), nbytes);
+ Max(conn->outBufSize - conn->outCount, 0), nbytes);
return EOF;
}
/* fixup avail for while loop */
/*
* pqGetnchar:
- * get a string of exactly len bytes in buffer s, no null termination
+ * get a string of exactly len bytes in buffer s, no null termination
*/
int
pqGetnchar(char *s, size_t len, PGconn *conn)
/*
* pqPutnchar:
- * send a string of exactly len bytes, no null termination needed
+ * send a string of exactly len bytes, no null termination needed
*/
int
pqPutnchar(const char *s, size_t len, PGconn *conn)
/*
* pgGetInt
- * read a 2 or 4 byte integer and convert from network byte order
- * to local byte order
+ * read a 2 or 4 byte integer and convert from network byte order
+ * to local byte order
*/
int
pqGetInt(int *result, size_t bytes, PGconn *conn)
goto definitelyFailed;
#endif
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not receive data from server: %s\n"),
+ libpq_gettext("could not receive data from server: %s\n"),
SOCK_STRERROR(SOCK_ERRNO));
return -1;
}
goto definitelyFailed;
#endif
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not receive data from server: %s\n"),
+ libpq_gettext("could not receive data from server: %s\n"),
SOCK_STRERROR(SOCK_ERRNO));
return -1;
}
definitelyFailed:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "server closed the connection unexpectedly\n"
- "\tThis probably means the server terminated abnormally\n"
- "\tbefore or while processing the request.\n"));
+ "server closed the connection unexpectedly\n"
+ "\tThis probably means the server terminated abnormally\n"
+ "\tbefore or while processing the request.\n"));
conn->status = CONNECTION_BAD; /* No more connection to backend */
#ifdef WIN32
closesocket(conn->sock);
if (sent < 0)
{
-
/*
* Anything except EAGAIN or EWOULDBLOCK is trouble. If it's
* EPIPE or ECONNRESET, assume we've lost the backend
#endif
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "server closed the connection unexpectedly\n"
- "\tThis probably means the server terminated abnormally\n"
- "\tbefore or while processing the request.\n"));
+ "server closed the connection unexpectedly\n"
+ "\tThis probably means the server terminated abnormally\n"
+ "\tbefore or while processing the request.\n"));
/*
* We used to close the socket here, but that's a bad
default:
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not send data to server: %s\n"),
+ libpq_gettext("could not send data to server: %s\n"),
SOCK_STRERROR(SOCK_ERRNO));
/* We don't assume it's a fatal error... */
return EOF;
{
return 0;
}
-
#endif /* MULTIBYTE */
char *
libpq_gettext(const char *msgid)
{
- static int already_bound = 0;
+ static int already_bound = 0;
if (!already_bound)
{
return dgettext("libpq", msgid);
}
-#endif /* ENABLE_NLS */
+#endif /* ENABLE_NLS */
#ifdef WIN32
/*
* If you can verify this working on win9x or have a solution, let us know, ok?
*
*/
-const char*
+const char *
winsock_strerror(DWORD eno)
{
- #define WSSE_MAXLEN (sizeof(winsock_strerror_buf)-1-12) /* 12 == "(0x00000000)" */
- int length;
+#define WSSE_MAXLEN (sizeof(winsock_strerror_buf)-1-12) /* 12 == "(0x00000000)" */
+ int length;
+
+ /* First try the "system table", this works on Win2k pro */
- /* First try the "system table", this works on Win2k pro */
+ if (FormatMessage(
+ FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
+ 0, eno, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ winsock_strerror_buf, WSSE_MAXLEN, NULL
+ ))
+ goto WSSE_GOODEXIT;
- if (FormatMessage(
- FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM,
- 0,eno,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- winsock_strerror_buf,WSSE_MAXLEN,NULL
- ))
- goto WSSE_GOODEXIT;
+ /* That didn't work, let's try the netmsg.dll */
- /* That didn't work, let's try the netmsg.dll */
+ if (netmsgModule &&
+ FormatMessage(
+ FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE,
+ 0, eno, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ winsock_strerror_buf, WSSE_MAXLEN, NULL
+ ))
+ goto WSSE_GOODEXIT;
- if (netmsgModule &&
- FormatMessage(
- FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_HMODULE,
- 0,eno,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- winsock_strerror_buf,WSSE_MAXLEN,NULL
- ))
- goto WSSE_GOODEXIT;
+ /* Everything failed, just tell the user that we don't know the desc */
- /* Everything failed, just tell the user that we don't know the desc */
-
- strcat(winsock_strerror_buf,"Socket error, no description available.");
+ strcat(winsock_strerror_buf, "Socket error, no description available.");
WSSE_GOODEXIT:
- length = strlen(winsock_strerror_buf);
- sprintf(winsock_strerror_buf + (lengthWSSE_MAXLEN),
- "(0x%08X)",eno);
+ length = strlen(winsock_strerror_buf);
+ sprintf(winsock_strerror_buf + (length < WSSE_MAXLEN ? length : WSSE_MAXLEN),
+ "(0x%08X)", eno);
- return winsock_strerror_buf;
+ return winsock_strerror_buf;
}
#endif
* didn't really belong there.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.42 2001/03/22 04:01:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.43 2001/10/25 05:50:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int ws_row;
int ws_col;
} screen_size;
-
#endif
nTups = PQntuples(res);
#endif
)
{
-
/*
* If we think there'll be more than one screen of output, try
* to pipe to the pager program.
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq-fe.h,v 1.75 2001/09/14 17:46:40 momjian Exp $
+ * $Id: libpq-fe.h,v 1.76 2001/10/25 05:50:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include
#ifdef WIN32
- #define SOCK_ERRNO (WSAGetLastError ())
- #define SOCK_STRERROR winsock_strerror
+#define SOCK_ERRNO (WSAGetLastError ())
+#define SOCK_STRERROR winsock_strerror
#else
- #define SOCK_ERRNO errno
- #define SOCK_STRERROR strerror
+#define SOCK_ERRNO errno
+#define SOCK_STRERROR strerror
#endif
typedef enum
{
-
/*
* Although you may decide to change this list in some way, values
* which become unused should never be removed, nor should
/* === in fe-exec.c === */
/* Quoting strings before inclusion in queries. */
- extern size_t PQescapeString (char *to, const char *from, size_t length);
+ extern size_t PQescapeString(char *to, const char *from, size_t length);
extern unsigned char *PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen);
/* Simple synchronous query */
extern PGresult *PQexec(PGconn *conn, const char *query);
extern PGnotify *PQnotifies(PGconn *conn);
- extern void PQfreeNotify(PGnotify *notify);
+ extern void PQfreeNotify(PGnotify *notify);
/* Interface for multiple-result or asynchronous queries */
extern int PQsendQuery(PGconn *conn, const char *query);
#ifdef __cplusplus
}
-
#endif
-
#endif /* LIBPQ_FE_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq-int.h,v 1.40 2001/10/03 21:58:28 tgl Exp $
+ * $Id: libpq-int.h,v 1.41 2001/10/25 05:50:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
PQnoticeProcessor noticeHook; /* notice/error message processor */
void *noticeArg;
- int client_encoding;/* encoding id */
+ int client_encoding; /* encoding id */
char *errMsg; /* error message, or NULL if no error */
/* PGAsyncStatusType defines the state of the query-execution state machine */
typedef enum
{
- PGASYNC_IDLE, /* nothing's happening, dude */
- PGASYNC_BUSY, /* query in progress */
- PGASYNC_READY, /* result ready for PQgetResult */
- PGASYNC_COPY_IN, /* Copy In data transfer in progress */
- PGASYNC_COPY_OUT /* Copy Out data transfer in progress */
+ PGASYNC_IDLE, /* nothing's happening, dude */
+ PGASYNC_BUSY, /* query in progress */
+ PGASYNC_READY, /* result ready for PQgetResult */
+ PGASYNC_COPY_IN,/* Copy In data transfer in progress */
+ PGASYNC_COPY_OUT/* Copy Out data transfer in progress */
} PGAsyncStatusType;
/* PGSetenvStatusType defines the state of the PQSetenv state machine */
typedef enum
{
- SETENV_STATE_OPTION_SEND, /* About to send an Environment Option */
- SETENV_STATE_OPTION_WAIT, /* Waiting for above send to complete */
+ SETENV_STATE_OPTION_SEND, /* About to send an
+ * Environment Option */
+ SETENV_STATE_OPTION_WAIT, /* Waiting for above send
+ * to complete */
/* these next two are only used in MULTIBYTE mode */
- SETENV_STATE_ENCODINGS_SEND,/* About to send an "encodings" query */
- SETENV_STATE_ENCODINGS_WAIT,/* Waiting for query to complete */
- SETENV_STATE_IDLE
+ SETENV_STATE_ENCODINGS_SEND, /* About to send an
+ * "encodings" query */
+ SETENV_STATE_ENCODINGS_WAIT, /* Waiting for query to
+ * complete */
+ SETENV_STATE_IDLE
} PGSetenvStatusType;
/* large-object-access data ... allocated only if large-object code is used. */
/* Miscellaneous stuff */
int be_pid; /* PID of backend --- needed for cancels */
int be_key; /* key of backend --- needed for cancels */
- char md5Salt[4]; /* password salt received from backend */
- char cryptSalt[2]; /* password salt received from backend */
+ char md5Salt[4]; /* password salt received from backend */
+ char cryptSalt[2]; /* password salt received from backend */
PGlobjfuncs *lobjfuncs; /* private state for large-object access
* fns */
/* Buffer for receiving various parts of messages */
PQExpBufferData workBuffer; /* expansible string */
- int client_encoding;/* encoding id */
+ int client_encoding; /* encoding id */
};
/* String descriptions of the ExecStatusTypes.
#define pqIsnonblocking(conn) ((conn)->nonblocking)
#ifdef ENABLE_NLS
-extern char * libpq_gettext(const char *msgid)
+extern char *
+libpq_gettext(const char *msgid)
__attribute__((format_arg(1)));
+
#else
#define libpq_gettext(x) (x)
#endif
-
#endif /* LIBPQ_INT_H */
case DLL_PROCESS_ATTACH:
if (WSAStartup(MAKEWORD(1, 1), &wsaData))
{
-
/*
* No really good way to do error handling here, since we
* don't know how we were loaded
*/
return FALSE;
}
- if (netmsgModule == NULL){
- netmsgModule=LoadLibraryEx("netmsg.dll",NULL,LOAD_LIBRARY_AS_DATAFILE);
- }
+ if (netmsgModule == NULL)
+ netmsgModule = LoadLibraryEx("netmsg.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
break;
case DLL_PROCESS_DETACH:
- if (netmsgModule != NULL)
+ if (netmsgModule != NULL)
FreeLibrary(netmsgModule);
WSACleanup();
break;
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.11 2001/08/17 15:11:15 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.12 2001/10/25 05:50:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
for (;;)
{
-
/*
* Try to format the given string into the available space; but if
* there's hardly any space, don't bother trying, just fall
for (;;)
{
-
/*
* Try to format the given string into the available space; but if
* there's hardly any space, don't bother trying, just fall
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqexpbuffer.h,v 1.7 2001/10/03 21:58:28 tgl Exp $
+ * $Id: pqexpbuffer.h,v 1.8 2001/10/25 05:50:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* This is a convenience routine that does the same thing as
* resetPQExpBuffer() followed by appendPQExpBuffer().
*/
-extern void printfPQExpBuffer(PQExpBuffer str, const char *fmt, ...)
+extern void
+printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
/* This extension allows gcc to check the format string */
__attribute__((format(printf, 2, 3)));
* to str if necessary. This is sort of like a combination of sprintf and
* strcat.
*/
-extern void appendPQExpBuffer(PQExpBuffer str, const char *fmt, ...)
+extern void
+appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
/* This extension allows gcc to check the format string */
__attribute__((format(printf, 2, 3)));
*/
extern void appendBinaryPQExpBuffer(PQExpBuffer str,
const char *data, size_t datalen);
-
#endif /* PQEXPBUFFER_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqsignal.h,v 1.10 2001/02/10 02:31:30 tgl Exp $
+ * $Id: pqsignal.h,v 1.11 2001/10/25 05:50:13 momjian Exp $
*
* NOTES
* This shouldn't be in libpq, but the monitor and some other
typedef void (*pqsigfunc) (int);
extern pqsigfunc pqsignal(int signo, pqsigfunc func);
-
#endif /* PQSIGNAL_H */
*/
#define crypt(a,b) (a)
-#undef EAGAIN /* doesn't apply on sockets */
+#undef EAGAIN /* doesn't apply on sockets */
#undef EINTR
#define EINTR WSAEINTR
#define EWOULDBLOCK WSAEWOULDBLOCK
static HINSTANCE netmsgModule = NULL;
static char winsock_strerror_buf[512];
-const char* winsock_strerror(DWORD eno);
+const char *winsock_strerror(DWORD eno);
/* Bind parameters on a statement handle */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_BindParameter(
- HSTMT hstmt,
- UWORD ipar,
- SWORD fParamType,
- SWORD fCType,
- SWORD fSqlType,
- UDWORD cbColDef,
- SWORD ibScale,
- PTR rgbValue,
- SDWORD cbValueMax,
- SDWORD FAR *pcbValue)
+ HSTMT hstmt,
+ UWORD ipar,
+ SWORD fParamType,
+ SWORD fCType,
+ SWORD fSqlType,
+ UDWORD cbColDef,
+ SWORD ibScale,
+ PTR rgbValue,
+ SDWORD cbValueMax,
+ SDWORD FAR * pcbValue)
{
StatementClass *stmt = (StatementClass *) hstmt;
static char *func = "PGAPI_BindParameter";
/* Associate a user-supplied buffer with a database column. */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_BindCol(
- HSTMT hstmt,
- UWORD icol,
- SWORD fCType,
- PTR rgbValue,
- SDWORD cbValueMax,
- SDWORD FAR *pcbValue)
+ HSTMT hstmt,
+ UWORD icol,
+ SWORD fCType,
+ PTR rgbValue,
+ SDWORD cbValueMax,
+ SDWORD FAR * pcbValue)
{
StatementClass *stmt = (StatementClass *) hstmt;
static char *func = "PGAPI_BindCol";
mylog("%s: entering...\n", func);
mylog("**** PGAPI_BindCol: stmt = %u, icol = %d\n", stmt, icol);
-mylog("**** : fCType=%d rgb=%x valusMax=%d pcb=%x\n", fCType, rgbValue, cbValueMax, pcbValue);
+ mylog("**** : fCType=%d rgb=%x valusMax=%d pcb=%x\n", fCType, rgbValue, cbValueMax, pcbValue);
if (!stmt)
{
* it is best to say this function is not supported and let the application assume a
* data type (most likely varchar).
*/
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_DescribeParam(
- HSTMT hstmt,
- UWORD ipar,
- SWORD FAR *pfSqlType,
- UDWORD FAR *pcbColDef,
- SWORD FAR *pibScale,
- SWORD FAR *pfNullable)
+ HSTMT hstmt,
+ UWORD ipar,
+ SWORD FAR * pfSqlType,
+ UDWORD FAR * pcbColDef,
+ SWORD FAR * pibScale,
+ SWORD FAR * pfNullable)
{
StatementClass *stmt = (StatementClass *) hstmt;
static char *func = "PGAPI_DescribeParam";
/* Sets multiple values (arrays) for the set of parameter markers. */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_ParamOptions(
- HSTMT hstmt,
- UDWORD crow,
- UDWORD FAR *pirow)
+ HSTMT hstmt,
+ UDWORD crow,
+ UDWORD FAR * pirow)
{
static char *func = "PGAPI_ParamOptions";
- StatementClass *stmt = (StatementClass *) hstmt;
+ StatementClass *stmt = (StatementClass *) hstmt;
mylog("%s: entering... %d %x\n", func, crow, pirow);
- if (crow == 1) /* temporary solution and must be rewritten later */
+ if (crow == 1) /* temporary solution and must be
+ * rewritten later */
{
if (pirow)
*pirow = 1;
* to call it anyway.
* If the statement does not have parameters, it should just return 0.
*/
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_NumParams(
- HSTMT hstmt,
- SWORD FAR *pcpar)
+ HSTMT hstmt,
+ SWORD FAR * pcpar)
{
StatementClass *stmt = (StatementClass *) hstmt;
char in_quote = FALSE;
void
-extend_bindings(StatementClass *stmt, int num_columns)
+extend_bindings(StatementClass * stmt, int num_columns)
{
static char *func = "extend_bindings";
BindInfoClass *new_bindings;
};
BindInfoClass *create_empty_bindings(int num_columns);
-void extend_bindings(StatementClass *stmt, int num_columns);
-
+void extend_bindings(StatementClass * stmt, int num_columns);
#endif
void
-CI_Destructor(ColumnInfoClass *self)
+CI_Destructor(ColumnInfoClass * self)
{
CI_free_memory(self);
* If self is null, then just read, don't store.
*/
char
-CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn)
+CI_read_fields(ColumnInfoClass * self, ConnectionClass * conn)
{
Int2 lf;
int new_num_fields;
void
-CI_free_memory(ColumnInfoClass *self)
+CI_free_memory(ColumnInfoClass * self)
{
register Int2 lf;
int num_fields = self->num_fields;
void
-CI_set_num_fields(ColumnInfoClass *self, int new_num_fields)
+CI_set_num_fields(ColumnInfoClass * self, int new_num_fields)
{
CI_free_memory(self); /* always safe to call */
void
-CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
+CI_set_field_info(ColumnInfoClass * self, int field_num, char *new_name,
Oid new_adtid, Int2 new_adtsize, Int4 new_atttypmod)
{
/* check bounds */
#define CI_get_atttypmod(self, col) (self->atttypmod[col])
ColumnInfoClass *CI_Constructor(void);
-void CI_Destructor(ColumnInfoClass *self);
-void CI_free_memory(ColumnInfoClass *self);
-char CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn);
+void CI_Destructor(ColumnInfoClass * self);
+void CI_free_memory(ColumnInfoClass * self);
+char CI_read_fields(ColumnInfoClass * self, ConnectionClass * conn);
/* functions for setting up the fields from within the program, */
/* without reading from a socket */
-void CI_set_num_fields(ColumnInfoClass *self, int new_num_fields);
-void CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
+void CI_set_num_fields(ColumnInfoClass * self, int new_num_fields);
+void CI_set_field_info(ColumnInfoClass * self, int field_num, char *new_name,
Oid new_adtid, Int2 new_adtsize, Int4 atttypmod);
-
#endif
extern GLOBAL_VALUES globals;
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_AllocConnect(
- HENV henv,
- HDBC FAR *phdbc)
+ HENV henv,
+ HDBC FAR * phdbc)
{
EnvironmentClass *env = (EnvironmentClass *) henv;
ConnectionClass *conn;
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_Connect(
- HDBC hdbc,
- UCHAR FAR *szDSN,
- SWORD cbDSN,
- UCHAR FAR *szUID,
- SWORD cbUID,
- UCHAR FAR *szAuthStr,
- SWORD cbAuthStr)
+ HDBC hdbc,
+ UCHAR FAR * szDSN,
+ SWORD cbDSN,
+ UCHAR FAR * szUID,
+ SWORD cbUID,
+ UCHAR FAR * szAuthStr,
+ SWORD cbAuthStr)
{
ConnectionClass *conn = (ConnectionClass *) hdbc;
ConnInfo *ci;
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_BrowseConnect(
- HDBC hdbc,
- UCHAR FAR *szConnStrIn,
- SWORD cbConnStrIn,
- UCHAR FAR *szConnStrOut,
- SWORD cbConnStrOutMax,
- SWORD FAR *pcbConnStrOut)
+ HDBC hdbc,
+ UCHAR FAR * szConnStrIn,
+ SWORD cbConnStrIn,
+ UCHAR FAR * szConnStrOut,
+ SWORD cbConnStrOutMax,
+ SWORD FAR * pcbConnStrOut)
{
static char *func = "PGAPI_BrowseConnect";
/* Drop any hstmts open on hdbc and disconnect from database */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_Disconnect(
- HDBC hdbc)
+ HDBC hdbc)
{
ConnectionClass *conn = (ConnectionClass *) hdbc;
static char *func = "PGAPI_Disconnect";
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_FreeConnect(
- HDBC hdbc)
+ HDBC hdbc)
{
ConnectionClass *conn = (ConnectionClass *) hdbc;
static char *func = "PGAPI_FreeConnect";
memset(&rv->connInfo, 0, sizeof(ConnInfo));
#ifdef DRIVER_CURSOR_IMPLEMENT
rv->connInfo.updatable_cursors = 1;
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+#endif /* DRIVER_CURSOR_IMPLEMENT */
memcpy(&(rv->connInfo.drivers), &globals, sizeof(globals));
rv->sock = SOCK_Constructor(rv);
if (!rv->sock)
#ifdef MULTIBYTE
rv->client_encoding = NULL;
rv->server_encoding = NULL;
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
/* Initialize statement options to defaults */
char
-CC_Destructor(ConnectionClass *self)
+CC_Destructor(ConnectionClass * self)
{
mylog("enter CC_Destructor, self=%u\n", self);
free(self->client_encoding);
if (self->server_encoding)
free(self->server_encoding);
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
/* Free up statement holders */
if (self->stmts)
{
/* Return how many cursors are opened on this connection */
int
-CC_cursor_count(ConnectionClass *self)
+CC_cursor_count(ConnectionClass * self)
{
StatementClass *stmt;
int i,
void
-CC_clear_error(ConnectionClass *self)
+CC_clear_error(ConnectionClass * self)
{
self->errornumber = 0;
self->errormsg = NULL;
* We are almost always in the middle of a transaction.
*/
char
-CC_abort(ConnectionClass *self)
+CC_abort(ConnectionClass * self)
{
QResultClass *res;
/* This is called by SQLDisconnect also */
char
-CC_cleanup(ConnectionClass *self)
+CC_cleanup(ConnectionClass * self)
{
int i;
StatementClass *stmt;
int
-CC_set_translation(ConnectionClass *self)
+CC_set_translation(ConnectionClass * self)
{
#ifdef WIN32
char
-CC_connect(ConnectionClass *self, char do_password)
+CC_connect(ConnectionClass * self, char do_password)
{
StartupPacket sp;
StartupPacket6_2 sp62;
char msgbuffer[ERROR_MSG_LENGTH];
char salt[5];
static char *func = "CC_connect";
+
#ifdef MULTIBYTE
- char *encoding;
-#endif /* MULTIBYTE */
+ char *encoding;
+#endif /* MULTIBYTE */
mylog("%s: entering...\n", func);
if (encoding && strcmp(encoding, "OTHER"))
self->client_encoding = strdup(encoding);
else
- {
+ {
encoding = check_client_encoding(ci->drivers.conn_settings);
if (encoding && strcmp(encoding, "OTHER"))
self->client_encoding = strdup(encoding);
mylog("CC_connect(): DSN = '%s', server = '%s', port = '%s', database = '%s', username = '%s', password='%s'\n", ci->dsn, ci->server, ci->port, ci->database, ci->username, ci->password);
another_version_retry:
+
/*
* If the socket was closed for some reason (like a SQLDisconnect,
* but no SQLFreeConnect then create a socket now.
if (!PROTOCOL_62(ci))
{
- BOOL before_64 = PG_VERSION_LT(self, 6.4), ReadyForQuery = FALSE;
+ BOOL before_64 = PG_VERSION_LT(self, 6.4),
+ ReadyForQuery = FALSE;
+
do
{
if (do_password)
self->errormsg = msgbuffer;
qlog("ERROR from backend during authentication: '%s'\n", self->errormsg);
if (strncmp(msgbuffer, "Unsupported frontend protocol", 29) == 0)
- { /* retry older version */
+ { /* retry older version */
if (PROTOCOL_63(ci))
strcpy(ci->protocol, PG62);
else
CC_initialize_pg_version(self);
goto another_version_retry;
}
-
+
return 0;
case 'R':
return 0;
}
break;
- case 'K': /* Secret key (6.4 protocol) */
- (void) SOCK_get_int(sock, 4); /* pid */
- (void) SOCK_get_int(sock, 4); /* key */
+ case 'K': /* Secret key (6.4 protocol) */
+ (void) SOCK_get_int(sock, 4); /* pid */
+ (void) SOCK_get_int(sock, 4); /* key */
break;
- case 'Z': /* Backend is ready for new query (6.4) */
+ case 'Z': /* Backend is ready for new query (6.4) */
ReadyForQuery = TRUE;
break;
default:
return 0;
}
- /*
- * There were no ReadyForQuery responce
- * before 6.4.
+ /*
+ * There were no ReadyForQuery responce before 6.4.
*/
if (before_64 && areq == AUTH_REQ_OK)
ReadyForQuery = TRUE;
char
-CC_add_statement(ConnectionClass *self, StatementClass *stmt)
+CC_add_statement(ConnectionClass * self, StatementClass * stmt)
{
int i;
char
-CC_remove_statement(ConnectionClass *self, StatementClass *stmt)
+CC_remove_statement(ConnectionClass * self, StatementClass * stmt)
{
int i;
* error message with its socket error message.
*/
char *
-CC_create_errormsg(ConnectionClass *self)
+CC_create_errormsg(ConnectionClass * self)
{
SocketClass *sock = self->sock;
int pos;
char
-CC_get_error(ConnectionClass *self, int *number, char **message)
+CC_get_error(ConnectionClass * self, int *number, char **message)
{
int rv;
* 'declare cursor C3326857 for ...' and 'fetch 100 in C3326857' statements.
*/
QResultClass *
-CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi)
+CC_send_query(ConnectionClass * self, char *query, QueryInfo * qi)
{
- QResultClass *result_in = NULL, *res = NULL, *retres = NULL;
- char swallow, *wq;
+ QResultClass *result_in = NULL,
+ *res = NULL,
+ *retres = NULL;
+ char swallow,
+ *wq;
int id;
SocketClass *sock = self->sock;
- int maxlen, empty_reqs;
- BOOL msg_truncated, ReadyToReturn,
- tuples_return = FALSE, query_completed = FALSE,
- before_64 = PG_VERSION_LT(self, 6.4);
+ int maxlen,
+ empty_reqs;
+ BOOL msg_truncated,
+ ReadyToReturn,
+ tuples_return = FALSE,
+ query_completed = FALSE,
+ before_64 = PG_VERSION_LT(self, 6.4);
/* ERROR_MSG_LENGTH is suffcient */
static char msgbuffer[ERROR_MSG_LENGTH + 1];
mylog("send_query: returning res = %u\n", res);
if (!before_64)
break;
+
/*
* (Quotation from the original comments) since
* backend may produce more than one result for some
CC_set_no_trans(self);
}
else
- {
self->errornumber = CONNECTION_SERVER_REPORTED_WARNING;
- }
QR_set_status(res, PGRES_FATAL_ERROR);
QR_set_aborted(res, TRUE);
while (msg_truncated)
}
else
{ /* next fetch, so reuse an existing result */
+
/*
- * called from QR_next_tuple
- * and must return immediately.
+ * called from QR_next_tuple and must return
+ * immediately.
*/
ReadyToReturn = TRUE;
if (!QR_fetch_tuples(result_in, NULL, NULL))
retres = NULL;
break;
}
+
/*
- * There were no ReadyForQuery response before 6.4.
+ * There were no ReadyForQuery response before 6.4.
*/
if (before_64)
{
break;
}
}
- /*
- * Break before being ready to return.
+
+ /*
+ * Break before being ready to return.
*/
if (!ReadyToReturn)
{
else
retres = res;
}
+
/*
- * set notice message to result_in.
+ * set notice message to result_in.
*/
if (result_in && res && retres == result_in)
{
QR_set_status(result_in, QR_get_status(res));
QR_set_notice(result_in, QR_get_notice(res));
}
+
/*
- * Cleanup garbage results before returning.
+ * Cleanup garbage results before returning.
*/
if (res && retres != res)
QR_Destructor(res);
int
-CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG *args, int nargs)
+CC_send_function(ConnectionClass * self, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG * args, int nargs)
{
char id,
c,
char
-CC_send_settings(ConnectionClass *self)
+CC_send_settings(ConnectionClass * self)
{
/* char ini_query[MAX_MESSAGE_LEN]; */
ConnInfo *ci = &(self->connInfo);
* will go away and the define 'PG_TYPE_LO' will be updated.
*/
void
-CC_lookup_lo(ConnectionClass *self)
+CC_lookup_lo(ConnectionClass * self)
{
HSTMT hstmt;
StatementClass *stmt;
* h-inoue 01-2-2001
*/
void
-CC_initialize_pg_version(ConnectionClass *self)
+CC_initialize_pg_version(ConnectionClass * self)
{
strcpy(self->pg_version, self->connInfo.protocol);
if (PROTOCOL_62(&self->connInfo))
* DJP - 25-1-2001
*/
void
-CC_lookup_pg_version(ConnectionClass *self)
+CC_lookup_pg_version(ConnectionClass * self)
{
HSTMT hstmt;
StatementClass *stmt;
void
-CC_log_error(char *func, char *desc, ConnectionClass *self)
+CC_log_error(char *func, char *desc, ConnectionClass * self)
{
#ifdef PRN_NULLCHECK
#define nullcheck(a) (a ? a : "(NULL)")
#undef PRN_NULLCHECK
}
-int CC_get_max_query_len(const ConnectionClass *conn)
+int
+CC_get_max_query_len(const ConnectionClass * conn)
{
- int value;
- /* Long Queries in 7.0+ */
- if (PG_VERSION_GE(conn, 7.0))
- value = 0 /* MAX_STATEMENT_LEN */;
- /* Prior to 7.0 we used 2*BLCKSZ */
- else if (PG_VERSION_GE(conn, 6.5))
- value = (2 * BLCKSZ);
- else
- /* Prior to 6.5 we used BLCKSZ */
- value = BLCKSZ;
- return value;
+ int value;
+
+ /* Long Queries in 7.0+ */
+ if (PG_VERSION_GE(conn, 7.0))
+ value = 0 /* MAX_STATEMENT_LEN */ ;
+ /* Prior to 7.0 we used 2*BLCKSZ */
+ else if (PG_VERSION_GE(conn, 6.5))
+ value = (2 * BLCKSZ);
+ else
+ /* Prior to 6.5 we used BLCKSZ */
+ value = BLCKSZ;
+ return value;
}
typedef enum
{
- CONN_NOT_CONNECTED, /* Connection has not been established */
- CONN_CONNECTED, /* Connection is up and has been
+ CONN_NOT_CONNECTED, /* Connection has not been
+ * established */
+ CONN_CONNECTED, /* Connection is up and has been
* established */
- CONN_DOWN, /* Connection is broken */
- CONN_EXECUTING /* the connection is currently executing a
+ CONN_DOWN, /* Connection is broken */
+ CONN_EXECUTING /* the connection is currently executing a
* statement */
-} CONN_Status;
+} CONN_Status;
/* These errors have general sql error state */
#define CONNECTION_SERVER_NOT_REACHED 101
char focus_password;
char disallow_premature;
char updatable_cursors;
- GLOBAL_VALUES drivers; /* moved from driver's option */
-} ConnInfo;
+ GLOBAL_VALUES drivers; /* moved from driver's option */
+} ConnInfo;
/* Macro to determine is the connection using 6.2 protocol? */
#define PROTOCOL_62(conninfo_) (strncmp((conninfo_)->protocol, PG62, strlen(PG62)) == 0)
#define HINSTANCE void *
#endif
-typedef BOOL (FAR WINAPI * DataSourceToDriverProc) (UDWORD,
- SWORD,
- PTR,
- SDWORD,
- PTR,
- SDWORD,
- SDWORD FAR *,
- UCHAR FAR *,
- SWORD,
- SWORD FAR *);
-
-typedef BOOL (FAR WINAPI * DriverToDataSourceProc) (UDWORD,
- SWORD,
- PTR,
- SDWORD,
- PTR,
- SDWORD,
- SDWORD FAR *,
- UCHAR FAR *,
- SWORD,
- SWORD FAR *);
+typedef BOOL(FAR WINAPI * DataSourceToDriverProc) (UDWORD,
+ SWORD,
+ PTR,
+ SDWORD,
+ PTR,
+ SDWORD,
+ SDWORD FAR *,
+ UCHAR FAR *,
+ SWORD,
+ SWORD FAR *);
+
+typedef BOOL(FAR WINAPI * DriverToDataSourceProc) (UDWORD,
+ SWORD,
+ PTR,
+ SDWORD,
+ PTR,
+ SDWORD,
+ SDWORD FAR *,
+ UCHAR FAR *,
+ SWORD,
+ SWORD FAR *);
/******* The Connection handle ************/
struct ConnectionClass_
Int2 pg_version_minor;
char ms_jet;
#ifdef MULTIBYTE
- char *client_encoding;
- char *server_encoding;
-#endif /* MULTIBYTE */
+ char *client_encoding;
+ char *server_encoding;
+#endif /* MULTIBYTE */
};
/* prototypes */
ConnectionClass *CC_Constructor(void);
-char CC_Destructor(ConnectionClass *self);
-int CC_cursor_count(ConnectionClass *self);
-char CC_cleanup(ConnectionClass *self);
-char CC_abort(ConnectionClass *self);
-int CC_set_translation(ConnectionClass *self);
-char CC_connect(ConnectionClass *self, char do_password);
-char CC_add_statement(ConnectionClass *self, StatementClass *stmt);
-char CC_remove_statement(ConnectionClass *self, StatementClass *stmt);
-char CC_get_error(ConnectionClass *self, int *number, char **message);
-QResultClass *CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi);
-void CC_clear_error(ConnectionClass *self);
-char *CC_create_errormsg(ConnectionClass *self);
-int CC_send_function(ConnectionClass *conn, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG *argv, int nargs);
-char CC_send_settings(ConnectionClass *self);
-void CC_lookup_lo(ConnectionClass *conn);
-void CC_lookup_pg_version(ConnectionClass *conn);
-void CC_initialize_pg_version(ConnectionClass *conn);
-void CC_log_error(char *func, char *desc, ConnectionClass *self);
-int CC_get_max_query_len(const ConnectionClass *self);
-
+char CC_Destructor(ConnectionClass * self);
+int CC_cursor_count(ConnectionClass * self);
+char CC_cleanup(ConnectionClass * self);
+char CC_abort(ConnectionClass * self);
+int CC_set_translation(ConnectionClass * self);
+char CC_connect(ConnectionClass * self, char do_password);
+char CC_add_statement(ConnectionClass * self, StatementClass * stmt);
+char CC_remove_statement(ConnectionClass * self, StatementClass * stmt);
+char CC_get_error(ConnectionClass * self, int *number, char **message);
+QResultClass *CC_send_query(ConnectionClass * self, char *query, QueryInfo * qi);
+void CC_clear_error(ConnectionClass * self);
+char *CC_create_errormsg(ConnectionClass * self);
+int CC_send_function(ConnectionClass * conn, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG * argv, int nargs);
+char CC_send_settings(ConnectionClass * self);
+void CC_lookup_lo(ConnectionClass * conn);
+void CC_lookup_pg_version(ConnectionClass * conn);
+void CC_initialize_pg_version(ConnectionClass * conn);
+void CC_log_error(char *func, char *desc, ConnectionClass * self);
+int CC_get_max_query_len(const ConnectionClass * self);
#endif
/*-------
- * Module: convert.c
+ * Module: convert.c
*
* Description: This module contains routines related to
* converting parameters and columns into requested data types.
{0, 0}
};
-static char *mapFunction(const char *func);
+static char *mapFunction(const char *func);
static unsigned int conv_from_octal(const unsigned char *s);
static unsigned int conv_from_hex(const unsigned char *s);
-static char *conv_to_octal(unsigned char val);
+static char *conv_to_octal(unsigned char val);
/*---------
* A Guide for date/time/timestamp conversions
/* This is called by SQLFetch() */
int
-copy_and_convert_field_bindinfo(StatementClass *stmt, Int4 field_type, void *value, int col)
+copy_and_convert_field_bindinfo(StatementClass * stmt, Int4 field_type, void *value, int col)
{
BindInfoClass *bic = &(stmt->bindings[col]);
/* This is called by SQLGetData() */
int
-copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 fCType,
- PTR rgbValue, SDWORD cbValueMax, SDWORD *pcbValue)
+copy_and_convert_field(StatementClass * stmt, Int4 field_type, void *value, Int2 fCType,
+ PTR rgbValue, SDWORD cbValueMax, SDWORD * pcbValue)
{
Int4 len = 0,
copy_len = 0;
int pcbValueOffset,
rgbValueOffset;
char *rgbValueBindRow;
- const char *ptr;
+ const char *ptr;
int bind_row = stmt->bind_row;
int bind_size = stmt->options.bind_size;
int result = COPY_OK;
BOOL changed;
- static char *tempBuf= NULL;
- static unsigned int tempBuflen = 0;
+ static char *tempBuf = NULL;
+ static unsigned int tempBuflen = 0;
const char *neut_str = value;
- char midtemp[2][32];
- int mtemp_cnt = 0;
+ char midtemp[2][32];
+ int mtemp_cnt = 0;
if (!tempBuf)
tempBuflen = 0;
if (!value)
{
-
/*
* handle a null just by returning SQL_NULL_DATA in pcbValue, and
* doing nothing to the buffer.
*/
switch (field_type)
{
-
/*
* $$$ need to add parsing for date/time/timestamp strings in
* PG_TYPE_CHAR,VARCHAR $$$
sscanf(value, "%4d-%2d-%2d %2d:%2d:%2d", &st.y, &st.m, &st.d, &st.hh, &st.mm, &st.ss);
else
{
-
/*
* The timestamp is invalid so set something conspicuous,
* like the epoch
break;
case PG_TYPE_BOOL:
- { /* change T/F to 1/0 */
+ { /* change T/F to 1/0 */
char *s;
s = midtemp[mtemp_cnt];
{
int nval,
i;
- const char *vp;
+ const char *vp;
/* this is an array of eight integers */
short *short_array = (short *) ((char *) rgbValue + rgbValueOffset);
default:
if (stmt->current_col >= 0 && stmt->bindings[stmt->current_col].data_left == -2)
- stmt->bindings[stmt->current_col].data_left = (cbValueMax > 0) ? 0 : -1; /* This seems to be needed for ADO ? */
+ stmt->bindings[stmt->current_col].data_left = (cbValueMax > 0) ? 0 : -1; /* This seems to be
+ * needed for ADO ? */
if (stmt->current_col < 0 || stmt->bindings[stmt->current_col].data_left < 0)
{
/* convert linefeeds to carriage-return/linefeed */
len = convert_linefeeds(neut_str, NULL, 0, &changed);
- if (cbValueMax == 0) /* just returns length info */
+ if (cbValueMax == 0) /* just returns length
+ * info */
{
result = COPY_RESULT_TRUNCATED;
break;
}
else
{
-
/*
* for SQL_C_CHAR, it's probably ok to leave currency symbols in.
* But to convert to numeric types, it is necessary to get rid of
*((UCHAR *) rgbValue + bind_row) = atoi(neut_str);
/*
- * mylog("SQL_C_BIT: bind_row = %d val = %d, cb = %d, rgb=%d\n",
- * bind_row, atoi(neut_str), cbValueMax, *((UCHAR *)rgbValue));
+ * mylog("SQL_C_BIT: bind_row = %d val = %d, cb = %d,
+ * rgb=%d\n", bind_row, atoi(neut_str), cbValueMax,
+ * *((UCHAR *)rgbValue));
*/
break;
* Functions/Macros to get rid of query size limit.
*
* I always used the follwoing macros to convert from
- * old_statement to new_statement. Please improve it
+ * old_statement to new_statement. Please improve it
* if you have a better way. Hiroshi 2001/05/22
*--------------------------------------------------------------------
*/
-#define INIT_MIN_ALLOC 4096
-static int enlarge_statement(StatementClass *stmt, unsigned int newsize)
+#define INIT_MIN_ALLOC 4096
+static int
+enlarge_statement(StatementClass * stmt, unsigned int newsize)
{
- unsigned int newalsize = INIT_MIN_ALLOC;
+ unsigned int newalsize = INIT_MIN_ALLOC;
static char *func = "enlarge_statement";
if (stmt->stmt_size_limit > 0 && stmt->stmt_size_limit < (int) newsize)
* Enlarge stmt_with_params if necessary.
*----------
*/
-#define ENLARGE_NEWSTATEMENT(newpos) \
+#define ENLARGE_NEWSTATEMENT(newpos) \
if (newpos >= new_stsize) \
{ \
if ((new_stsize = enlarge_statement(stmt, newpos)) <= 0) \
* Initialize stmt_with_params, new_statement etc.
*----------
*/
-#define CVT_INIT(size) \
+#define CVT_INIT(size) \
do { \
if (stmt->stmt_with_params) \
free(stmt->stmt_with_params); \
* Terminate the stmt_with_params string with NULL.
*----------
*/
-#define CVT_TERMINATE \
+#define CVT_TERMINATE \
do { \
new_statement[npos] = '\0'; \
} while (0)
* Append a data.
*----------
*/
-#define CVT_APPEND_DATA(s, len) \
+#define CVT_APPEND_DATA(s, len) \
do { \
unsigned int newpos = npos + len; \
ENLARGE_NEWSTATEMENT(newpos) \
* Append a string.
*----------
*/
-#define CVT_APPEND_STR(s) \
+#define CVT_APPEND_STR(s) \
do { \
unsigned int len = strlen(s); \
CVT_APPEND_DATA(s, len); \
} while (0)
/*----------
- * Append a char.
+ * Append a char.
*----------
*/
-#define CVT_APPEND_CHAR(c) \
+#define CVT_APPEND_CHAR(c) \
do { \
ENLARGE_NEWSTATEMENT(npos + 1); \
new_statement[npos++] = c; \
/*----------
* Append a binary data.
- * Newly reqeuired size may be overestimated currently.
+ * Newly reqeuired size may be overestimated currently.
*----------
*/
-#define CVT_APPEND_BINARY(buf, used) \
+#define CVT_APPEND_BINARY(buf, used) \
do { \
unsigned int newlimit = npos + 5 * used; \
ENLARGE_NEWSTATEMENT(newlimit); \
*
*----------
*/
-#define CVT_SPECIAL_CHARS(buf, used) \
+#define CVT_SPECIAL_CHARS(buf, used) \
do { \
- int cnvlen = convert_special_chars(buf, NULL, used); \
+ int cnvlen = convert_special_chars(buf, NULL, used); \
unsigned int newlimit = npos + cnvlen; \
\
ENLARGE_NEWSTATEMENT(newlimit); \
} while (0)
/*----------
- * Check if the statement is
+ * Check if the statement is
* SELECT ... INTO table FROM .....
* This isn't really a strict check but ...
- *----------
+ *----------
*/
static BOOL
into_table_from(const char *stmt)
case ',':
case '\'':
return FALSE;
- case '\"': /* double quoted table name ? */
+ case '\"': /* double quoted table name ? */
do
{
do
- {
- while (*(++stmt) != '\"' && *stmt);
- }
+ while (*(++stmt) != '\"' && *stmt);
while (*stmt && *(++stmt) == '\"');
- while (*stmt && !isspace((unsigned char) *stmt) && *stmt != '\"') stmt++;
+ while (*stmt && !isspace((unsigned char) *stmt) && *stmt != '\"')
+ stmt++;
}
while (*stmt == '\"');
break;
while (!isspace((unsigned char) *(++stmt)));
break;
}
- if (! *stmt)
+ if (!*stmt)
return FALSE;
while (isspace((unsigned char) *(++stmt)));
if (strnicmp(stmt, "from", 4))
}
/*----------
- * Check if the statement is
+ * Check if the statement is
* SELECT ... FOR UPDATE .....
* This isn't really a strict check but ...
- *----------
+ *----------
*/
static BOOL
table_for_update(const char *stmt, int *endpos)
{
const char *wstmt = stmt;
+
while (isspace((unsigned char) *(++wstmt)));
- if (! *wstmt)
+ if (!*wstmt)
return FALSE;
if (strnicmp(wstmt, "update", 6))
return FALSE;
* This function does a dynamic memory allocation to get rid of query size limit!
*/
int
-copy_statement_with_parameters(StatementClass *stmt)
+copy_statement_with_parameters(StatementClass * stmt)
{
static char *func = "copy_statement_with_parameters";
unsigned int opos,
oldstmtlen;
char param_string[128],
tmp[256],
- cbuf[PG_NUMERIC_MAX_PRECISION * 2]; /* seems big enough to handle the data in this function */
+ cbuf[PG_NUMERIC_MAX_PRECISION * 2]; /* seems big enough to
+ * handle the data in
+ * this function */
int param_number;
Int2 param_ctype,
param_sqltype;
- char *old_statement = stmt->statement, oldchar;
+ char *old_statement = stmt->statement,
+ oldchar;
char *new_statement = stmt->stmt_with_params;
- unsigned int new_stsize = 0;
+ unsigned int new_stsize = 0;
SIMPLE_TIME st;
time_t t = time(NULL);
struct tm *tim;
SDWORD used;
- char *buffer, *buf;
- BOOL in_quote = FALSE, in_dquote = FALSE, in_escape = FALSE;
+ char *buffer,
+ *buf;
+ BOOL in_quote = FALSE,
+ in_dquote = FALSE,
+ in_escape = FALSE;
Oid lobj_oid;
int lobj_fd,
retval;
- BOOL check_cursor_ok = FALSE; /* check cursor restriction */
- BOOL proc_no_param = TRUE;
- unsigned int declare_pos = 0;
- ConnectionClass *conn = SC_get_conn(stmt);
- ConnInfo *ci = &(conn->connInfo);
- BOOL prepare_dummy_cursor = FALSE, begin_first = FALSE;
- char token_save[64];
- int token_len;
- BOOL prev_token_end;
+ BOOL check_cursor_ok = FALSE; /* check cursor
+ * restriction */
+ BOOL proc_no_param = TRUE;
+ unsigned int declare_pos = 0;
+ ConnectionClass *conn = SC_get_conn(stmt);
+ ConnInfo *ci = &(conn->connInfo);
+ BOOL prepare_dummy_cursor = FALSE,
+ begin_first = FALSE;
+ char token_save[64];
+ int token_len;
+ BOOL prev_token_end;
+
#ifdef DRIVER_CURSOR_IMPLEMENT
- BOOL search_from_pos = FALSE;
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+ BOOL search_from_pos = FALSE;
+#endif /* DRIVER_CURSOR_IMPLEMENT */
if (ci->disallow_premature)
prepare_dummy_cursor = stmt->pre_executing;
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
}
else if (stmt->options.cursor_type == SQL_CURSOR_FORWARD_ONLY)
- stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
+ stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
else if (stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY)
{
if (stmt->parse_status == STMT_PARSE_NONE)
if (stmt->parse_status != STMT_PARSE_COMPLETE)
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
else if (!stmt->ti || stmt->ntab != 1)
- stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
+ stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
else
search_from_pos = TRUE;
}
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+#endif /* DRIVER_CURSOR_IMPLEMENT */
/* If the application hasn't set a cursor name, then generate one */
if (stmt->cursor_name[0] == '\0')
else if (ci->drivers.use_declarefetch)
SC_set_fetchcursor(stmt);
sprintf(new_statement, "%sdeclare %s cursor for ",
- new_statement, stmt->cursor_name);
+ new_statement, stmt->cursor_name);
npos = strlen(new_statement);
check_cursor_ok = TRUE;
declare_pos = npos;
CVT_APPEND_CHAR(oldchar);
continue;
}
+
/*
- * From here we are guaranteed to handle a
- * 1-byte character.
+ * From here we are guaranteed to handle a 1-byte character.
*/
#endif
- if (in_escape) /* escape check */
+ if (in_escape) /* escape check */
{
in_escape = FALSE;
CVT_APPEND_CHAR(oldchar);
continue;
- }
+ }
else if (in_quote || in_dquote) /* quote/double quote check */
{
if (oldchar == '\\')
else if (oldchar == '\"' && in_dquote)
in_dquote = FALSE;
CVT_APPEND_CHAR(oldchar);
- continue;
+ continue;
}
+
/*
- * From here we are guranteed to be in neither
- * an escape, a quote nor a double quote.
+ * From here we are guranteed to be in neither an escape, a quote
+ * nor a double quote.
*/
/* Squeeze carriage-return/linefeed pairs to linefeed only */
else if (oldchar == '\r' && opos + 1 < oldstmtlen &&
- old_statement[opos + 1] == '\n')
+ old_statement[opos + 1] == '\n')
continue;
+
/*
* Handle literals (date, time, timestamp) and ODBC scalar
* functions
#else
char *end = strchr(begin, '}');
-
#endif
if (!end)
/* procedure calls */
if (stmt->statement_type == STMT_TYPE_PROCCALL)
{
- int lit_call_len = 4;
+ int lit_call_len = 4;
+
while (isspace((unsigned char) old_statement[++opos]));
/* '=?' to accept return values exists ? */
if (old_statement[opos] == '?')
opos--;
continue;
}
- opos += lit_call_len;
+ opos += lit_call_len;
CVT_APPEND_STR("SELECT ");
#ifdef MULTIBYTE
if (multibyte_strchr(&old_statement[opos], '('))
#else
if (strchr(&old_statement[opos], '('))
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
proc_no_param = FALSE;
- continue;
+ continue;
}
*end = '\0';
esc = convert_escape(begin);
if (esc)
- {
CVT_APPEND_STR(esc);
- }
else
{ /* it's not a valid literal so just copy */
*end = '}';
in_escape = TRUE;
else if (oldchar == '\"')
in_dquote = TRUE;
- else
+ else
{
if (isspace(oldchar))
{
if (token_len == 4)
{
if (check_cursor_ok &&
- into_table_from(&old_statement[opos - token_len]))
+ into_table_from(&old_statement[opos - token_len]))
{
stmt->statement_type = STMT_TYPE_CREATE;
SC_no_pre_executable(stmt);
}
#ifdef DRIVER_CURSOR_IMPLEMENT
else if (search_from_pos && /* where's from clause */
- strnicmp(token_save, "from", 4) == 0)
+ strnicmp(token_save, "from", 4) == 0)
{
search_from_pos = FALSE;
npos -= 5;
CVT_APPEND_STR(", CTID, OID from");
}
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+#endif /* DRIVER_CURSOR_IMPLEMENT */
}
if (token_len == 3)
{
- int endpos;
+ int endpos;
+
if (check_cursor_ok &&
- strnicmp(token_save, "for", 3) == 0 &&
- table_for_update(&old_statement[opos], &endpos))
+ strnicmp(token_save, "for", 3) == 0 &&
+ table_for_update(&old_statement[opos], &endpos))
{
SC_no_fetchcursor(stmt);
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
}
}
}
- }
+ }
}
else if (prev_token_end)
{
}
else if (token_len + 1 < sizeof(token_save))
token_save[token_len++] = oldchar;
- }
+ }
CVT_APPEND_CHAR(oldchar);
continue;
}
}
else
{
-
-
+
+
used = stmt->parameters[param_number].used ? *stmt->parameters[param_number].used : SQL_NTS;
-
+
buffer = stmt->parameters[param_number].buffer;
}
/* it was a SQL_C_CHAR */
if (buf)
- {
CVT_SPECIAL_CHARS(buf, used);
- }
/* it was a numeric type */
else if (param_string[0] != '\0')
- {
CVT_APPEND_STR(param_string);
- }
/* it was date,time,timestamp -- use m,d,y,hh,mm,ss */
else
int length = strlen(new_statement);
conn->DriverToDataSource(conn->translation_option,
- SQL_CHAR,
- new_statement, length,
- new_statement, length, NULL,
- NULL, 0, NULL);
+ SQL_CHAR,
+ new_statement, length,
+ new_statement, length, NULL,
+ NULL, 0, NULL);
}
#ifdef DRIVER_CURSOR_IMPLEMENT
if (search_from_pos)
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+#endif /* DRIVER_CURSOR_IMPLEMENT */
if (prepare_dummy_cursor && SC_is_pre_executable(stmt))
{
- char fetchstr[128];
+ char fetchstr[128];
+
sprintf(fetchstr, ";fetch backward in %s;close %s;",
stmt->cursor_name, stmt->cursor_name);
if (begin_first && CC_is_in_autocommit(conn))
}
else if (strcmp(key, "fn") == 0)
{
-
/*
* Function invocation Separate off the func name, skipping
* trailing whitespace.
mapFunc = mapFunction(key);
/*
- * We could have mapFunction() return key if not in table...
- * - thomas 2000-04-03
+ * We could have mapFunction() return key if not in table... -
+ * thomas 2000-04-03
*/
if (mapFunc == NULL)
{
BOOL
convert_money(const char *s, char *sout, size_t soutmax)
{
- size_t i = 0, out = 0;
+ size_t i = 0,
+ out = 0;
for (i = 0; s[i]; i++)
{
else
{
if (out + 1 >= soutmax)
- return FALSE; /* sout is too short */
+ return FALSE; /* sout is too short */
if (s[i] == '(')
sout[out++] = '-';
else
* It does not zero out SIMPLE_TIME in case it is desired to initialize it with a value
*/
char
-parse_datetime(char *buf, SIMPLE_TIME *st)
+parse_datetime(char *buf, SIMPLE_TIME * st)
{
int y,
m,
/* Change linefeed to carriage-return/linefeed */
int
-convert_linefeeds(const char *si, char *dst, size_t max, BOOL *changed)
+convert_linefeeds(const char *si, char *dst, size_t max, BOOL * changed)
{
size_t i = 0,
out = 0;
int
convert_from_pgbinary(const unsigned char *value, unsigned char *rgbValue, int cbValueMax)
{
- size_t i, ilen = strlen(value);
+ size_t i,
+ ilen = strlen(value);
int o = 0;
void
encode(const char *in, char *out)
{
- unsigned int i, ilen = strlen(in),
+ unsigned int i,
+ ilen = strlen(in),
o = 0;
for (i = 0; i < ilen; i++)
void
decode(const char *in, char *out)
{
- unsigned int i, ilen = strlen(in),
+ unsigned int i,
+ ilen = strlen(in),
o = 0;
for (i = 0; i < ilen; i++)
*-------
*/
int
-convert_lo(StatementClass *stmt, const void *value, Int2 fCType, PTR rgbValue,
- SDWORD cbValueMax, SDWORD *pcbValue)
+convert_lo(StatementClass * stmt, const void *value, Int2 fCType, PTR rgbValue,
+ SDWORD cbValueMax, SDWORD * pcbValue)
{
Oid oid;
int retval,
result,
left = -1;
BindInfoClass *bindInfo = NULL;
- ConnectionClass *conn = SC_get_conn(stmt);
- ConnInfo *ci = &(conn->connInfo);
+ ConnectionClass *conn = SC_get_conn(stmt);
+ ConnInfo *ci = &(conn->connInfo);
/* If using SQLGetData, then current_col will be set */
if (stmt->current_col >= 0)
int hh;
int mm;
int ss;
-} SIMPLE_TIME;
+} SIMPLE_TIME;
-int copy_and_convert_field_bindinfo(StatementClass *stmt, Int4 field_type, void *value, int col);
-int copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 fCType,
- PTR rgbValue, SDWORD cbValueMax, SDWORD *pcbValue);
+int copy_and_convert_field_bindinfo(StatementClass * stmt, Int4 field_type, void *value, int col);
+int copy_and_convert_field(StatementClass * stmt, Int4 field_type, void *value, Int2 fCType,
+ PTR rgbValue, SDWORD cbValueMax, SDWORD * pcbValue);
-int copy_statement_with_parameters(StatementClass *stmt);
+int copy_statement_with_parameters(StatementClass * stmt);
char *convert_escape(char *value);
-BOOL convert_money(const char *s, char *sout, size_t soutmax);
-char parse_datetime(char *buf, SIMPLE_TIME *st);
-int convert_linefeeds(const char *s, char *dst, size_t max, BOOL *changed);
-int convert_special_chars(const char *si, char *dst, int used);
+BOOL convert_money(const char *s, char *sout, size_t soutmax);
+char parse_datetime(char *buf, SIMPLE_TIME * st);
+int convert_linefeeds(const char *s, char *dst, size_t max, BOOL * changed);
+int convert_special_chars(const char *si, char *dst, int used);
int convert_pgbinary_to_char(const char *value, char *rgbValue, int cbValueMax);
int convert_from_pgbinary(const unsigned char *value, unsigned char *rgbValue, int cbValueMax);
int convert_to_pgbinary(const unsigned char *in, char *out, int len);
void encode(const char *in, char *out);
void decode(const char *in, char *out);
-int convert_lo(StatementClass *stmt, const void *value, Int2 fCType, PTR rgbValue,
- SDWORD cbValueMax, SDWORD *pcbValue);
-
+int convert_lo(StatementClass * stmt, const void *value, Int2 fCType, PTR rgbValue,
+ SDWORD cbValueMax, SDWORD * pcbValue);
#endif
#endif
extern GLOBAL_VALUES globals;
+
#ifdef WIN32
-static int driver_optionsDraw(HWND, const ConnInfo *, int src, BOOL enable);
-static int driver_options_update(HWND hdlg, ConnInfo *ci, BOOL);
-static void updateCommons(const ConnInfo *ci);
+static int driver_optionsDraw(HWND, const ConnInfo *, int src, BOOL enable);
+static int driver_options_update(HWND hdlg, ConnInfo * ci, BOOL);
+static void updateCommons(const ConnInfo * ci);
#endif
#ifdef WIN32
void
-SetDlgStuff(HWND hdlg, const ConnInfo *ci)
+SetDlgStuff(HWND hdlg, const ConnInfo * ci)
{
-
/*
* If driver attribute NOT present, then set the datasource name and
* description
void
-GetDlgStuff(HWND hdlg, ConnInfo *ci)
+GetDlgStuff(HWND hdlg, ConnInfo * ci)
{
GetDlgItemText(hdlg, IDC_DESC, ci->desc, sizeof(ci->desc));
static int
-driver_optionsDraw(HWND hdlg, const ConnInfo *ci, int src, BOOL enable)
+driver_optionsDraw(HWND hdlg, const ConnInfo * ci, int src, BOOL enable)
{
- const GLOBAL_VALUES *comval;
- static BOOL defset = FALSE;
- static GLOBAL_VALUES defval;
-
+ const GLOBAL_VALUES *comval;
+ static BOOL defset = FALSE;
+ static GLOBAL_VALUES defval;
+
switch (src)
{
- case 0: /* driver common */
+ case 0: /* driver common */
comval = &globals;
break;
- case 1: /* dsn specific */
+ case 1: /* dsn specific */
comval = &(ci->drivers);
break;
- case 2: /* default */
+ case 2: /* default */
if (!defset)
{
defval.commlog = DEFAULT_COMMLOG;
return 0;
}
static int
-driver_options_update(HWND hdlg, ConnInfo *ci, BOOL updateProfile)
+driver_options_update(HWND hdlg, ConnInfo * ci, BOOL updateProfile)
{
- GLOBAL_VALUES *comval;
+ GLOBAL_VALUES *comval;
if (ci)
comval = &(ci->drivers);
comval->fetch_max = GetDlgItemInt(hdlg, DRV_CACHE_SIZE, NULL, FALSE);
comval->max_varchar_size = GetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, NULL, FALSE);
comval->max_longvarchar_size = GetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, NULL, TRUE); /* allows for
- * SQL_NO_TOTAL */
+ * SQL_NO_TOTAL */
GetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, sizeof(comval->extra_systable_prefixes));
WPARAM wParam,
LPARAM lParam)
{
- ConnInfo *ci;
+ ConnInfo *ci;
+
switch (wMsg)
{
case WM_INITDIALOG:
- SetWindowLong(hdlg, DWL_USER, lParam); /* save for OK etc */
+ SetWindowLong(hdlg, DWL_USER, lParam); /* save for OK etc */
ci = (ConnInfo *) lParam;
CheckDlgButton(hdlg, DRV_OR_DSN, 0);
if (ci && ci->dsn && ci->dsn[0])
- {
SetWindowText(hdlg, "Advanced Options (per DSN)");
- }
else
{
SetWindowText(hdlg, "Advanced Options (Connection)");
case IDOK:
ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
driver_options_update(hdlg, IsDlgButtonChecked(hdlg, DRV_OR_DSN) ? NULL : ci,
- ci && ci->dsn && ci->dsn[0]);
+ ci && ci->dsn && ci->dsn[0]);
case IDCANCEL:
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
else
{
ConnInfo *ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
+
driver_optionsDraw(hdlg, ci, 0, FALSE);
}
break;
else
{
ConnInfo *ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
+
SetWindowText(hdlg, "Advanced Options (per DSN)");
driver_optionsDraw(hdlg, ci, ci ? 1 : 0, ci == NULL);
}
* to the ODBCINST.INI portion of the registry
*/
static void
-updateCommons(const ConnInfo *ci)
+updateCommons(const ConnInfo * ci)
{
- const char *sectionName;
- const char *fileName;
- const GLOBAL_VALUES *comval;
+ const char *sectionName;
+ const char *fileName;
+ const GLOBAL_VALUES *comval;
char tmp[128];
if (ci)
{
mylog("ci but dsn==NULL\n");
return;
- }
+ }
else
{
mylog("drivers updating\n");
SQLWritePrivateProfileString(sectionName,
INI_KSQO, tmp, fileName);
- /* Never update the onlyread, unique_index from this module
- sprintf(tmp, "%d", comval->unique_index);
- SQLWritePrivateProfileString(sectionName,
- INI_UNIQUEINDEX, tmp, fileName);
-
- sprintf(tmp, "%d", comval->onlyread);
- SQLWritePrivateProfileString(sectionName,
- INI_READONLY, tmp, fileName);*/
+ /*
+ * Never update the onlyread, unique_index from this module
+ * sprintf(tmp, "%d", comval->unique_index);
+ * SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp,
+ * fileName);
+ *
+ * sprintf(tmp, "%d", comval->onlyread);
+ * SQLWritePrivateProfileString(sectionName, INI_READONLY, tmp,
+ * fileName);
+ */
sprintf(tmp, "%d", comval->use_declarefetch);
SQLWritePrivateProfileString(sectionName,
sprintf(tmp, "%d", comval->text_as_longvarchar);
SQLWritePrivateProfileString(sectionName,
- INI_TEXTASLONGVARCHAR, tmp, fileName);
+ INI_TEXTASLONGVARCHAR, tmp, fileName);
sprintf(tmp, "%d", comval->unknowns_as_longvarchar);
SQLWritePrivateProfileString(sectionName,
- INI_UNKNOWNSASLONGVARCHAR, tmp, fileName);
+ INI_UNKNOWNSASLONGVARCHAR, tmp, fileName);
sprintf(tmp, "%d", comval->bools_as_char);
SQLWritePrivateProfileString(sectionName,
sprintf(tmp, "%d", comval->max_longvarchar_size);
SQLWritePrivateProfileString(sectionName,
- INI_MAXLONGVARCHARSIZE, tmp, fileName);
+ INI_MAXLONGVARCHARSIZE, tmp, fileName);
SQLWritePrivateProfileString(sectionName,
- INI_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, fileName);
+ INI_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, fileName);
- /* Never update the conn_setting from this module
- SQLWritePrivateProfileString(sectionName,
- INI_CONNSETTINGS, comval->conn_settings, fileName); */
+ /*
+ * Never update the conn_setting from this module
+ * SQLWritePrivateProfileString(sectionName, INI_CONNSETTINGS,
+ * comval->conn_settings, fileName);
+ */
}
#endif /* WIN32 */
void
-makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len)
+makeConnectString(char *connect_string, const ConnInfo * ci, UWORD len)
{
char got_dsn = (ci->dsn[0] != '\0');
char encoded_conn_settings[LARGE_REGISTRY_LEN];
hlen = strlen(connect_string);
if (!abbrev)
sprintf(&connect_string[hlen],
- ";READONLY=%s;PROTOCOL=%s;FAKEOIDINDEX=%s;SHOWOIDCOLUMN=%s;ROWVERSIONING=%s;SHOWSYSTEMTABLES=%s;CONNSETTINGS=%s;FETCH=%d;SOCKET=%d;UNKNOWNSIZES=%d;MAXVARCHARSIZE=%d;MAXLONGVARCHARSIZE=%d;DEBUG=%d;COMMLOG=%d;OPTIMIZER=%d;KSQO=%d;USEDECLAREFETCH=%d;TEXTASLONGVARCHAR=%d;UNKNOWNSASLONGVARCHAR=%d;BOOLSASCHAR=%d;PARSE=%d;CANCELASFREESTMT=%d;EXTRASYSTABLEPREFIXES=%s",
- ci->onlyread,
- ci->protocol,
- ci->fake_oid_index,
- ci->show_oid_column,
- ci->row_versioning,
- ci->show_system_tables,
- encoded_conn_settings,
- ci->drivers.fetch_max,
- ci->drivers.socket_buffersize,
- ci->drivers.unknown_sizes,
- ci->drivers.max_varchar_size,
- ci->drivers.max_longvarchar_size,
- ci->drivers.debug,
- ci->drivers.commlog,
- ci->drivers.disable_optimizer,
- ci->drivers.ksqo,
- ci->drivers.use_declarefetch,
- ci->drivers.text_as_longvarchar,
- ci->drivers.unknowns_as_longvarchar,
- ci->drivers.bools_as_char,
- ci->drivers.parse,
- ci->drivers.cancel_as_freestmt,
- ci->drivers.extra_systable_prefixes);
+ ";READONLY=%s;PROTOCOL=%s;FAKEOIDINDEX=%s;SHOWOIDCOLUMN=%s;ROWVERSIONING=%s;SHOWSYSTEMTABLES=%s;CONNSETTINGS=%s;FETCH=%d;SOCKET=%d;UNKNOWNSIZES=%d;MAXVARCHARSIZE=%d;MAXLONGVARCHARSIZE=%d;DEBUG=%d;COMMLOG=%d;OPTIMIZER=%d;KSQO=%d;USEDECLAREFETCH=%d;TEXTASLONGVARCHAR=%d;UNKNOWNSASLONGVARCHAR=%d;BOOLSASCHAR=%d;PARSE=%d;CANCELASFREESTMT=%d;EXTRASYSTABLEPREFIXES=%s",
+ ci->onlyread,
+ ci->protocol,
+ ci->fake_oid_index,
+ ci->show_oid_column,
+ ci->row_versioning,
+ ci->show_system_tables,
+ encoded_conn_settings,
+ ci->drivers.fetch_max,
+ ci->drivers.socket_buffersize,
+ ci->drivers.unknown_sizes,
+ ci->drivers.max_varchar_size,
+ ci->drivers.max_longvarchar_size,
+ ci->drivers.debug,
+ ci->drivers.commlog,
+ ci->drivers.disable_optimizer,
+ ci->drivers.ksqo,
+ ci->drivers.use_declarefetch,
+ ci->drivers.text_as_longvarchar,
+ ci->drivers.unknowns_as_longvarchar,
+ ci->drivers.bools_as_char,
+ ci->drivers.parse,
+ ci->drivers.cancel_as_freestmt,
+ ci->drivers.extra_systable_prefixes);
/* Abbrebiation is needed ? */
if (abbrev || strlen(connect_string) >= len)
sprintf(&connect_string[hlen],
- ";A0=%s;A1=%s;A2=%s;A3=%s;A4=%s;A5=%s;A6=%s;A7=%d;A8=%d;A9=%d;B0=%d;B1=%d;B2=%d;B3=%d;B4=%d;B5=%d;B6=%d;B7=%d;B8=%d;B9=%d;C0=%d;C1=%d;C2=%s",
- ci->onlyread,
- ci->protocol,
- ci->fake_oid_index,
- ci->show_oid_column,
- ci->row_versioning,
- ci->show_system_tables,
- encoded_conn_settings,
- ci->drivers.fetch_max,
- ci->drivers.socket_buffersize,
- ci->drivers.unknown_sizes,
- ci->drivers.max_varchar_size,
- ci->drivers.max_longvarchar_size,
- ci->drivers.debug,
- ci->drivers.commlog,
- ci->drivers.disable_optimizer,
- ci->drivers.ksqo,
- ci->drivers.use_declarefetch,
- ci->drivers.text_as_longvarchar,
- ci->drivers.unknowns_as_longvarchar,
- ci->drivers.bools_as_char,
- ci->drivers.parse,
- ci->drivers.cancel_as_freestmt,
- ci->drivers.extra_systable_prefixes);
+ ";A0=%s;A1=%s;A2=%s;A3=%s;A4=%s;A5=%s;A6=%s;A7=%d;A8=%d;A9=%d;B0=%d;B1=%d;B2=%d;B3=%d;B4=%d;B5=%d;B6=%d;B7=%d;B8=%d;B9=%d;C0=%d;C1=%d;C2=%s",
+ ci->onlyread,
+ ci->protocol,
+ ci->fake_oid_index,
+ ci->show_oid_column,
+ ci->row_versioning,
+ ci->show_system_tables,
+ encoded_conn_settings,
+ ci->drivers.fetch_max,
+ ci->drivers.socket_buffersize,
+ ci->drivers.unknown_sizes,
+ ci->drivers.max_varchar_size,
+ ci->drivers.max_longvarchar_size,
+ ci->drivers.debug,
+ ci->drivers.commlog,
+ ci->drivers.disable_optimizer,
+ ci->drivers.ksqo,
+ ci->drivers.use_declarefetch,
+ ci->drivers.text_as_longvarchar,
+ ci->drivers.unknowns_as_longvarchar,
+ ci->drivers.bools_as_char,
+ ci->drivers.parse,
+ ci->drivers.cancel_as_freestmt,
+ ci->drivers.extra_systable_prefixes);
}
void
-copyAttributes(ConnInfo *ci, const char *attribute, const char *value)
+copyAttributes(ConnInfo * ci, const char *attribute, const char *value)
{
if (stricmp(attribute, "DSN") == 0)
strcpy(ci->dsn, value);
/* strcpy(ci->conn_settings, value); */
}
else if (stricmp(attribute, INI_DISALLOWPREMATURE) == 0 || stricmp(attribute, "C3") == 0)
- {
ci->disallow_premature = atoi(value);
- }
else if (stricmp(attribute, INI_UPDATABLECURSORS) == 0 || stricmp(attribute, "C4") == 0)
- {
ci->updatable_cursors = atoi(value);
- }
mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',onlyread='%s',protocol='%s',conn_settings='%s',disallow_premature=%d)\n", ci->dsn, ci->server, ci->database, ci->username, ci->password, ci->port, ci->onlyread, ci->protocol, ci->conn_settings, ci->disallow_premature);
}
void
-copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value)
+copyCommonAttributes(ConnInfo * ci, const char *attribute, const char *value)
{
if (stricmp(attribute, INI_FETCH) == 0 || stricmp(attribute, "A7") == 0)
ci->drivers.fetch_max = atoi(value);
ci->drivers.disable_optimizer = atoi(value);
else if (stricmp(attribute, INI_KSQO) == 0 || stricmp(attribute, "B5") == 0)
ci->drivers.ksqo = atoi(value);
+
/*
- else if (stricmp(attribute, INI_UNIQUEINDEX) == 0 || stricmp(attribute, "UIX") == 0)
- ci->drivers.unique_index = atoi(value);
- */
+ * else if (stricmp(attribute, INI_UNIQUEINDEX) == 0 ||
+ * stricmp(attribute, "UIX") == 0) ci->drivers.unique_index =
+ * atoi(value);
+ */
else if (stricmp(attribute, INI_UNKNOWNSIZES) == 0 || stricmp(attribute, "A9") == 0)
ci->drivers.unknown_sizes = atoi(value);
else if (stricmp(attribute, INI_LIE) == 0)
else if (stricmp(attribute, INI_EXTRASYSTABLEPREFIXES) == 0 || stricmp(attribute, "C2") == 0)
strcpy(ci->drivers.extra_systable_prefixes, value);
mylog("CopyCommonAttributes: A7=%d;A8=%d;A9=%d;B0=%d;B1=%d;B2=%d;B3=%d;B4=%d;B5=%d;B6=%d;B7=%d;B8=%d;B9=%d;C0=%d;C1=%d;C2=%s",
- ci->drivers.fetch_max,
- ci->drivers.socket_buffersize,
- ci->drivers.unknown_sizes,
- ci->drivers.max_varchar_size,
- ci->drivers.max_longvarchar_size,
- ci->drivers.debug,
- ci->drivers.commlog,
- ci->drivers.disable_optimizer,
- ci->drivers.ksqo,
- ci->drivers.use_declarefetch,
- ci->drivers.text_as_longvarchar,
- ci->drivers.unknowns_as_longvarchar,
- ci->drivers.bools_as_char,
- ci->drivers.parse,
- ci->drivers.cancel_as_freestmt,
- ci->drivers.extra_systable_prefixes);
+ ci->drivers.fetch_max,
+ ci->drivers.socket_buffersize,
+ ci->drivers.unknown_sizes,
+ ci->drivers.max_varchar_size,
+ ci->drivers.max_longvarchar_size,
+ ci->drivers.debug,
+ ci->drivers.commlog,
+ ci->drivers.disable_optimizer,
+ ci->drivers.ksqo,
+ ci->drivers.use_declarefetch,
+ ci->drivers.text_as_longvarchar,
+ ci->drivers.unknowns_as_longvarchar,
+ ci->drivers.bools_as_char,
+ ci->drivers.parse,
+ ci->drivers.cancel_as_freestmt,
+ ci->drivers.extra_systable_prefixes);
}
void
-getDSNdefaults(ConnInfo *ci)
+getDSNdefaults(ConnInfo * ci)
{
if (ci->port[0] == '\0')
strcpy(ci->port, DEFAULT_PORT);
void
-getDSNinfo(ConnInfo *ci, char overwrite)
+getDSNinfo(ConnInfo * ci, char overwrite)
{
char *DSN = ci->dsn;
char encoded_conn_settings[LARGE_REGISTRY_LEN],
- temp[SMALL_REGISTRY_LEN];
+ temp[SMALL_REGISTRY_LEN];
/*
* If a driver keyword was present, then dont use a DSN and return.
/* This is for datasource based options only */
void
-writeDSNinfo(const ConnInfo *ci)
+writeDSNinfo(const ConnInfo * ci)
{
- const char *DSN = ci->dsn;
+ const char *DSN = ci->dsn;
char encoded_conn_settings[LARGE_REGISTRY_LEN],
- temp[SMALL_REGISTRY_LEN];
+ temp[SMALL_REGISTRY_LEN];
encode(ci->conn_settings, encoded_conn_settings);
encoded_conn_settings,
ODBC_INI);
- sprintf(temp, "%d", ci->disallow_premature);
+ sprintf(temp, "%d", ci->disallow_premature);
SQLWritePrivateProfileString(DSN,
INI_DISALLOWPREMATURE,
temp,
ODBC_INI);
- sprintf(temp, "%d", ci->updatable_cursors);
+ sprintf(temp, "%d", ci->updatable_cursors);
SQLWritePrivateProfileString(DSN,
INI_UPDATABLECURSORS,
temp,
* the registry and gets any driver defaults.
*/
void
-getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
+getCommonDefaults(const char *section, const char *filename, ConnInfo * ci)
{
char temp[256];
- GLOBAL_VALUES *comval;
+ GLOBAL_VALUES *comval;
if (ci)
comval = &(ci->drivers);
/* Dont allow override of an override! */
if (!ci)
{
-
/*
* ConnSettings is stored in the driver section and per datasource
* for override
*/
SQLGetPrivateProfileString(section, INI_CONNSETTINGS, "",
- comval->conn_settings, sizeof(comval->conn_settings), filename);
+ comval->conn_settings, sizeof(comval->conn_settings), filename);
/* Default state for future DSN's Readonly attribute */
SQLGetPrivateProfileString(section, INI_READONLY, "",
#define DEFAULT_EXTRASYSTABLEPREFIXES "dd_;"
/* prototypes */
-void getCommonDefaults(const char *section, const char *filename, ConnInfo *ci);
+void getCommonDefaults(const char *section, const char *filename, ConnInfo * ci);
#ifdef WIN32
-void SetDlgStuff(HWND hdlg, const ConnInfo *ci);
-void GetDlgStuff(HWND hdlg, ConnInfo *ci);
+void SetDlgStuff(HWND hdlg, const ConnInfo * ci);
+void GetDlgStuff(HWND hdlg, ConnInfo * ci);
int CALLBACK driver_optionsProc(HWND hdlg,
WORD wMsg,
WORD wMsg,
WPARAM wParam,
LPARAM lParam);
-
#endif /* WIN32 */
void updateGlobals(void);
-void writeDSNinfo(const ConnInfo *ci);
-void getDSNdefaults(ConnInfo *ci);
-void getDSNinfo(ConnInfo *ci, char overwrite);
-void makeConnectString(char *connect_string, const ConnInfo *ci, UWORD);
-void copyAttributes(ConnInfo *ci, const char *attribute, const char *value);
-void copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value);
-
+void writeDSNinfo(const ConnInfo * ci);
+void getDSNdefaults(ConnInfo * ci);
+void getDSNinfo(ConnInfo * ci, char overwrite);
+void makeConnectString(char *connect_string, const ConnInfo * ci, UWORD);
+void copyAttributes(ConnInfo * ci, const char *attribute, const char *value);
+void copyCommonAttributes(ConnInfo * ci, const char *attribute, const char *value);
#endif
#include "dlg_specific.h"
/* prototypes */
-void dconn_get_connect_attributes(const UCHAR FAR *connect_string, ConnInfo *ci);
-static void dconn_get_common_attributes(const UCHAR FAR *connect_string, ConnInfo *ci);
+void dconn_get_connect_attributes(const UCHAR FAR * connect_string, ConnInfo * ci);
+static void dconn_get_common_attributes(const UCHAR FAR * connect_string, ConnInfo * ci);
#ifdef WIN32
BOOL FAR PASCAL dconn_FDriverConnectProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
-RETCODE dconn_DoDialog(HWND hwnd, ConnInfo *ci);
-
-extern HINSTANCE NEAR s_hModule;/* Saved module handle. */
+RETCODE dconn_DoDialog(HWND hwnd, ConnInfo * ci);
+extern HINSTANCE NEAR s_hModule; /* Saved module handle. */
#endif
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_DriverConnect(
- HDBC hdbc,
- HWND hwnd,
- UCHAR FAR *szConnStrIn,
- SWORD cbConnStrIn,
- UCHAR FAR *szConnStrOut,
- SWORD cbConnStrOutMax,
- SWORD FAR *pcbConnStrOut,
- UWORD fDriverCompletion)
+ HDBC hdbc,
+ HWND hwnd,
+ UCHAR FAR * szConnStrIn,
+ SWORD cbConnStrIn,
+ UCHAR FAR * szConnStrOut,
+ SWORD cbConnStrOutMax,
+ SWORD FAR * pcbConnStrOut,
+ UWORD fDriverCompletion)
{
static char *func = "PGAPI_DriverConnect";
ConnectionClass *conn = (ConnectionClass *) hdbc;
#ifdef WIN32
RETCODE dialog_result;
-
#endif
RETCODE result;
char connStrIn[MAX_CONNECT_STRING];
lenStrout = cbConnStrOutMax;
if (conn->ms_jet && lenStrout > 255)
- lenStrout = 255;
+ lenStrout = 255;
makeConnectString(connStrOut, ci, lenStrout);
len = strlen(connStrOut);
if (szConnStrOut)
{
-
/*
* Return the completed string to the caller. The correct method
* is to only construct the connect string if a dialog was put up,
if (len >= cbConnStrOutMax)
{
- int clen;
+ int clen;
+
for (clen = strlen(szConnStrOut) - 1; clen >= 0 && szConnStrOut[clen] != ';'; clen--)
szConnStrOut[clen] = '\0';
result = SQL_SUCCESS_WITH_INFO;
#ifdef WIN32
RETCODE
-dconn_DoDialog(HWND hwnd, ConnInfo *ci)
+dconn_DoDialog(HWND hwnd, ConnInfo * ci)
{
int dialog_result;
case IDC_DRIVER:
ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV),
- hdlg, driver_optionsProc, (LPARAM) ci);
+ hdlg, driver_optionsProc, (LPARAM) ci);
break;
case IDC_DATASOURCE:
return FALSE;
}
-
#endif /* WIN32 */
void
-dconn_get_connect_attributes(const UCHAR FAR *connect_string, ConnInfo *ci)
+dconn_get_connect_attributes(const UCHAR FAR * connect_string, ConnInfo * ci)
{
char *our_connect_string;
char *pair,
memset(ci, 0, sizeof(ConnInfo));
#ifdef DRIVER_CURSOR_IMPLEMENT
ci->updatable_cursors = 1;
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+#endif /* DRIVER_CURSOR_IMPLEMENT */
our_connect_string = strdup(connect_string);
strtok_arg = our_connect_string;
}
static void
-dconn_get_common_attributes(const UCHAR FAR *connect_string, ConnInfo *ci)
+dconn_get_common_attributes(const UCHAR FAR * connect_string, ConnInfo * ci)
{
char *our_connect_string;
char *pair,
ConnectionClass *conns[MAX_CONNECTIONS];
-RETCODE SQL_API
-PGAPI_AllocEnv(HENV FAR *phenv)
+RETCODE SQL_API
+PGAPI_AllocEnv(HENV FAR * phenv)
{
static char *func = "PGAPI_AllocEnv";
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_FreeEnv(HENV henv)
{
static char *func = "PGAPI_FreeEnv";
/* Returns the next SQL error information. */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_Error(
- HENV henv,
- HDBC hdbc,
- HSTMT hstmt,
- UCHAR FAR *szSqlState,
- SDWORD FAR *pfNativeError,
- UCHAR FAR *szErrorMsg,
- SWORD cbErrorMsgMax,
- SWORD FAR *pcbErrorMsg)
+ HENV henv,
+ HDBC hdbc,
+ HSTMT hstmt,
+ UCHAR FAR * szSqlState,
+ SDWORD FAR * pfNativeError,
+ UCHAR FAR * szErrorMsg,
+ SWORD cbErrorMsgMax,
+ SWORD FAR * pcbErrorMsg)
{
char *msg;
int status;
- BOOL once_again = FALSE;
- SWORD msglen;
+ BOOL once_again = FALSE;
+ SWORD msglen;
mylog("**** PGAPI_Error: henv=%u, hdbc=%u, hstmt=%u <%d>\n", henv, hdbc, hstmt, cbErrorMsgMax);
strcpy(szSqlState, "07006");
break;
case STMT_INVALID_CURSOR_STATE_ERROR:
- strcpy(szSqlState, "24000");
+ strcpy(szSqlState, "24000");
break;
case STMT_OPTION_VALUE_CHANGED:
strcpy(szSqlState, "01S02");
if (once_again)
{
- int outlen;
+ int outlen;
+
stmt->errornumber = status;
if (cbErrorMsgMax > 0)
outlen = *pcbErrorMsg;
char
-EN_Destructor(EnvironmentClass *self)
+EN_Destructor(EnvironmentClass * self)
{
int lf;
char rv = 1;
mylog("exit EN_Destructor: rv = %d\n", rv);
#ifdef _MEMORY_DEBUG_
-debug_memory_inouecheck();
-#endif /* _MEMORY_DEBUG_ */
+ debug_memory_inouecheck();
+#endif /* _MEMORY_DEBUG_ */
return rv;
}
char
-EN_get_error(EnvironmentClass *self, int *number, char **message)
+EN_get_error(EnvironmentClass * self, int *number, char **message)
{
if (self && self->errormsg && self->errornumber)
{
char
-EN_add_connection(EnvironmentClass *self, ConnectionClass *conn)
+EN_add_connection(EnvironmentClass * self, ConnectionClass * conn)
{
int i;
char
-EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn)
+EN_remove_connection(EnvironmentClass * self, ConnectionClass * conn)
{
int i;
void
-EN_log_error(char *func, char *desc, EnvironmentClass *self)
+EN_log_error(char *func, char *desc, EnvironmentClass * self)
{
if (self)
qlog("ENVIRON ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->errornumber, self->errormsg);
/* Environment prototypes */
EnvironmentClass *EN_Constructor(void);
-char EN_Destructor(EnvironmentClass *self);
-char EN_get_error(EnvironmentClass *self, int *number, char **message);
-char EN_add_connection(EnvironmentClass *self, ConnectionClass *conn);
-char EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn);
-void EN_log_error(char *func, char *desc, EnvironmentClass *self);
-
+char EN_Destructor(EnvironmentClass * self);
+char EN_get_error(EnvironmentClass * self, int *number, char **message);
+char EN_add_connection(EnvironmentClass * self, ConnectionClass * conn);
+char EN_remove_connection(EnvironmentClass * self, ConnectionClass * conn);
+void EN_log_error(char *func, char *desc, EnvironmentClass * self);
#endif
/* Perform a Prepare on the SQL statement */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_Prepare(HSTMT hstmt,
- UCHAR FAR *szSqlStr,
- SDWORD cbSqlStr)
+ UCHAR FAR * szSqlStr,
+ SDWORD cbSqlStr)
{
static char *func = "PGAPI_Prepare";
StatementClass *self = (StatementClass *) hstmt;
/* Performs the equivalent of SQLPrepare, followed by SQLExecute. */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_ExecDirect(
- HSTMT hstmt,
- UCHAR FAR *szSqlStr,
- SDWORD cbSqlStr)
+ HSTMT hstmt,
+ UCHAR FAR * szSqlStr,
+ SDWORD cbSqlStr)
{
StatementClass *stmt = (StatementClass *) hstmt;
RETCODE result;
/* Execute a prepared SQL statement */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_Execute(
- HSTMT hstmt)
+ HSTMT hstmt)
{
static char *func = "PGAPI_Execute";
StatementClass *stmt = (StatementClass *) hstmt;
*/
if (!stmt->pre_executing)
{
-
/*
* The bound parameters could have possibly changed since the last
* execute of this statement? Therefore check for params and
return retval;
mylog(" stmt_with_params = '%s'\n", stmt->stmt_with_params);
+
/*
- * Get the field info for the prepared
- * query using dummy backward fetch.
+ * Get the field info for the prepared query using dummy backward
+ * fetch.
*/
if (stmt->inaccurate_result && conn->connInfo.disallow_premature)
{
if (SC_is_pre_executable(stmt))
{
- BOOL in_trans = CC_is_in_trans(conn);
- BOOL issued_begin = FALSE, begin_included = FALSE;
- QResultClass *res;
+ BOOL in_trans = CC_is_in_trans(conn);
+ BOOL issued_begin = FALSE,
+ begin_included = FALSE;
+ QResultClass *res;
if (strnicmp(stmt->stmt_with_params, "BEGIN;", 6) == 0)
begin_included = TRUE;
}
else if (!in_trans && begin_included)
CC_set_no_trans(conn);
- }
- stmt->status =STMT_FINISHED;
+ }
+ stmt->status = STMT_FINISHED;
return SQL_SUCCESS;
}
}
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_Transact(
- HENV henv,
- HDBC hdbc,
- UWORD fType)
+ HENV henv,
+ HDBC hdbc,
+ UWORD fType)
{
static char *func = "PGAPI_Transact";
extern ConnectionClass *conns[];
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_Cancel(
- HSTMT hstmt) /* Statement to cancel. */
+ HSTMT hstmt) /* Statement to cancel. */
{
static char *func = "PGAPI_Cancel";
StatementClass *stmt = (StatementClass *) hstmt;
RETCODE result;
- ConnInfo *ci;
+ ConnInfo *ci;
#ifdef WIN32
HMODULE hmodule;
FARPROC addr;
-
#endif
mylog("%s: entering...\n", func);
*/
if (stmt->data_at_exec < 0)
{
-
/*
* MAJOR HACK for Windows to reset the driver manager's cursor
* state: Because of what seems like a bug in the Odbc driver
* Currently, just copy the input string without modification
* observing buffer limits and truncation.
*/
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_NativeSql(
- HDBC hdbc,
- UCHAR FAR *szSqlStrIn,
- SDWORD cbSqlStrIn,
- UCHAR FAR *szSqlStr,
- SDWORD cbSqlStrMax,
- SDWORD FAR *pcbSqlStr)
+ HDBC hdbc,
+ UCHAR FAR * szSqlStrIn,
+ SDWORD cbSqlStrIn,
+ UCHAR FAR * szSqlStr,
+ SDWORD cbSqlStrMax,
+ SDWORD FAR * pcbSqlStr)
{
static char *func = "PGAPI_NativeSql";
int len = 0;
* Supplies parameter data at execution time.
* Used in conjuction with SQLPutData.
*/
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_ParamData(
- HSTMT hstmt,
- PTR FAR *prgbValue)
+ HSTMT hstmt,
+ PTR FAR * prgbValue)
{
static char *func = "PGAPI_ParamData";
StatementClass *stmt = (StatementClass *) hstmt;
int i,
retval;
- ConnInfo *ci;
+ ConnInfo *ci;
mylog("%s: entering...\n", func);
* Supplies parameter data at execution time.
* Used in conjunction with SQLParamData.
*/
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_PutData(
- HSTMT hstmt,
- PTR rgbValue,
- SDWORD cbValue)
+ HSTMT hstmt,
+ PTR rgbValue,
+ SDWORD cbValue)
{
static char *func = "PGAPI_PutData";
StatementClass *stmt = (StatementClass *) hstmt;
/*
* theIniFileName is searched for in:
- * $HOME/theIniFileName
- * theIniFileName
- * ODBCINSTDIR/ODBCINST_INI
+ * $HOME/theIniFileName
+ * theIniFileName
+ * ODBCINSTDIR/ODBCINST_INI
*/
DWORD
-GetPrivateProfileString(const char *theSection, /* section name */
- const char *theKey, /* search key name */
- const char *theDefault, /* default value if not
+GetPrivateProfileString(const char *theSection, /* section name */
+ const char *theKey, /* search key name */
+ const char *theDefault, /* default value if not
* found */
char *theReturnBuffer, /* return value stored
* here */
size_t theReturnBufferLength, /* byte length of return
* buffer */
- const char *theIniFileName) /* pathname of ini file to
- * search */
+ const char *theIniFileName) /* pathname of ini file
+ * to search */
{
char buf[MAXPGPATH];
char *ptr = 0;
if (ptr == NULL || (((struct passwd *) ptr)->pw_dir) == NULL || *(((struct passwd *) ptr)->pw_dir) == '\0')
ptr = "/home";
else
- ptr = ((struct passwd *) ptr)->pw_dir; /* get user home dir */
+ ptr = ((struct passwd *) ptr)->pw_dir; /* get user home dir */
/*
- * If it can't be opened because the paths are too long, then
- * skip it, don't just truncate the path string... The truncated path
- * might accidently be an existing file. The default value will be
- * returned instead.
+ * If it can't be opened because the paths are too long, then skip it,
+ * don't just truncate the path string... The truncated path might
+ * accidently be an existing file. The default value will be returned
+ * instead.
*/
if (MAXPGPATH - 1 >= strlen(ptr) + 1 + strlen(theIniFileName))
{
DWORD
WritePrivateProfileString(const char *theSection, /* section name */
- const char *theKey, /* write key name */
+ const char *theKey, /* write key name */
const char *theBuffer, /* input buffer */
- const char *theIniFileName) /* pathname of ini file to
- * write */
+ const char *theIniFileName) /* pathname of ini file
+ * to write */
{
return 0;
}
return aReturnLength > 0 ? aReturnLength - 1 : 0;
}
+#endif /* NOT_USED */
-#endif /* NOT_USED */
-
-
-#endif /* not WIN32 */
+#endif /* not WIN32 */
{
#endif
- DWORD
- GetPrivateProfileString(const char *theSection, /* section name */
- const char *theKey, /* search key name */
- const char *theDefault, /* default value if not
- * found */
+ DWORD
+ GetPrivateProfileString(const char *theSection, /* section name */
+ const char *theKey, /* search key name */
+ const char *theDefault, /* default value if not
+ * found */
char *theReturnBuffer, /* return valuse stored
* here */
size_t theBufferLength, /* byte length of return
* buffer */
- const char *theIniFileName); /* pathname of ini file
+ const char *theIniFileName); /* pathname of ini file
* to search */
- DWORD
+ DWORD
WritePrivateProfileString(const char *theSection, /* section name */
const char *theKey, /* write key name */
- const char *theBuffer, /* input buffer */
- const char *theIniFileName); /* pathname of ini file
+ const char *theBuffer, /* input buffer */
+ const char *theIniFileName); /* pathname of ini file
* to write */
#ifdef __cplusplus
}
-
#endif
#ifndef WIN32
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_GetInfo(
- HDBC hdbc,
- UWORD fInfoType,
- PTR rgbInfoValue,
- SWORD cbInfoValueMax,
- SWORD FAR *pcbInfoValue)
+ HDBC hdbc,
+ UWORD fInfoType,
+ PTR rgbInfoValue,
+ SWORD cbInfoValueMax,
+ SWORD FAR * pcbInfoValue)
{
static char *func = "PGAPI_GetInfo";
ConnectionClass *conn = (ConnectionClass *) hdbc;
#ifdef DRIVER_CURSOR_IMPLEMENT
{
static char dver[32];
+
SQLGetPrivateProfileString(DBMS_NAME,
- "DriverODBCVer", "", dver, sizeof(dver), "odbcinst.ini");
+ "DriverODBCVer", "", dver, sizeof(dver), "odbcinst.ini");
if (dver[0])
{
- int major, minor;
+ int major,
+ minor;
+
mylog("REGISTRY_ODBC_VER = %s\n", dver)
-;
+ ;
if (sscanf(dver, "%x.%x", &major, &minor) >= 2)
{
- Int2 drv_ver = (major << 8) + minor;
+ Int2 drv_ver = (major << 8) + minor;
+
if (drv_ver > ODBCVER)
{
conn->driver_version = drv_ver;
}
}
}
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+#endif /* DRIVER_CURSOR_IMPLEMENT */
break;
case SQL_DRIVER_VER: /* ODBC 1.0 */
case SQL_POSITIONED_STATEMENTS: /* ODBC 2.0 */
len = 4;
value = ci->drivers.lie ? (SQL_PS_POSITIONED_DELETE |
- SQL_PS_POSITIONED_UPDATE |
- SQL_PS_SELECT_FOR_UPDATE) : 0;
+ SQL_PS_POSITIONED_UPDATE |
+ SQL_PS_SELECT_FOR_UPDATE) : 0;
break;
case SQL_PROCEDURE_TERM: /* ODBC 1.0 */
case SQL_SCROLL_CONCURRENCY: /* ODBC 1.0 */
len = 4;
value = ci->drivers.lie ? (SQL_SCCO_READ_ONLY |
- SQL_SCCO_LOCK |
- SQL_SCCO_OPT_ROWVER |
- SQL_SCCO_OPT_VALUES) :
- (SQL_SCCO_READ_ONLY);
+ SQL_SCCO_LOCK |
+ SQL_SCCO_OPT_ROWVER |
+ SQL_SCCO_OPT_VALUES) :
+ (SQL_SCCO_READ_ONLY);
if (ci->updatable_cursors)
value |= SQL_SCCO_OPT_ROWVER;
break;
case SQL_SCROLL_OPTIONS: /* ODBC 1.0 */
len = 4;
value = ci->drivers.lie ? (SQL_SO_FORWARD_ONLY |
- SQL_SO_STATIC |
- SQL_SO_KEYSET_DRIVEN |
- SQL_SO_DYNAMIC |
- SQL_SO_MIXED)
- : (ci->drivers.use_declarefetch ? SQL_SO_FORWARD_ONLY : (SQL_SO_FORWARD_ONLY | SQL_SO_STATIC));
+ SQL_SO_STATIC |
+ SQL_SO_KEYSET_DRIVEN |
+ SQL_SO_DYNAMIC |
+ SQL_SO_MIXED)
+ : (ci->drivers.use_declarefetch ? SQL_SO_FORWARD_ONLY : (SQL_SO_FORWARD_ONLY | SQL_SO_STATIC));
if (ci->updatable_cursors)
- value |= 0; /* SQL_SO_KEYSET_DRIVEN in the furure */
+ value |= 0; /* SQL_SO_KEYSET_DRIVEN in the furure */
break;
case SQL_SEARCH_PATTERN_ESCAPE: /* ODBC 1.0 */
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_GetTypeInfo(
- HSTMT hstmt,
- SWORD fSqlType)
+ HSTMT hstmt,
+ SWORD fSqlType)
{
static char *func = "PGAPI_GetTypeInfo";
StatementClass *stmt = (StatementClass *) hstmt;
if (fSqlType == SQL_ALL_TYPES || fSqlType == sqlType)
{
- row = (TupleNode *) malloc(sizeof(TupleNode) + (15 - 1) *sizeof(TupleField));
+ row = (TupleNode *) malloc(sizeof(TupleNode) + (15 - 1) * sizeof(TupleField));
/* These values can't be NULL */
set_tuplefield_string(&row->tuple[0], pgtype_to_name(stmt, pgType));
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_GetFunctions(
- HDBC hdbc,
- UWORD fFunction,
- UWORD FAR *pfExists)
+ HDBC hdbc,
+ UWORD fFunction,
+ UWORD FAR * pfExists)
{
static char *func = "PGAPI_GetFunctions";
- ConnectionClass *conn = (ConnectionClass *)hdbc;
- ConnInfo *ci = &(conn->connInfo);
+ ConnectionClass *conn = (ConnectionClass *) hdbc;
+ ConnInfo *ci = &(conn->connInfo);
mylog("%s: entering...%u\n", func, fFunction);
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_Tables(
- HSTMT hstmt,
- UCHAR FAR *szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
- SWORD cbTableOwner,
- UCHAR FAR *szTableName,
- SWORD cbTableName,
- UCHAR FAR *szTableType,
- SWORD cbTableType)
+ HSTMT hstmt,
+ UCHAR FAR * szTableQualifier,
+ SWORD cbTableQualifier,
+ UCHAR FAR * szTableOwner,
+ SWORD cbTableOwner,
+ UCHAR FAR * szTableName,
+ SWORD cbTableName,
+ UCHAR FAR * szTableType,
+ SWORD cbTableType)
{
static char *func = "PGAPI_Tables";
StatementClass *stmt = (StatementClass *) hstmt;
}
result = PGAPI_BindCol(htbl_stmt, 1, SQL_C_CHAR,
- table_name, MAX_INFO_STRING, NULL);
+ table_name, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = tbl_stmt->errormsg;
}
result = PGAPI_BindCol(htbl_stmt, 2, SQL_C_CHAR,
- table_owner, MAX_INFO_STRING, NULL);
+ table_owner, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = tbl_stmt->errormsg;
return SQL_ERROR;
}
result = PGAPI_BindCol(htbl_stmt, 3, SQL_C_CHAR,
- relkind_or_hasrules, MAX_INFO_STRING, NULL);
+ relkind_or_hasrules, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = tbl_stmt->errormsg;
result = PGAPI_Fetch(htbl_stmt);
while ((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO))
{
-
/*
* Determine if this table name is a system table. If treating
* system tables as regular tables, then no need to do this test.
(view && show_views) ||
(regular_table && show_regular_tables))
{
- row = (TupleNode *) malloc(sizeof(TupleNode) + (5 - 1) *sizeof(TupleField));
+ row = (TupleNode *) malloc(sizeof(TupleNode) + (5 - 1) * sizeof(TupleField));
set_tuplefield_string(&row->tuple[0], "");
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_Columns(
- HSTMT hstmt,
- UCHAR FAR *szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
- SWORD cbTableOwner,
- UCHAR FAR *szTableName,
- SWORD cbTableName,
- UCHAR FAR *szColumnName,
- SWORD cbColumnName)
+ HSTMT hstmt,
+ UCHAR FAR * szTableQualifier,
+ SWORD cbTableQualifier,
+ UCHAR FAR * szTableOwner,
+ SWORD cbTableOwner,
+ UCHAR FAR * szTableName,
+ SWORD cbTableName,
+ UCHAR FAR * szColumnName,
+ SWORD cbColumnName)
{
static char *func = "PGAPI_Columns";
StatementClass *stmt = (StatementClass *) hstmt;
mylog("%s: hcol_stmt = %u, col_stmt = %u\n", func, hcol_stmt, col_stmt);
result = PGAPI_ExecDirect(hcol_stmt, columns_query,
- strlen(columns_query));
+ strlen(columns_query));
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = SC_create_errormsg(hcol_stmt);
}
result = PGAPI_BindCol(hcol_stmt, 1, SQL_C_CHAR,
- table_owner, MAX_INFO_STRING, NULL);
+ table_owner, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = col_stmt->errormsg;
}
result = PGAPI_BindCol(hcol_stmt, 2, SQL_C_CHAR,
- table_name, MAX_INFO_STRING, NULL);
+ table_name, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = col_stmt->errormsg;
}
result = PGAPI_BindCol(hcol_stmt, 3, SQL_C_CHAR,
- field_name, MAX_INFO_STRING, NULL);
+ field_name, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = col_stmt->errormsg;
}
result = PGAPI_BindCol(hcol_stmt, 4, SQL_C_LONG,
- &field_type, 4, NULL);
+ &field_type, 4, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = col_stmt->errormsg;
}
result = PGAPI_BindCol(hcol_stmt, 5, SQL_C_CHAR,
- field_type_name, MAX_INFO_STRING, NULL);
+ field_type_name, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = col_stmt->errormsg;
}
result = PGAPI_BindCol(hcol_stmt, 6, SQL_C_SHORT,
- &field_number, MAX_INFO_STRING, NULL);
+ &field_number, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = col_stmt->errormsg;
}
result = PGAPI_BindCol(hcol_stmt, 7, SQL_C_LONG,
- &field_length, MAX_INFO_STRING, NULL);
+ &field_length, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = col_stmt->errormsg;
}
result = PGAPI_BindCol(hcol_stmt, 8, SQL_C_LONG,
- &mod_length, MAX_INFO_STRING, NULL);
+ &mod_length, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = col_stmt->errormsg;
}
result = PGAPI_BindCol(hcol_stmt, 9, SQL_C_CHAR,
- not_null, MAX_INFO_STRING, NULL);
+ not_null, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = col_stmt->errormsg;
}
result = PGAPI_BindCol(hcol_stmt, 10, SQL_C_CHAR,
- relhasrules, MAX_INFO_STRING, NULL);
+ relhasrules, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = col_stmt->errormsg;
/* For OID fields */
the_type = PG_TYPE_OID;
row = (TupleNode *) malloc(sizeof(TupleNode) +
- (result_cols - 1) *sizeof(TupleField));
+ (result_cols - 1) * sizeof(TupleField));
set_tuplefield_string(&row->tuple[0], "");
/* see note in SQLTables() */
while ((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO))
{
row = (TupleNode *) malloc(sizeof(TupleNode) +
- (result_cols - 1) *sizeof(TupleField));
+ (result_cols - 1) * sizeof(TupleField));
set_tuplefield_string(&row->tuple[0], "");
if (field_type == PG_TYPE_NUMERIC)
{
if (mod_length >= 4)
- mod_length -= 4;/* the length is in atttypmod - 4 */
+ mod_length -= 4; /* the length is in atttypmod - 4 */
if (mod_length >= 0)
{
useStaticPrecision = FALSE;
if (mod_length >= 4)
- mod_length -= 4;/* the length is in atttypmod - 4 */
+ mod_length -= 4; /* the length is in atttypmod - 4 */
if (mod_length > ci->drivers.max_varchar_size || mod_length <= 0)
mod_length = ci->drivers.max_varchar_size;
the_type = PG_TYPE_INT4;
row = (TupleNode *) malloc(sizeof(TupleNode) +
- (result_cols - 1) *sizeof(TupleField));
+ (result_cols - 1) * sizeof(TupleField));
set_tuplefield_string(&row->tuple[0], "");
set_tuplefield_string(&row->tuple[1], "");
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_SpecialColumns(
- HSTMT hstmt,
- UWORD fColType,
- UCHAR FAR *szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
- SWORD cbTableOwner,
- UCHAR FAR *szTableName,
- SWORD cbTableName,
- UWORD fScope,
- UWORD fNullable)
+ HSTMT hstmt,
+ UWORD fColType,
+ UCHAR FAR * szTableQualifier,
+ SWORD cbTableQualifier,
+ UCHAR FAR * szTableOwner,
+ SWORD cbTableOwner,
+ UCHAR FAR * szTableName,
+ SWORD cbTableName,
+ UWORD fScope,
+ UWORD fNullable)
{
static char *func = "PGAPI_SpecialColumns";
TupleNode *row;
mylog("%s: hcol_stmt = %u, col_stmt = %u\n", func, hcol_stmt, col_stmt);
result = PGAPI_ExecDirect(hcol_stmt, columns_query,
- strlen(columns_query));
+ strlen(columns_query));
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = SC_create_errormsg(hcol_stmt);
}
result = PGAPI_BindCol(hcol_stmt, 1, SQL_C_CHAR,
- relhasrules, MAX_INFO_STRING, NULL);
+ relhasrules, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = col_stmt->errormsg;
/* use the oid value for the rowid */
if (fColType == SQL_BEST_ROWID)
{
- row = (TupleNode *) malloc(sizeof(TupleNode) + (8 - 1) *sizeof(TupleField));
+ row = (TupleNode *) malloc(sizeof(TupleNode) + (8 - 1) * sizeof(TupleField));
set_tuplefield_int2(&row->tuple[0], SQL_SCOPE_SESSION);
set_tuplefield_string(&row->tuple[1], "oid");
if (atoi(ci->row_versioning))
{
- row = (TupleNode *) malloc(sizeof(TupleNode) + (8 - 1) *sizeof(TupleField));
+ row = (TupleNode *) malloc(sizeof(TupleNode) + (8 - 1) * sizeof(TupleField));
set_tuplefield_null(&row->tuple[0]);
set_tuplefield_string(&row->tuple[1], "xmin");
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_Statistics(
- HSTMT hstmt,
- UCHAR FAR *szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
- SWORD cbTableOwner,
- UCHAR FAR *szTableName,
- SWORD cbTableName,
- UWORD fUnique,
- UWORD fAccuracy)
+ HSTMT hstmt,
+ UCHAR FAR * szTableQualifier,
+ SWORD cbTableQualifier,
+ UCHAR FAR * szTableOwner,
+ SWORD cbTableOwner,
+ UCHAR FAR * szTableName,
+ SWORD cbTableName,
+ UWORD fUnique,
+ UWORD fAccuracy)
{
static char *func = "PGAPI_Statistics";
StatementClass *stmt = (StatementClass *) hstmt;
*/
col_stmt->internal = TRUE;
result = PGAPI_Columns(hcol_stmt, "", 0, "", 0,
- table_name, (SWORD) strlen(table_name), "", 0);
+ table_name, (SWORD) strlen(table_name), "", 0);
col_stmt->internal = FALSE;
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
goto SEEYA;
}
result = PGAPI_BindCol(hcol_stmt, 4, SQL_C_CHAR,
- column_name, MAX_INFO_STRING, &column_name_len);
+ column_name, MAX_INFO_STRING, &column_name_len);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = col_stmt->errormsg;
" and d.oid = i.indrelid"
" and i.indexrelid = c.oid"
" and c.relam = a.oid"
- , table_name);
+ ,table_name);
if (PG_VERSION_GT(SC_get_conn(stmt), 6.4))
strcat(index_query, " order by i.indisprimary desc");
/* bind the index name column */
result = PGAPI_BindCol(hindx_stmt, 1, SQL_C_CHAR,
- index_name, MAX_INFO_STRING, &index_name_len);
+ index_name, MAX_INFO_STRING, &index_name_len);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column
}
/* bind the vector column */
result = PGAPI_BindCol(hindx_stmt, 2, SQL_C_DEFAULT,
- fields_vector, 32, &fields_vector_len);
+ fields_vector, 32, &fields_vector_len);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column
}
/* bind the "is unique" column */
result = PGAPI_BindCol(hindx_stmt, 3, SQL_C_CHAR,
- isunique, sizeof(isunique), NULL);
+ isunique, sizeof(isunique), NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column
/* bind the "is clustered" column */
result = PGAPI_BindCol(hindx_stmt, 4, SQL_C_CHAR,
- isclustered, sizeof(isclustered), NULL);
+ isclustered, sizeof(isclustered), NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column
/* bind the "is hash" column */
result = PGAPI_BindCol(hindx_stmt, 5, SQL_C_CHAR,
- ishash, sizeof(ishash), NULL);
+ ishash, sizeof(ishash), NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column
}
result = PGAPI_BindCol(hindx_stmt, 6, SQL_C_CHAR,
- relhasrules, MAX_INFO_STRING, NULL);
+ relhasrules, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = indx_stmt->errormsg;
if (relhasrules[0] != '1' && atoi(ci->show_oid_column) && atoi(ci->fake_oid_index))
{
row = (TupleNode *) malloc(sizeof(TupleNode) +
- (13 - 1) *sizeof(TupleField));
+ (13 - 1) * sizeof(TupleField));
/* no table qualifier */
set_tuplefield_string(&row->tuple[0], "");
while (i < 16 && fields_vector[i] != 0)
{
row = (TupleNode *) malloc(sizeof(TupleNode) +
- (13 - 1) *sizeof(TupleField));
+ (13 - 1) * sizeof(TupleField));
/* no table qualifier */
set_tuplefield_string(&row->tuple[0], "");
* Clustered/HASH index?
*/
set_tuplefield_int2(&row->tuple[6], (Int2)
- (atoi(isclustered) ? SQL_INDEX_CLUSTERED :
- (!strncmp(ishash, "hash", 4)) ? SQL_INDEX_HASHED : SQL_INDEX_OTHER));
+ (atoi(isclustered) ? SQL_INDEX_CLUSTERED :
+ (!strncmp(ishash, "hash", 4)) ? SQL_INDEX_HASHED : SQL_INDEX_OTHER));
set_tuplefield_int2(&row->tuple[7], (Int2) (i + 1));
if (fields_vector[i] == OID_ATTNUM)
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_ColumnPrivileges(
- HSTMT hstmt,
- UCHAR FAR *szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
- SWORD cbTableOwner,
- UCHAR FAR *szTableName,
- SWORD cbTableName,
- UCHAR FAR *szColumnName,
- SWORD cbColumnName)
+ HSTMT hstmt,
+ UCHAR FAR * szTableQualifier,
+ SWORD cbTableQualifier,
+ UCHAR FAR * szTableOwner,
+ SWORD cbTableOwner,
+ UCHAR FAR * szTableName,
+ SWORD cbTableName,
+ UCHAR FAR * szColumnName,
+ SWORD cbColumnName)
{
static char *func = "PGAPI_ColumnPrivileges";
*
* Retrieve the primary key columns for the specified table.
*/
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_PrimaryKeys(
- HSTMT hstmt,
- UCHAR FAR *szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
- SWORD cbTableOwner,
- UCHAR FAR *szTableName,
- SWORD cbTableName)
+ HSTMT hstmt,
+ UCHAR FAR * szTableQualifier,
+ SWORD cbTableQualifier,
+ UCHAR FAR * szTableOwner,
+ SWORD cbTableOwner,
+ UCHAR FAR * szTableName,
+ SWORD cbTableName)
{
static char *func = "PGAPI_PrimaryKeys";
StatementClass *stmt = (StatementClass *) hstmt;
SDWORD attname_len;
char pktab[MAX_TABLE_LEN + 1];
Int2 result_cols;
- int qno, qstart, qend;
+ int qno,
+ qstart,
+ qend;
mylog("%s: entering...stmt=%u\n", func, stmt);
}
result = PGAPI_BindCol(htbl_stmt, 1, SQL_C_CHAR,
- attname, MAX_INFO_STRING, &attname_len);
+ attname, MAX_INFO_STRING, &attname_len);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = tbl_stmt->errormsg;
switch (qno)
{
case 1:
+
/*
- * Simplified query to remove assumptions about number of possible
- * index columns. Courtesy of Tom Lane - thomas 2000-03-21
- */
+ * Simplified query to remove assumptions about number of
+ * possible index columns. Courtesy of Tom Lane - thomas
+ * 2000-03-21
+ */
sprintf(tables_query, "select ta.attname, ia.attnum"
- " from pg_attribute ta, pg_attribute ia, pg_class c, pg_index i"
- " where c.relname = '%s'"
- " AND c.oid = i.indrelid"
- " AND i.indisprimary = 't'"
- " AND ia.attrelid = i.indexrelid"
- " AND ta.attrelid = i.indrelid"
- " AND ta.attnum = i.indkey[ia.attnum-1]"
- " order by ia.attnum", pktab);
+ " from pg_attribute ta, pg_attribute ia, pg_class c, pg_index i"
+ " where c.relname = '%s'"
+ " AND c.oid = i.indrelid"
+ " AND i.indisprimary = 't'"
+ " AND ia.attrelid = i.indexrelid"
+ " AND ta.attrelid = i.indrelid"
+ " AND ta.attnum = i.indkey[ia.attnum-1]"
+ " order by ia.attnum", pktab);
break;
case 2:
+
/*
- * Simplified query to search old fashoned primary key
- */
+ * Simplified query to search old fashoned primary key
+ */
sprintf(tables_query, "select ta.attname, ia.attnum"
- " from pg_attribute ta, pg_attribute ia, pg_class c, pg_index i"
- " where c.relname = '%s_pkey'"
- " AND c.oid = i.indexrelid"
- " AND ia.attrelid = i.indexrelid"
- " AND ta.attrelid = i.indrelid"
- " AND ta.attnum = i.indkey[ia.attnum-1]"
- " order by ia.attnum", pktab);
+ " from pg_attribute ta, pg_attribute ia, pg_class c, pg_index i"
+ " where c.relname = '%s_pkey'"
+ " AND c.oid = i.indexrelid"
+ " AND ia.attrelid = i.indexrelid"
+ " AND ta.attrelid = i.indrelid"
+ " AND ta.attnum = i.indkey[ia.attnum-1]"
+ " order by ia.attnum", pktab);
break;
}
mylog("%s: tables_query='%s'\n", func, tables_query);
while ((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO))
{
- row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) *sizeof(TupleField));
+ row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) * sizeof(TupleField));
set_tuplefield_null(&row->tuple[0]);
* There may be much more effective way in the
* future version. The way is very forcive currently.
*/
-static BOOL isMultibyte(const unsigned char *str)
+static BOOL
+isMultibyte(const unsigned char *str)
{
for (; *str; str++)
{
}
return FALSE;
}
-static char *getClientTableName(ConnectionClass *conn, char *serverTableName, BOOL *nameAlloced)
+static char *
+getClientTableName(ConnectionClass * conn, char *serverTableName, BOOL * nameAlloced)
{
- char query[1024], saveoid[24], *ret = serverTableName;
- BOOL continueExec = TRUE, bError = FALSE;
- QResultClass *res;
+ char query[1024],
+ saveoid[24],
+ *ret = serverTableName;
+ BOOL continueExec = TRUE,
+ bError = FALSE;
+ QResultClass *res;
*nameAlloced = FALSE;
if (!conn->client_encoding || !isMultibyte(serverTableName))
}
return ret;
}
-static char *getClientColumnName(ConnectionClass *conn, const char *serverTableName, char *serverColumnName, BOOL *nameAlloced)
+static char *
+getClientColumnName(ConnectionClass * conn, const char *serverTableName, char *serverColumnName, BOOL * nameAlloced)
{
- char query[1024], saveattrelid[24], saveattnum[16], *ret = serverColumnName;
- BOOL continueExec = TRUE, bError = FALSE;
- QResultClass *res;
+ char query[1024],
+ saveattrelid[24],
+ saveattnum[16],
+ *ret = serverColumnName;
+ BOOL continueExec = TRUE,
+ bError = FALSE;
+ QResultClass *res;
*nameAlloced = FALSE;
if (!conn->client_encoding || !isMultibyte(serverColumnName))
if (!bError && continueExec)
{
sprintf(query, "select attrelid, attnum from pg_class, pg_attribute "
- "where relname = '%s' and attrelid = pg_class.oid "
- "and attname = '%s'", serverTableName, serverColumnName);
+ "where relname = '%s' and attrelid = pg_class.oid "
+ "and attname = '%s'", serverTableName, serverColumnName);
if (res = CC_send_query(conn, query, NULL), res)
{
if (QR_get_num_tuples(res) > 0)
}
return ret;
}
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_ForeignKeys(
- HSTMT hstmt,
- UCHAR FAR *szPkTableQualifier,
- SWORD cbPkTableQualifier,
- UCHAR FAR *szPkTableOwner,
- SWORD cbPkTableOwner,
- UCHAR FAR *szPkTableName,
- SWORD cbPkTableName,
- UCHAR FAR *szFkTableQualifier,
- SWORD cbFkTableQualifier,
- UCHAR FAR *szFkTableOwner,
- SWORD cbFkTableOwner,
- UCHAR FAR *szFkTableName,
- SWORD cbFkTableName)
+ HSTMT hstmt,
+ UCHAR FAR * szPkTableQualifier,
+ SWORD cbPkTableQualifier,
+ UCHAR FAR * szPkTableOwner,
+ SWORD cbPkTableOwner,
+ UCHAR FAR * szPkTableName,
+ SWORD cbPkTableName,
+ UCHAR FAR * szFkTableQualifier,
+ SWORD cbFkTableQualifier,
+ UCHAR FAR * szFkTableOwner,
+ SWORD cbFkTableOwner,
+ UCHAR FAR * szFkTableName,
+ SWORD cbFkTableName)
{
static char *func = "PGAPI_ForeignKeys";
StatementClass *stmt = (StatementClass *) hstmt;
del_rule[MAX_TABLE_LEN];
char pk_table_needed[MAX_TABLE_LEN + 1];
char fk_table_needed[MAX_TABLE_LEN + 1];
- char *pkey_ptr, *pkey_text,
- *fkey_ptr, *fkey_text,
- *pk_table, *pkt_text,
- *fk_table, *fkt_text;
+ char *pkey_ptr,
+ *pkey_text,
+ *fkey_ptr,
+ *fkey_text,
+ *pk_table,
+ *pkt_text,
+ *fk_table,
+ *fkt_text;
+
#ifdef MULTIBYTE
- BOOL pkey_alloced, fkey_alloced, pkt_alloced, fkt_alloced;
- ConnectionClass *conn;
-#endif /* MULTIBYTE */
+ BOOL pkey_alloced,
+ fkey_alloced,
+ pkt_alloced,
+ fkt_alloced;
+ ConnectionClass *conn;
+#endif /* MULTIBYTE */
int i,
j,
k,
#if (ODBCVER >= 0x0300)
SWORD defer_type;
-
#endif
char pkey[MAX_INFO_STRING];
Int2 result_cols;
#ifdef MULTIBYTE
pkey_alloced = fkey_alloced = pkt_alloced = fkt_alloced = FALSE;
conn = SC_get_conn(stmt);
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
+
/*
* Case #2 -- Get the foreign keys in the specified table (fktab) that
* refer to the primary keys of other table(s).
}
result = PGAPI_BindCol(htbl_stmt, 1, SQL_C_BINARY,
- trig_args, sizeof(trig_args), NULL);
+ trig_args, sizeof(trig_args), NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = tbl_stmt->errormsg;
}
result = PGAPI_BindCol(htbl_stmt, 2, SQL_C_SHORT,
- &trig_nargs, 0, NULL);
+ &trig_nargs, 0, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = tbl_stmt->errormsg;
}
result = PGAPI_BindCol(htbl_stmt, 5, SQL_C_CHAR,
- upd_rule, sizeof(upd_rule), NULL);
+ upd_rule, sizeof(upd_rule), NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = tbl_stmt->errormsg;
}
result = PGAPI_BindCol(htbl_stmt, 6, SQL_C_CHAR,
- del_rule, sizeof(del_rule), NULL);
+ del_rule, sizeof(del_rule), NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = tbl_stmt->errormsg;
}
keyresult = PGAPI_BindCol(hpkey_stmt, 4, SQL_C_CHAR,
- pkey, sizeof(pkey), NULL);
+ pkey, sizeof(pkey), NULL);
if (keyresult != SQL_SUCCESS)
{
stmt->errornumber = STMT_NO_MEMORY_ERROR;
pkt_text = getClientTableName(conn, pk_table, &pkt_alloced);
#else
pkt_text = pk_table;
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
/* If there is a pk table specified, then check it. */
if (pk_table_needed[0] != '\0')
{
pkey_text = getClientColumnName(conn, pk_table, pkey_ptr, &pkey_alloced);
#else
pkey_text = pkey_ptr;
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
mylog("%s: pkey_ptr='%s', pkey='%s'\n", func, pkey_text, pkey);
if (strcmp(pkey_text, pkey))
{
#ifdef MULTIBYTE
if (pkey_alloced)
free(pkey_text);
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
/* Get to next primary key */
for (k = 0; k < 2; k++)
pkey_ptr += strlen(pkey_ptr) + 1;
for (k = 0; k < num_keys; k++)
{
- row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) *sizeof(TupleField));
+ row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) * sizeof(TupleField));
#ifdef MULTIBYTE
pkey_text = getClientColumnName(conn, pk_table, pkey_ptr, &pkey_alloced);
#else
pkey_text = pkey_ptr;
fkey_text = fkey_ptr;
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
mylog("%s: pk_table = '%s', pkey_ptr = '%s'\n", func, pkt_text, pkey_text);
set_tuplefield_null(&row->tuple[0]);
set_tuplefield_string(&row->tuple[1], "");
if (pkey_alloced)
free(pkey_text);
pkey_alloced = FALSE;
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
/* next primary/foreign key */
for (i = 0; i < 2; i++)
{
if (pkt_alloced)
free(pkt_text);
pkt_alloced = FALSE;
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
result = PGAPI_Fetch(htbl_stmt);
}
}
result = PGAPI_BindCol(htbl_stmt, 1, SQL_C_BINARY,
- trig_args, sizeof(trig_args), NULL);
+ trig_args, sizeof(trig_args), NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = tbl_stmt->errormsg;
}
result = PGAPI_BindCol(htbl_stmt, 2, SQL_C_SHORT,
- &trig_nargs, 0, NULL);
+ &trig_nargs, 0, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = tbl_stmt->errormsg;
}
result = PGAPI_BindCol(htbl_stmt, 5, SQL_C_CHAR,
- upd_rule, sizeof(upd_rule), NULL);
+ upd_rule, sizeof(upd_rule), NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = tbl_stmt->errormsg;
}
result = PGAPI_BindCol(htbl_stmt, 6, SQL_C_CHAR,
- del_rule, sizeof(del_rule), NULL);
+ del_rule, sizeof(del_rule), NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
stmt->errormsg = tbl_stmt->errormsg;
fkt_text = getClientTableName(conn, fk_table, &fkt_alloced);
#else
fkt_text = fk_table;
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
/* Get to first foreign key */
fkey_ptr = trig_args;
#else
pkey_text = pkey_ptr;
fkey_text = fkey_ptr;
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
mylog("pkey_ptr = '%s', fk_table = '%s', fkey_ptr = '%s'\n", pkey_text, fkt_text, fkey_text);
- row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) *sizeof(TupleField));
+ row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) * sizeof(TupleField));
mylog("pk_table_needed = '%s', pkey_ptr = '%s'\n", pk_table_needed, pkey_text);
set_tuplefield_null(&row->tuple[0]);
if (fkey_alloced)
free(fkey_text);
fkey_alloced = FALSE;
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
/* next primary/foreign key */
for (j = 0; j < 2; j++)
if (fkt_alloced)
free(fkt_text);
fkt_alloced = FALSE;
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
result = PGAPI_Fetch(htbl_stmt);
}
}
free(fkt_text);
if (fkey_alloced)
free(fkey_text);
-#endif /* MULTIBYTE */
+#endif /* MULTIBYTE */
PGAPI_FreeStmt(htbl_stmt, SQL_DROP);
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_ProcedureColumns(
- HSTMT hstmt,
- UCHAR FAR *szProcQualifier,
- SWORD cbProcQualifier,
- UCHAR FAR *szProcOwner,
- SWORD cbProcOwner,
- UCHAR FAR *szProcName,
- SWORD cbProcName,
- UCHAR FAR *szColumnName,
- SWORD cbColumnName)
+ HSTMT hstmt,
+ UCHAR FAR * szProcQualifier,
+ SWORD cbProcQualifier,
+ UCHAR FAR * szProcOwner,
+ SWORD cbProcOwner,
+ UCHAR FAR * szProcName,
+ SWORD cbProcName,
+ UCHAR FAR * szColumnName,
+ SWORD cbColumnName)
{
static char *func = "PGAPI_ProcedureColumns";
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_Procedures(
- HSTMT hstmt,
- UCHAR FAR *szProcQualifier,
- SWORD cbProcQualifier,
- UCHAR FAR *szProcOwner,
- SWORD cbProcOwner,
- UCHAR FAR *szProcName,
- SWORD cbProcName)
+ HSTMT hstmt,
+ UCHAR FAR * szProcQualifier,
+ SWORD cbProcQualifier,
+ UCHAR FAR * szProcOwner,
+ SWORD cbProcOwner,
+ UCHAR FAR * szProcName,
+ SWORD cbProcName)
{
static char *func = "PGAPI_Procedures";
- StatementClass *stmt = (StatementClass *) hstmt;
- ConnectionClass *conn = SC_get_conn(stmt);
+ StatementClass *stmt = (StatementClass *) hstmt;
+ ConnectionClass *conn = SC_get_conn(stmt);
char proc_query[INFO_INQUIRY_LEN];
- QResultClass *res;
+ QResultClass *res;
mylog("%s: entering...\n", func);
-
+
if (PG_VERSION_LT(conn, 6.5))
{
stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
}
if (!SC_recycle_statement(stmt))
return SQL_ERROR;
+
/*
- * The following seems the simplest implementation
+ * The following seems the simplest implementation
*/
- strcpy(proc_query, "select '' as ""PROCEDURE_CAT"", '' as ""PROCEDURE_SCHEM"","
- " proname as ""PROCEDURE_NAME"", '' as ""NUM_INPUT_PARAMS"","
- " '' as ""NUM_OUTPUT_PARAMS"", '' as ""NUM_RESULT_SETS"","
- " '' as ""REMARKS"","
- " case when prorettype =0 then 1::int2 else 2::int2 end as ""PROCEDURE_TYPE"" from pg_proc");
+ strcpy(proc_query, "select '' as " "PROCEDURE_CAT" ", '' as " "PROCEDURE_SCHEM" ","
+ " proname as " "PROCEDURE_NAME" ", '' as " "NUM_INPUT_PARAMS" ","
+ " '' as " "NUM_OUTPUT_PARAMS" ", '' as " "NUM_RESULT_SETS" ","
+ " '' as " "REMARKS" ","
+ " case when prorettype =0 then 1::int2 else 2::int2 end as " "PROCEDURE_TYPE" " from pg_proc");
my_strcat(proc_query, " where proname like '%.*s'", szProcName, cbProcName);
res = CC_send_query(conn, proc_query, NULL);
return SQL_ERROR;
}
stmt->result = res;
+
/*
* also, things need to think that this statement is finished so the
* results can be retrieved.
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_TablePrivileges(
- HSTMT hstmt,
- UCHAR FAR *szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
- SWORD cbTableOwner,
- UCHAR FAR *szTableName,
- SWORD cbTableName)
+ HSTMT hstmt,
+ UCHAR FAR * szTableQualifier,
+ SWORD cbTableQualifier,
+ UCHAR FAR * szTableOwner,
+ SWORD cbTableOwner,
+ UCHAR FAR * szTableName,
+ SWORD cbTableName)
{
- StatementClass *stmt = (StatementClass *) hstmt;
+ StatementClass *stmt = (StatementClass *) hstmt;
static char *func = "PGAPI_TablePrivileges";
Int2 result_cols;
mylog("%s: entering...\n", func);
/*
- * a statement is actually executed, so we'll have to do this
- * ourselves.
- */
+ * a statement is actually executed, so we'll have to do this
+ * ourselves.
+ */
result_cols = 7;
extend_bindings(stmt, result_cols);
QR_set_field_info(stmt->result, 4, "GRANTEE", PG_TYPE_TEXT, MAX_INFO_STRING);
QR_set_field_info(stmt->result, 5, "PRIVILEGE", PG_TYPE_TEXT, MAX_INFO_STRING);
QR_set_field_info(stmt->result, 6, "IS_GRANTABLE", PG_TYPE_TEXT, MAX_INFO_STRING);
-
+
SC_log_error(func, "Function not implemented", (StatementClass *) hstmt);
return SQL_ERROR;
}
#include
#define MEM_ALLOC(size) (malloc((size_t)(size)))
-#define MEM_FREE(ptr) \
+#define MEM_FREE(ptr) \
do { \
if(ptr) \
free(ptr); \
typedef DWORD LPARAM;
typedef void *HWND;
typedef int BOOL;
-
#endif /* _UNIX_ */
#if defined(WIN32) || defined(WIN32_SYSTEM)
#define STRLEN(str) ((str)? _fstrlen((char FAR*)(str)):0)
#define STREQ(a, b) (_fstrcmp((char FAR*)(a), (char FAR*)(b) == 0)
#endif
-
#endif /* WIN32 */
#define SYSERR (-1)
#ifndef NULL
#define NULL ((void FAR*)0UL)
#endif
-
#endif
#endif
RETCODE SQL_API SQLAllocConnect(HENV henv,
- HDBC FAR *phdbc);
- RETCODE SQL_API SQLAllocEnv(HENV FAR *phenv);
+ HDBC FAR * phdbc);
+ RETCODE SQL_API SQLAllocEnv(HENV FAR * phenv);
RETCODE SQL_API SQLAllocStmt(HDBC hdbc,
- HSTMT FAR *phstmt);
+ HSTMT FAR * phstmt);
RETCODE SQL_API SQLBindCol(HSTMT hstmt,
UWORD icol,
SWORD fCType,
PTR rgbValue,
SDWORD cbValueMax,
- SDWORD FAR *pcbValue);
+ SDWORD FAR * pcbValue);
RETCODE SQL_API SQLCancel(HSTMT hstmt);
UWORD fDescType,
PTR rgbDesc,
SWORD cbDescMax,
- SWORD FAR *pcbDesc,
- SDWORD FAR *pfDesc);
+ SWORD FAR * pcbDesc,
+ SDWORD FAR * pfDesc);
RETCODE SQL_API SQLConnect(HDBC hdbc,
- UCHAR FAR *szDSN,
+ UCHAR FAR * szDSN,
SWORD cbDSN,
- UCHAR FAR *szUID,
+ UCHAR FAR * szUID,
SWORD cbUID,
- UCHAR FAR *szAuthStr,
+ UCHAR FAR * szAuthStr,
SWORD cbAuthStr);
RETCODE SQL_API SQLDescribeCol(HSTMT hstmt,
UWORD icol,
- UCHAR FAR *szColName,
+ UCHAR FAR * szColName,
SWORD cbColNameMax,
- SWORD FAR *pcbColName,
- SWORD FAR *pfSqlType,
- UDWORD FAR *pcbColDef,
- SWORD FAR *pibScale,
- SWORD FAR *pfNullable);
+ SWORD FAR * pcbColName,
+ SWORD FAR * pfSqlType,
+ UDWORD FAR * pcbColDef,
+ SWORD FAR * pibScale,
+ SWORD FAR * pfNullable);
RETCODE SQL_API SQLDisconnect(HDBC hdbc);
RETCODE SQL_API SQLError(HENV henv,
HDBC hdbc,
HSTMT hstmt,
- UCHAR FAR *szSqlState,
- SDWORD FAR *pfNativeError,
- UCHAR FAR *szErrorMsg,
+ UCHAR FAR * szSqlState,
+ SDWORD FAR * pfNativeError,
+ UCHAR FAR * szErrorMsg,
SWORD cbErrorMsgMax,
- SWORD FAR *pcbErrorMsg);
+ SWORD FAR * pcbErrorMsg);
RETCODE SQL_API SQLExecDirect(HSTMT hstmt,
- UCHAR FAR *szSqlStr,
+ UCHAR FAR * szSqlStr,
SDWORD cbSqlStr);
RETCODE SQL_API SQLExecute(HSTMT hstmt);
UWORD fOption);
RETCODE SQL_API SQLGetCursorName(HSTMT hstmt,
- UCHAR FAR *szCursor,
+ UCHAR FAR * szCursor,
SWORD cbCursorMax,
- SWORD FAR *pcbCursor);
+ SWORD FAR * pcbCursor);
RETCODE SQL_API SQLNumResultCols(HSTMT hstmt,
- SWORD FAR *pccol);
+ SWORD FAR * pccol);
RETCODE SQL_API SQLPrepare(HSTMT hstmt,
- UCHAR FAR *szSqlStr,
+ UCHAR FAR * szSqlStr,
SDWORD cbSqlStr);
RETCODE SQL_API SQLRowCount(HSTMT hstmt,
- SDWORD FAR *pcrow);
+ SDWORD FAR * pcrow);
RETCODE SQL_API SQLSetCursorName(HSTMT hstmt,
- UCHAR FAR *szCursor,
+ UCHAR FAR * szCursor,
SWORD cbCursor);
RETCODE SQL_API SQLTransact(HENV henv,
UDWORD cbColDef,
SWORD ibScale,
PTR rgbValue,
- SDWORD FAR *pcbValue);
+ SDWORD FAR * pcbValue);
#ifdef __cplusplus
}
-
#endif
#endif
{
SQLUINTEGER dwLowWord;
SQLUINTEGER dwHighWord;
-} SQLUBIGINT;
+} SQLUBIGINT;
typedef struct
{
SQLUINTEGER dwLowWord;
SQLINTEGER dwHighWord;
-} SQLBIGINT;
-
+} SQLBIGINT;
#endif /* GCC */
typedef struct tagDATE_STRUCT
SQLSMALLINT year;
SQLUSMALLINT month;
SQLUSMALLINT day;
-} DATE_STRUCT,
-SQL_DATE_STRUCT;
+} DATE_STRUCT,
+
+ SQL_DATE_STRUCT;
typedef struct tagTIME_STRUCT
{
SQLUSMALLINT hour;
SQLUSMALLINT minute;
SQLUSMALLINT second;
-} TIME_STRUCT,
-SQL_TIME_STRUCT;
+} TIME_STRUCT,
+
+ SQL_TIME_STRUCT;
typedef struct tagTIMESTAMP_STRUCT
{
SQLUSMALLINT minute;
SQLUSMALLINT second;
SQLUINTEGER fraction;
-} TIMESTAMP_STRUCT,
-SQL_TIMESTAMP_STRUCT;
+} TIMESTAMP_STRUCT,
+
+ SQL_TIMESTAMP_STRUCT;
/* postodbc doesn't use these but what the heck */
/* Don't know what SQL_MAX_NUMERIC_LEN should be so I can't include this. It's
WORD Data2;
WORD Data3;
BYTE Data4[8];
-} SQLGUID;
+} SQLGUID;
typedef enum
{
- SQL_IS_YEAR = 1,
- SQL_IS_MONTH = 2,
- SQL_IS_DAY = 3,
- SQL_IS_HOUR = 4,
- SQL_IS_MINUTE = 5,
- SQL_IS_SECOND = 6,
- SQL_IS_YEAR_TO_MONTH = 7,
- SQL_IS_DAY_TO_HOUR = 8,
- SQL_IS_DAY_TO_MINUTE = 9,
- SQL_IS_DAY_TO_SECOND = 10,
- SQL_IS_HOUR_TO_MINUTE = 11,
- SQL_IS_HOUR_TO_SECOND = 12,
- SQL_IS_MINUTE_TO_SECOND = 13
-} SQLINTERVAL;
+ SQL_IS_YEAR = 1,
+ SQL_IS_MONTH = 2,
+ SQL_IS_DAY = 3,
+ SQL_IS_HOUR = 4,
+ SQL_IS_MINUTE = 5,
+ SQL_IS_SECOND = 6,
+ SQL_IS_YEAR_TO_MONTH = 7,
+ SQL_IS_DAY_TO_HOUR = 8,
+ SQL_IS_DAY_TO_MINUTE = 9,
+ SQL_IS_DAY_TO_SECOND = 10,
+ SQL_IS_HOUR_TO_MINUTE = 11,
+ SQL_IS_HOUR_TO_SECOND = 12,
+ SQL_IS_MINUTE_TO_SECOND = 13
+} SQLINTERVAL;
typedef struct tagSQL_YEAR_MONTH
{
SQLUINTEGER year;
SQLUINTEGER month;
-} SQL_YEAR_MONTH_STRUCT;
+} SQL_YEAR_MONTH_STRUCT;
typedef struct tagSQL_DAY_SECOND
{
SQLUINTEGER minute;
SQLUINTEGER second;
SQLUINTEGER fraction;
-} SQL_DAY_SECOND_STRUCT;
+} SQL_DAY_SECOND_STRUCT;
typedef struct tagSQL_INTERVAL_STRUCT
{
SQL_YEAR_MONTH_STRUCT year_month;
SQL_DAY_SECOND_STRUCT day_second;
} intval;
-} SQL_INTERVAL_STRUCT;
+} SQL_INTERVAL_STRUCT;
#define SQL_MAX_OPTION_STRING_LENGTH 256
#define SQL_NUM_EXTENSIONS (SQL_EXT_API_LAST - SQL_EXT_API_START + 1)
* function prototypes previously missing from isqlext.h
*/
RETCODE SQL_API SQLColumns(HSTMT hstmt,
- UCHAR FAR *szTableQualifier,
+ UCHAR FAR * szTableQualifier,
SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
+ UCHAR FAR * szTableOwner,
SWORD cbTableOwner,
- UCHAR FAR *szTableName,
+ UCHAR FAR * szTableName,
SWORD cbTableName,
- UCHAR FAR *szColumnName,
+ UCHAR FAR * szColumnName,
SWORD cbColumnName);
RETCODE SQL_API SQLDriverConnect(HDBC hdbc,
HWND hwnd,
- UCHAR FAR *szConnStrIn,
+ UCHAR FAR * szConnStrIn,
SWORD cbConnStrIn,
- UCHAR FAR *szConnStrOut,
+ UCHAR FAR * szConnStrOut,
SWORD cbConnStrOutMax,
- SWORD FAR *pcbConnStrOut,
+ SWORD FAR * pcbConnStrOut,
UWORD fDriverCompletion);
RETCODE SQL_API SQLGetConnectOption(HDBC hdbc,
SWORD fCType,
PTR rgbValue,
SDWORD cbValueMax,
- SDWORD FAR *pcbValue);
+ SDWORD FAR * pcbValue);
RETCODE SQL_API SQLGetFunctions(HDBC hdbc,
UWORD fFunction,
- UWORD FAR *pfExists);
+ UWORD FAR * pfExists);
RETCODE SQL_API SQLGetInfo(HDBC hdbc,
UWORD fInfoType,
PTR rgbInfoValue,
SWORD cbInfoValueMax,
- SWORD FAR *pcbInfoValue);
+ SWORD FAR * pcbInfoValue);
RETCODE SQL_API SQLGetStmtOption(HSTMT hstmt,
UWORD fOption,
SWORD fSqlType);
RETCODE SQL_API SQLParamData(HSTMT hstmt,
- PTR FAR *prgbValue);
+ PTR FAR * prgbValue);
RETCODE SQL_API SQLPutData(HSTMT hstmt,
PTR rgbValue,
RETCODE SQL_API SQLSpecialColumns(HSTMT hstmt,
UWORD fColType,
- UCHAR FAR *szTableQualifier,
+ UCHAR FAR * szTableQualifier,
SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
+ UCHAR FAR * szTableOwner,
SWORD cbTableOwner,
- UCHAR FAR *szTableName,
+ UCHAR FAR * szTableName,
SWORD cbTableName,
UWORD fScope,
UWORD fNullable);
RETCODE SQL_API SQLStatistics(HSTMT hstmt,
- UCHAR FAR *szTableQualifier,
+ UCHAR FAR * szTableQualifier,
SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
+ UCHAR FAR * szTableOwner,
SWORD cbTableOwner,
- UCHAR FAR *szTableName,
+ UCHAR FAR * szTableName,
SWORD cbTableName,
UWORD fUnique,
UWORD fAccuracy);
RETCODE SQL_API SQLTables(HSTMT hstmt,
- UCHAR FAR *szTableQualifier,
+ UCHAR FAR * szTableQualifier,
SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
+ UCHAR FAR * szTableOwner,
SWORD cbTableOwner,
- UCHAR FAR *szTableName,
+ UCHAR FAR * szTableName,
SWORD cbTableName,
- UCHAR FAR *szTableType,
+ UCHAR FAR * szTableType,
SWORD cbTableType);
RETCODE SQL_API SQLBrowseConnect(HDBC hdbc,
- UCHAR FAR *szConnStrIn,
+ UCHAR FAR * szConnStrIn,
SWORD cbConnStrIn,
- UCHAR FAR *szConnStrOut,
+ UCHAR FAR * szConnStrOut,
SWORD cbConnStrOutMax,
- SWORD FAR *pcbConnStrOut);
+ SWORD FAR * pcbConnStrOut);
RETCODE SQL_API SQLColumnPrivileges(HSTMT hstmt,
- UCHAR FAR *szTableQualifier,
+ UCHAR FAR * szTableQualifier,
SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
+ UCHAR FAR * szTableOwner,
SWORD cbTableOwner,
- UCHAR FAR *szTableName,
+ UCHAR FAR * szTableName,
SWORD cbTableName,
- UCHAR FAR *szColumnName,
+ UCHAR FAR * szColumnName,
SWORD cbColumnName);
RETCODE SQL_API SQLDescribeParam(HSTMT hstmt,
UWORD ipar,
- SWORD FAR *pfSqlType,
- UDWORD FAR *pcbColDef,
- SWORD FAR *pibScale,
- SWORD FAR *pfNullable);
+ SWORD FAR * pfSqlType,
+ UDWORD FAR * pcbColDef,
+ SWORD FAR * pibScale,
+ SWORD FAR * pfNullable);
RETCODE SQL_API SQLExtendedFetch(HSTMT hstmt,
UWORD fFetchType,
SDWORD irow,
- UDWORD FAR *pcrow,
- UWORD FAR *rgfRowStatus);
+ UDWORD FAR * pcrow,
+ UWORD FAR * rgfRowStatus);
RETCODE SQL_API SQLForeignKeys(HSTMT hstmt,
- UCHAR FAR *szPkTableQualifier,
+ UCHAR FAR * szPkTableQualifier,
SWORD cbPkTableQualifier,
- UCHAR FAR *szPkTableOwner,
+ UCHAR FAR * szPkTableOwner,
SWORD cbPkTableOwner,
- UCHAR FAR *szPkTableName,
+ UCHAR FAR * szPkTableName,
SWORD cbPkTableName,
- UCHAR FAR *szFkTableQualifier,
+ UCHAR FAR * szFkTableQualifier,
SWORD cbFkTableQualifier,
- UCHAR FAR *szFkTableOwner,
+ UCHAR FAR * szFkTableOwner,
SWORD cbFkTableOwner,
- UCHAR FAR *szFkTableName,
+ UCHAR FAR * szFkTableName,
SWORD cbFkTableName);
RETCODE SQL_API SQLMoreResults(HSTMT hstmt);
RETCODE SQL_API SQLNativeSql(HDBC hdbc,
- UCHAR FAR *szSqlStrIn,
+ UCHAR FAR * szSqlStrIn,
SDWORD cbSqlStrIn,
- UCHAR FAR *szSqlStr,
+ UCHAR FAR * szSqlStr,
SDWORD cbSqlStrMax,
- SDWORD FAR *pcbSqlStr);
+ SDWORD FAR * pcbSqlStr);
RETCODE SQL_API SQLNumParams(HSTMT hstmt,
- SWORD FAR *pcpar);
+ SWORD FAR * pcpar);
RETCODE SQL_API SQLParamOptions(HSTMT hstmt,
UDWORD crow,
- UDWORD FAR *pirow);
+ UDWORD FAR * pirow);
RETCODE SQL_API SQLPrimaryKeys(HSTMT hstmt,
- UCHAR FAR *szTableQualifier,
+ UCHAR FAR * szTableQualifier,
SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
+ UCHAR FAR * szTableOwner,
SWORD cbTableOwner,
- UCHAR FAR *szTableName,
+ UCHAR FAR * szTableName,
SWORD cbTableName);
RETCODE SQL_API SQLProcedureColumns(HSTMT hstmt,
- UCHAR FAR *szProcQualifier,
+ UCHAR FAR * szProcQualifier,
SWORD cbProcQualifier,
- UCHAR FAR *szProcOwner,
+ UCHAR FAR * szProcOwner,
SWORD cbProcOwner,
- UCHAR FAR *szProcName,
+ UCHAR FAR * szProcName,
SWORD cbProcName,
- UCHAR FAR *szColumnName,
+ UCHAR FAR * szColumnName,
SWORD cbColumnName);
RETCODE SQL_API SQLProcedures(HSTMT hstmt,
- UCHAR FAR *szProcQualifier,
+ UCHAR FAR * szProcQualifier,
SWORD cbProcQualifier,
- UCHAR FAR *szProcOwner,
+ UCHAR FAR * szProcOwner,
SWORD cbProcOwner,
- UCHAR FAR *szProcName,
+ UCHAR FAR * szProcName,
SWORD cbProcName);
RETCODE SQL_API SQLSetPos(HSTMT hstmt,
UWORD fLock);
RETCODE SQL_API SQLTablePrivileges(HSTMT hstmt,
- UCHAR FAR *szTableQualifier,
+ UCHAR FAR * szTableQualifier,
SWORD cbTableQualifier,
- UCHAR FAR *szTableOwner,
+ UCHAR FAR * szTableOwner,
SWORD cbTableOwner,
- UCHAR FAR *szTableName,
+ UCHAR FAR * szTableName,
SWORD cbTableName);
RETCODE SQL_API SQLBindParameter(HSTMT hstmt,
SWORD ibScale,
PTR rgbValue,
SDWORD cbValueMax,
- SDWORD FAR *pcbValue);
+ SDWORD FAR * pcbValue);
RETCODE SQL_API SQLSetScrollOptions(HSTMT hstmt,
UWORD fConcurrency,
#ifdef __cplusplus
}
-
#endif
-
#endif
Oid
-lo_creat(ConnectionClass *conn, int mode)
+lo_creat(ConnectionClass * conn, int mode)
{
LO_ARG argv[1];
int retval,
int
-lo_open(ConnectionClass *conn, int lobjId, int mode)
+lo_open(ConnectionClass * conn, int lobjId, int mode)
{
int fd;
int result_len;
int
-lo_close(ConnectionClass *conn, int fd)
+lo_close(ConnectionClass * conn, int fd)
{
LO_ARG argv[1];
int retval,
int
-lo_read(ConnectionClass *conn, int fd, char *buf, int len)
+lo_read(ConnectionClass * conn, int fd, char *buf, int len)
{
LO_ARG argv[2];
int result_len;
int
-lo_write(ConnectionClass *conn, int fd, char *buf, int len)
+lo_write(ConnectionClass * conn, int fd, char *buf, int len)
{
LO_ARG argv[2];
int retval,
int
-lo_lseek(ConnectionClass *conn, int fd, int offset, int whence)
+lo_lseek(ConnectionClass * conn, int fd, int offset, int whence)
{
LO_ARG argv[3];
int retval,
int
-lo_tell(ConnectionClass *conn, int fd)
+lo_tell(ConnectionClass * conn, int fd)
{
LO_ARG argv[1];
int retval,
int
-lo_unlink(ConnectionClass *conn, Oid lobjId)
+lo_unlink(ConnectionClass * conn, Oid lobjId)
{
LO_ARG argv[1];
int retval,
#define INV_WRITE 0x00020000
#define INV_READ 0x00040000
-Oid lo_creat(ConnectionClass *conn, int mode);
-int lo_open(ConnectionClass *conn, int lobjId, int mode);
-int lo_close(ConnectionClass *conn, int fd);
-int lo_read(ConnectionClass *conn, int fd, char *buf, int len);
-int lo_write(ConnectionClass *conn, int fd, char *buf, int len);
-int lo_lseek(ConnectionClass *conn, int fd, int offset, int len);
-int lo_tell(ConnectionClass *conn, int fd);
-int lo_unlink(ConnectionClass *conn, Oid lobjId);
-
+Oid lo_creat(ConnectionClass * conn, int mode);
+int lo_open(ConnectionClass * conn, int lobjId, int mode);
+int lo_close(ConnectionClass * conn, int fd);
+int lo_read(ConnectionClass * conn, int fd, char *buf, int len);
+int lo_write(ConnectionClass * conn, int fd, char *buf, int len);
+int lo_lseek(ConnectionClass * conn, int fd, int offset, int len);
+int lo_tell(ConnectionClass * conn, int fd);
+int lo_unlink(ConnectionClass * conn, Oid lobjId);
#endif
#endif
extern GLOBAL_VALUES globals;
-void generate_filename(const char *, const char *, char *);
+void generate_filename(const char *, const char *, char *);
void
return;
}
-static int mylog_on = 0, qlog_on = 0;
-void logs_on_off(int cnopen, int mylog_onoff, int qlog_onoff)
+static int mylog_on = 0,
+ qlog_on = 0;
+void
+logs_on_off(int cnopen, int mylog_onoff, int qlog_onoff)
{
- static int mylog_on_count = 0, mylog_off_count = 0,
- qlog_on_count = 0, qlog_off_count = 0;
+ static int mylog_on_count = 0,
+ mylog_off_count = 0,
+ qlog_on_count = 0,
+ qlog_off_count = 0;
if (mylog_onoff)
mylog_on_count += cnopen;
- else
+ else
mylog_off_count += cnopen;
if (mylog_on_count > 0)
mylog_on = 1;
mylog_on = globals.debug;
if (qlog_onoff)
qlog_on_count += cnopen;
- else
+ else
qlog_off_count += cnopen;
if (qlog_on_count > 0)
qlog_on = 1;
{
va_list args;
char filebuf[80];
- static FILE *LOGFP = NULL;
+ static FILE *LOGFP = NULL;
if (mylog_on)
{
va_end(args);
}
}
-
#endif
{
va_list args;
char filebuf[80];
- static FILE *LOGFP = NULL;
+ static FILE *LOGFP = NULL;
if (qlog_on)
{
va_end(args);
}
}
-
#endif
#define STRCPY_NULL (-2)
int my_strcpy(char *dst, int dst_len, const char *src, int src_len);
-
#endif
unsigned char *
check_client_encoding(unsigned char *str)
{
- if (strstr(str, "%27SJIS%27") ||
- strstr(str, "%27Shift_JIS%27") ||
- strstr(str, "'SJIS'") ||
- strstr(str, "'sjis'") ||
- strstr(str, "'Shift_JIS'"))
+ if (strstr(str, "%27SJIS%27") ||
+ strstr(str, "%27Shift_JIS%27") ||
+ strstr(str, "'SJIS'") ||
+ strstr(str, "'sjis'") ||
+ strstr(str, "'Shift_JIS'"))
{
multibyte_client_encoding = SJIS;
return ("SJIS");
}
- if (strstr(str, "%27BIG5%27") ||
- strstr(str, "%27Big5%27") ||
- strstr(str, "'BIG5'") ||
- strstr(str, "'big5'") ||
- strstr(str, "'Big5'"))
+ if (strstr(str, "%27BIG5%27") ||
+ strstr(str, "%27Big5%27") ||
+ strstr(str, "'BIG5'") ||
+ strstr(str, "'big5'") ||
+ strstr(str, "'Big5'"))
{
multibyte_client_encoding = BIG5;
return ("BIG5");
switch (multibyte_client_encoding)
{
/* Japanese Shift-JIS(CP932) Support. */
- case SJIS:
+ case SJIS:
{
if (multibyte_status < 2 && s > 0x80 && !(s > 0x9f && s < 0xE0))
multibyte_status = 2;
SQLSetConnectOption, SQLSetCursorName, SQLSetParam,
SQLSetStmtOption, SQLSpecialColumns, SQLStatistics,
SQLTables, SQLTransact, SQLColAttributes,
- SQLColumnPrivileges, SQLDescribeParam, SQLExtendedFetch,
- SQLForeignKeys, SQLMoreResults, SQLNativeSql,
- SQLNumParams, SQLParamOptions, SQLPrimaryKeys,
- SQLProcedureColumns, SQLProcedures, SQLSetPos,
- SQLTablePrivileges, SQLBindParameter
+ SQLColumnPrivileges, SQLDescribeParam, SQLExtendedFetch,
+ SQLForeignKeys, SQLMoreResults, SQLNativeSql,
+ SQLNumParams, SQLParamOptions, SQLPrimaryKeys,
+ SQLProcedureColumns, SQLProcedures, SQLSetPos,
+ SQLTablePrivileges, SQLBindParameter
*-------
*/
#ifdef WIN32
-#define ODBCVER_REP 0x3000
+#define ODBCVER_REP 0x3000
#endif
#include "psqlodbc.h"
#include
#include "connection.h"
#include "statement.h"
-RETCODE SQL_API SQLAllocConnect(HENV EnvironmentHandle,
- HDBC FAR *ConnectionHandle)
+RETCODE SQL_API
+SQLAllocConnect(HENV EnvironmentHandle,
+ HDBC FAR * ConnectionHandle)
{
mylog("[SQLAllocConnect]");
return PGAPI_AllocConnect(EnvironmentHandle, ConnectionHandle);
}
-RETCODE SQL_API SQLAllocEnv(HENV FAR *EnvironmentHandle)
+RETCODE SQL_API
+SQLAllocEnv(HENV FAR * EnvironmentHandle)
{
mylog("[SQLAllocEnv]");
return PGAPI_AllocEnv(EnvironmentHandle);
}
-RETCODE SQL_API SQLAllocStmt(HDBC ConnectionHandle,
- HSTMT *StatementHandle)
+RETCODE SQL_API
+SQLAllocStmt(HDBC ConnectionHandle,
+ HSTMT * StatementHandle)
{
mylog("[SQLAllocStmt]");
return PGAPI_AllocStmt(ConnectionHandle, StatementHandle);
}
-RETCODE SQL_API SQLBindCol(HSTMT StatementHandle,
- SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
- PTR TargetValue, SQLINTEGER BufferLength,
- SQLINTEGER *StrLen_or_Ind)
+RETCODE SQL_API
+SQLBindCol(HSTMT StatementHandle,
+ SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
+ PTR TargetValue, SQLINTEGER BufferLength,
+ SQLINTEGER * StrLen_or_Ind)
{
mylog("[SQLBindCol]");
return PGAPI_BindCol(StatementHandle, ColumnNumber,
- TargetType, TargetValue, BufferLength, StrLen_or_Ind);
+ TargetType, TargetValue, BufferLength, StrLen_or_Ind);
}
-RETCODE SQL_API SQLCancel(HSTMT StatementHandle)
+RETCODE SQL_API
+SQLCancel(HSTMT StatementHandle)
{
mylog("[SQLCancel]");
return PGAPI_Cancel(StatementHandle);
}
-RETCODE SQL_API SQLColumns(HSTMT StatementHandle,
- SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
- SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
- SQLCHAR *TableName, SQLSMALLINT NameLength3,
- SQLCHAR *ColumnName, SQLSMALLINT NameLength4)
+RETCODE SQL_API
+SQLColumns(HSTMT StatementHandle,
+ SQLCHAR * CatalogName, SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName, SQLSMALLINT NameLength2,
+ SQLCHAR * TableName, SQLSMALLINT NameLength3,
+ SQLCHAR * ColumnName, SQLSMALLINT NameLength4)
{
mylog("[SQLColumns]");
return PGAPI_Columns(StatementHandle, CatalogName, NameLength1,
- SchemaName, NameLength2, TableName, NameLength3,
- ColumnName, NameLength4);
+ SchemaName, NameLength2, TableName, NameLength3,
+ ColumnName, NameLength4);
}
-RETCODE SQL_API SQLConnect(HDBC ConnectionHandle,
- SQLCHAR *ServerName, SQLSMALLINT NameLength1,
- SQLCHAR *UserName, SQLSMALLINT NameLength2,
- SQLCHAR *Authentication, SQLSMALLINT NameLength3)
+RETCODE SQL_API
+SQLConnect(HDBC ConnectionHandle,
+ SQLCHAR * ServerName, SQLSMALLINT NameLength1,
+ SQLCHAR * UserName, SQLSMALLINT NameLength2,
+ SQLCHAR * Authentication, SQLSMALLINT NameLength3)
{
mylog("[SQLConnect]");
return PGAPI_Connect(ConnectionHandle, ServerName, NameLength1,
- UserName, NameLength2, Authentication, NameLength3);
+ UserName, NameLength2, Authentication, NameLength3);
}
-RETCODE SQL_API SQLDriverConnect(HDBC hdbc,
- HWND hwnd,
- UCHAR FAR *szConnStrIn,
- SWORD cbConnStrIn,
- UCHAR FAR *szConnStrOut,
- SWORD cbConnStrOutMax,
- SWORD FAR *pcbConnStrOut,
- UWORD fDriverCompletion)
+RETCODE SQL_API
+SQLDriverConnect(HDBC hdbc,
+ HWND hwnd,
+ UCHAR FAR * szConnStrIn,
+ SWORD cbConnStrIn,
+ UCHAR FAR * szConnStrOut,
+ SWORD cbConnStrOutMax,
+ SWORD FAR * pcbConnStrOut,
+ UWORD fDriverCompletion)
{
mylog("[SQLDriverConnect]");
return PGAPI_DriverConnect(hdbc, hwnd, szConnStrIn, cbConnStrIn,
szConnStrOut, cbConnStrOutMax, pcbConnStrOut, fDriverCompletion);
}
-RETCODE SQL_API SQLBrowseConnect(
- HDBC hdbc,
- SQLCHAR *szConnStrIn,
- SQLSMALLINT cbConnStrIn,
- SQLCHAR *szConnStrOut,
- SQLSMALLINT cbConnStrOutMax,
- SQLSMALLINT *pcbConnStrOut)
+RETCODE SQL_API
+SQLBrowseConnect(
+ HDBC hdbc,
+ SQLCHAR * szConnStrIn,
+ SQLSMALLINT cbConnStrIn,
+ SQLCHAR * szConnStrOut,
+ SQLSMALLINT cbConnStrOutMax,
+ SQLSMALLINT * pcbConnStrOut)
{
mylog("[SQLBrowseConnect]");
return PGAPI_BrowseConnect(hdbc, szConnStrIn, cbConnStrIn,
- szConnStrOut, cbConnStrOutMax, pcbConnStrOut);
+ szConnStrOut, cbConnStrOutMax, pcbConnStrOut);
}
-RETCODE SQL_API SQLDataSources(HENV EnvironmentHandle,
- SQLUSMALLINT Direction, SQLCHAR *ServerName,
- SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
- SQLCHAR *Description, SQLSMALLINT BufferLength2,
- SQLSMALLINT *NameLength2)
+RETCODE SQL_API
+SQLDataSources(HENV EnvironmentHandle,
+ SQLUSMALLINT Direction, SQLCHAR * ServerName,
+ SQLSMALLINT BufferLength1, SQLSMALLINT * NameLength1,
+ SQLCHAR * Description, SQLSMALLINT BufferLength2,
+ SQLSMALLINT * NameLength2)
{
mylog("[SQLDataSources]");
+
/*
- return PGAPI_DataSources(EnvironmentHandle, Direction, ServerName,
- BufferLength1, NameLength1, Description, BufferLength2,
- NameLength2);
- */
+ * return PGAPI_DataSources(EnvironmentHandle, Direction, ServerName,
+ * BufferLength1, NameLength1, Description, BufferLength2,
+ * NameLength2);
+ */
return SQL_ERROR;
}
-RETCODE SQL_API SQLDescribeCol(HSTMT StatementHandle,
- SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName,
- SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
- SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize,
- SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
+RETCODE SQL_API
+SQLDescribeCol(HSTMT StatementHandle,
+ SQLUSMALLINT ColumnNumber, SQLCHAR * ColumnName,
+ SQLSMALLINT BufferLength, SQLSMALLINT * NameLength,
+ SQLSMALLINT * DataType, SQLUINTEGER * ColumnSize,
+ SQLSMALLINT * DecimalDigits, SQLSMALLINT * Nullable)
{
mylog("[SQLDescribeCol]");
return PGAPI_DescribeCol(StatementHandle, ColumnNumber,
- ColumnName, BufferLength, NameLength,
- DataType, ColumnSize, DecimalDigits, Nullable);
+ ColumnName, BufferLength, NameLength,
+ DataType, ColumnSize, DecimalDigits, Nullable);
}
-RETCODE SQL_API SQLDisconnect(HDBC ConnectionHandle)
+RETCODE SQL_API
+SQLDisconnect(HDBC ConnectionHandle)
{
mylog("[SQLDisconnect]");
return PGAPI_Disconnect(ConnectionHandle);
}
-RETCODE SQL_API SQLError(HENV EnvironmentHandle,
- HDBC ConnectionHandle, HSTMT StatementHandle,
- SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
- SQLCHAR *MessageText, SQLSMALLINT BufferLength,
- SQLSMALLINT *TextLength)
+RETCODE SQL_API
+SQLError(HENV EnvironmentHandle,
+ HDBC ConnectionHandle, HSTMT StatementHandle,
+ SQLCHAR * Sqlstate, SQLINTEGER * NativeError,
+ SQLCHAR * MessageText, SQLSMALLINT BufferLength,
+ SQLSMALLINT * TextLength)
{
mylog("[SQLError]");
return PGAPI_Error(EnvironmentHandle, ConnectionHandle, StatementHandle,
- Sqlstate, NativeError, MessageText, BufferLength, TextLength);
+ Sqlstate, NativeError, MessageText, BufferLength, TextLength);
}
-RETCODE SQL_API SQLExecDirect(HSTMT StatementHandle,
- SQLCHAR *StatementText, SQLINTEGER TextLength)
+RETCODE SQL_API
+SQLExecDirect(HSTMT StatementHandle,
+ SQLCHAR * StatementText, SQLINTEGER TextLength)
{
mylog("[SQLExecDirect]");
return PGAPI_ExecDirect(StatementHandle, StatementText, TextLength);
}
-RETCODE SQL_API SQLExecute(HSTMT StatementHandle)
+RETCODE SQL_API
+SQLExecute(HSTMT StatementHandle)
{
mylog("[SQLExecute]");
return PGAPI_Execute(StatementHandle);
}
-RETCODE SQL_API SQLFetch(HSTMT StatementHandle)
+RETCODE SQL_API
+SQLFetch(HSTMT StatementHandle)
{
- static char *func = "SQLFetch";
+ static char *func = "SQLFetch";
+
#if (ODBCVER >= 0x3000)
- StatementClass *stmt = (StatementClass *) StatementHandle;
+ StatementClass *stmt = (StatementClass *) StatementHandle;
ConnectionClass *conn = SC_get_conn(stmt);
- if (conn->driver_version >= 0x0300)
+
+ if (conn->driver_version >= 0x0300)
{
- SQLUSMALLINT *rowStatusArray = stmt->options.rowStatusArray;
- SQLINTEGER *pcRow = stmt->options.rowsFetched;
+ SQLUSMALLINT *rowStatusArray = stmt->options.rowStatusArray;
+ SQLINTEGER *pcRow = stmt->options.rowsFetched;
mylog("[[%s]]", func);
- return PGAPI_ExtendedFetch(StatementHandle, SQL_FETCH_NEXT, 0,
- pcRow, rowStatusArray);
+ return PGAPI_ExtendedFetch(StatementHandle, SQL_FETCH_NEXT, 0,
+ pcRow, rowStatusArray);
}
#endif
mylog("[%s]", func);
return PGAPI_Fetch(StatementHandle);
}
-RETCODE SQL_API SQLFreeConnect(HDBC ConnectionHandle)
+RETCODE SQL_API
+SQLFreeConnect(HDBC ConnectionHandle)
{
mylog("[SQLFreeStmt]");
return PGAPI_FreeConnect(ConnectionHandle);
}
-RETCODE SQL_API SQLFreeEnv(HENV EnvironmentHandle)
+RETCODE SQL_API
+SQLFreeEnv(HENV EnvironmentHandle)
{
mylog("[SQLFreeEnv]");
return PGAPI_FreeEnv(EnvironmentHandle);
}
-RETCODE SQL_API SQLFreeStmt(HSTMT StatementHandle,
- SQLUSMALLINT Option)
+RETCODE SQL_API
+SQLFreeStmt(HSTMT StatementHandle,
+ SQLUSMALLINT Option)
{
mylog("[SQLFreeStmt]");
return PGAPI_FreeStmt(StatementHandle, Option);
}
-RETCODE SQL_API SQLGetConnectOption(HDBC ConnectionHandle,
- SQLUSMALLINT Option, PTR Value)
+RETCODE SQL_API
+SQLGetConnectOption(HDBC ConnectionHandle,
+ SQLUSMALLINT Option, PTR Value)
{
mylog("[SQLGetConnectOption]");
return PGAPI_GetConnectOption(ConnectionHandle, Option, Value);
-}
-RETCODE SQL_API SQLGetCursorName(HSTMT StatementHandle,
- SQLCHAR *CursorName, SQLSMALLINT BufferLength,
- SQLSMALLINT *NameLength)
+}
+RETCODE SQL_API
+SQLGetCursorName(HSTMT StatementHandle,
+ SQLCHAR * CursorName, SQLSMALLINT BufferLength,
+ SQLSMALLINT * NameLength)
{
mylog("[SQLGetCursorName]");
return PGAPI_GetCursorName(StatementHandle, CursorName, BufferLength,
- NameLength);
+ NameLength);
}
-RETCODE SQL_API SQLGetData(HSTMT StatementHandle,
- SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
- PTR TargetValue, SQLINTEGER BufferLength,
- SQLINTEGER *StrLen_or_Ind)
+RETCODE SQL_API
+SQLGetData(HSTMT StatementHandle,
+ SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
+ PTR TargetValue, SQLINTEGER BufferLength,
+ SQLINTEGER * StrLen_or_Ind)
{
mylog("[SQLGetData]");
return PGAPI_GetData(StatementHandle, ColumnNumber, TargetType,
- TargetValue, BufferLength, StrLen_or_Ind);
+ TargetValue, BufferLength, StrLen_or_Ind);
}
-RETCODE SQL_API SQLGetFunctions(HDBC ConnectionHandle,
- SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported)
+RETCODE SQL_API
+SQLGetFunctions(HDBC ConnectionHandle,
+ SQLUSMALLINT FunctionId, SQLUSMALLINT * Supported)
{
mylog("[SQLGetFunctions]");
#if (ODBCVER >= 0x3000)
#endif
return PGAPI_GetFunctions(ConnectionHandle, FunctionId, Supported);
}
-RETCODE SQL_API SQLGetInfo(HDBC ConnectionHandle,
- SQLUSMALLINT InfoType, PTR InfoValue,
- SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
+RETCODE SQL_API
+SQLGetInfo(HDBC ConnectionHandle,
+ SQLUSMALLINT InfoType, PTR InfoValue,
+ SQLSMALLINT BufferLength, SQLSMALLINT * StringLength)
{
#if (ODBCVER >= 0x3000)
- RETCODE ret;
+ RETCODE ret;
+
mylog("[SQLGetInfo(30)]");
if ((ret = PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue,
- BufferLength, StringLength)) == SQL_ERROR)
+ BufferLength, StringLength)) == SQL_ERROR)
{
if (((ConnectionClass *) ConnectionHandle)->driver_version >= 0x3000)
return PGAPI_GetInfo30(ConnectionHandle, InfoType, InfoValue,
- BufferLength, StringLength);
+ BufferLength, StringLength);
}
return ret;
#else
mylog("[SQLGetInfo]");
return PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue,
- BufferLength, StringLength);
+ BufferLength, StringLength);
#endif
}
-RETCODE SQL_API SQLGetStmtOption(HSTMT StatementHandle,
- SQLUSMALLINT Option, PTR Value)
+RETCODE SQL_API
+SQLGetStmtOption(HSTMT StatementHandle,
+ SQLUSMALLINT Option, PTR Value)
{
mylog("[SQLGetStmtOption]");
return PGAPI_GetStmtOption(StatementHandle, Option, Value);
}
-RETCODE SQL_API SQLGetTypeInfo(HSTMT StatementHandle,
- SQLSMALLINT DataType)
+RETCODE SQL_API
+SQLGetTypeInfo(HSTMT StatementHandle,
+ SQLSMALLINT DataType)
{
mylog("[SQLGetTypeInfo]");
- return PGAPI_GetTypeInfo(StatementHandle,DataType);
+ return PGAPI_GetTypeInfo(StatementHandle, DataType);
}
-RETCODE SQL_API SQLNumResultCols(HSTMT StatementHandle,
- SQLSMALLINT *ColumnCount)
+RETCODE SQL_API
+SQLNumResultCols(HSTMT StatementHandle,
+ SQLSMALLINT * ColumnCount)
{
mylog("[SQLNumResultCols]");
return PGAPI_NumResultCols(StatementHandle, ColumnCount);
}
-RETCODE SQL_API SQLParamData(HSTMT StatementHandle,
- PTR *Value)
+RETCODE SQL_API
+SQLParamData(HSTMT StatementHandle,
+ PTR * Value)
{
mylog("[SQLParamData]");
return PGAPI_ParamData(StatementHandle, Value);
}
-RETCODE SQL_API SQLPrepare(HSTMT StatementHandle,
- SQLCHAR *StatementText, SQLINTEGER TextLength)
+RETCODE SQL_API
+SQLPrepare(HSTMT StatementHandle,
+ SQLCHAR * StatementText, SQLINTEGER TextLength)
{
mylog("[SQLPrepare]");
return PGAPI_Prepare(StatementHandle, StatementText, TextLength);
}
-RETCODE SQL_API SQLPutData(HSTMT StatementHandle,
- PTR Data, SQLINTEGER StrLen_or_Ind)
+RETCODE SQL_API
+SQLPutData(HSTMT StatementHandle,
+ PTR Data, SQLINTEGER StrLen_or_Ind)
{
mylog("[SQLPutData]");
return PGAPI_PutData(StatementHandle, Data, StrLen_or_Ind);
}
-RETCODE SQL_API SQLRowCount(HSTMT StatementHandle,
- SQLINTEGER *RowCount)
+RETCODE SQL_API
+SQLRowCount(HSTMT StatementHandle,
+ SQLINTEGER * RowCount)
{
mylog("[SQLRowCount]");
return PGAPI_RowCount(StatementHandle, RowCount);
}
-RETCODE SQL_API SQLSetConnectOption(HDBC ConnectionHandle,
- SQLUSMALLINT Option, SQLUINTEGER Value)
+RETCODE SQL_API
+SQLSetConnectOption(HDBC ConnectionHandle,
+ SQLUSMALLINT Option, SQLUINTEGER Value)
{
mylog("[SQLSetConnectionOption]");
return PGAPI_SetConnectOption(ConnectionHandle, Option, Value);
}
-RETCODE SQL_API SQLSetCursorName(HSTMT StatementHandle,
- SQLCHAR *CursorName, SQLSMALLINT NameLength)
+RETCODE SQL_API
+SQLSetCursorName(HSTMT StatementHandle,
+ SQLCHAR * CursorName, SQLSMALLINT NameLength)
{
mylog("[SQLSetCursorName]");
return PGAPI_SetCursorName(StatementHandle, CursorName, NameLength);
}
-RETCODE SQL_API SQLSetParam(HSTMT StatementHandle,
- SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
- SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
- SQLSMALLINT ParameterScale, PTR ParameterValue,
- SQLINTEGER *StrLen_or_Ind)
+RETCODE SQL_API
+SQLSetParam(HSTMT StatementHandle,
+ SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
+ SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
+ SQLSMALLINT ParameterScale, PTR ParameterValue,
+ SQLINTEGER * StrLen_or_Ind)
{
mylog("[SQLSetParam]");
+
/*
- return PGAPI_SetParam(StatementHandle, ParameterNumber, ValueType,
- ParameterType, LengthPrecision, ParameterScale, ParameterValue,
- StrLen_or_Ind);
- */
- return SQL_ERROR;
+ * return PGAPI_SetParam(StatementHandle, ParameterNumber, ValueType,
+ * ParameterType, LengthPrecision, ParameterScale, ParameterValue,
+ * StrLen_or_Ind);
+ */
+ return SQL_ERROR;
}
-RETCODE SQL_API SQLSetStmtOption(HSTMT StatementHandle,
- SQLUSMALLINT Option, SQLUINTEGER Value)
+RETCODE SQL_API
+SQLSetStmtOption(HSTMT StatementHandle,
+ SQLUSMALLINT Option, SQLUINTEGER Value)
{
mylog("[SQLSetStmtOption]");
return PGAPI_SetStmtOption(StatementHandle, Option, Value);
}
-RETCODE SQL_API SQLSpecialColumns(HSTMT StatementHandle,
- SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName,
- SQLSMALLINT NameLength1, SQLCHAR *SchemaName,
- SQLSMALLINT NameLength2, SQLCHAR *TableName,
- SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
- SQLUSMALLINT Nullable)
+RETCODE SQL_API
+SQLSpecialColumns(HSTMT StatementHandle,
+ SQLUSMALLINT IdentifierType, SQLCHAR * CatalogName,
+ SQLSMALLINT NameLength1, SQLCHAR * SchemaName,
+ SQLSMALLINT NameLength2, SQLCHAR * TableName,
+ SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
+ SQLUSMALLINT Nullable)
{
mylog("[SQLSpecialColumns]");
return PGAPI_SpecialColumns(StatementHandle, IdentifierType, CatalogName,
- NameLength1, SchemaName, NameLength2, TableName, NameLength3,
- Scope, Nullable);
+ NameLength1, SchemaName, NameLength2, TableName, NameLength3,
+ Scope, Nullable);
}
-RETCODE SQL_API SQLStatistics(HSTMT StatementHandle,
- SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
- SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
- SQLCHAR *TableName, SQLSMALLINT NameLength3,
- SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
+RETCODE SQL_API
+SQLStatistics(HSTMT StatementHandle,
+ SQLCHAR * CatalogName, SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName, SQLSMALLINT NameLength2,
+ SQLCHAR * TableName, SQLSMALLINT NameLength3,
+ SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
{
mylog("[SQLStatistics]");
return PGAPI_Statistics(StatementHandle, CatalogName, NameLength1,
- SchemaName, NameLength2, TableName, NameLength3, Unique,
- Reserved);
+ SchemaName, NameLength2, TableName, NameLength3, Unique,
+ Reserved);
}
-RETCODE SQL_API SQLTables(HSTMT StatementHandle,
- SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
- SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
- SQLCHAR *TableName, SQLSMALLINT NameLength3,
- SQLCHAR *TableType, SQLSMALLINT NameLength4)
+RETCODE SQL_API
+SQLTables(HSTMT StatementHandle,
+ SQLCHAR * CatalogName, SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName, SQLSMALLINT NameLength2,
+ SQLCHAR * TableName, SQLSMALLINT NameLength3,
+ SQLCHAR * TableType, SQLSMALLINT NameLength4)
{
mylog("[SQLTables]");
return PGAPI_Tables(StatementHandle, CatalogName, NameLength1,
- SchemaName, NameLength2, TableName, NameLength3,
- TableType, NameLength4);
+ SchemaName, NameLength2, TableName, NameLength3,
+ TableType, NameLength4);
}
-RETCODE SQL_API SQLTransact(HENV EnvironmentHandle,
- HDBC ConnectionHandle, SQLUSMALLINT CompletionType)
+RETCODE SQL_API
+SQLTransact(HENV EnvironmentHandle,
+ HDBC ConnectionHandle, SQLUSMALLINT CompletionType)
{
mylog("[SQLTransact]");
return PGAPI_Transact(EnvironmentHandle, ConnectionHandle, CompletionType);
}
-RETCODE SQL_API SQLColAttributes(
- HSTMT hstmt,
- SQLUSMALLINT icol,
- SQLUSMALLINT fDescType,
- PTR rgbDesc,
- SQLSMALLINT cbDescMax,
- SQLSMALLINT *pcbDesc,
- SQLINTEGER *pfDesc)
+RETCODE SQL_API
+SQLColAttributes(
+ HSTMT hstmt,
+ SQLUSMALLINT icol,
+ SQLUSMALLINT fDescType,
+ PTR rgbDesc,
+ SQLSMALLINT cbDescMax,
+ SQLSMALLINT * pcbDesc,
+ SQLINTEGER * pfDesc)
{
mylog("[SQLColAttributes]");
return PGAPI_ColAttributes(hstmt, icol, fDescType, rgbDesc,
- cbDescMax, pcbDesc, pfDesc);
+ cbDescMax, pcbDesc, pfDesc);
}
-RETCODE SQL_API SQLColumnPrivileges(
- HSTMT hstmt,
- SQLCHAR *szCatalogName,
- SQLSMALLINT cbCatalogName,
- SQLCHAR *szSchemaName,
- SQLSMALLINT cbSchemaName,
- SQLCHAR *szTableName,
- SQLSMALLINT cbTableName,
- SQLCHAR *szColumnName,
- SQLSMALLINT cbColumnName)
+RETCODE SQL_API
+SQLColumnPrivileges(
+ HSTMT hstmt,
+ SQLCHAR * szCatalogName,
+ SQLSMALLINT cbCatalogName,
+ SQLCHAR * szSchemaName,
+ SQLSMALLINT cbSchemaName,
+ SQLCHAR * szTableName,
+ SQLSMALLINT cbTableName,
+ SQLCHAR * szColumnName,
+ SQLSMALLINT cbColumnName)
{
mylog("[SQLColumnPrivileges]");
return PGAPI_ColumnPrivileges(hstmt, szCatalogName, cbCatalogName,
- szSchemaName, cbSchemaName, szTableName, cbTableName,
- szColumnName, cbColumnName);
+ szSchemaName, cbSchemaName, szTableName, cbTableName,
+ szColumnName, cbColumnName);
}
-RETCODE SQL_API SQLDescribeParam(
- HSTMT hstmt,
- SQLUSMALLINT ipar,
- SQLSMALLINT *pfSqlType,
- SQLUINTEGER *pcbParamDef,
- SQLSMALLINT *pibScale,
- SQLSMALLINT *pfNullable)
+RETCODE SQL_API
+SQLDescribeParam(
+ HSTMT hstmt,
+ SQLUSMALLINT ipar,
+ SQLSMALLINT * pfSqlType,
+ SQLUINTEGER * pcbParamDef,
+ SQLSMALLINT * pibScale,
+ SQLSMALLINT * pfNullable)
{
mylog("[SQLDescribeParam]");
return PGAPI_DescribeParam(hstmt, ipar, pfSqlType, pcbParamDef,
- pibScale, pfNullable);
+ pibScale, pfNullable);
}
-RETCODE SQL_API SQLExtendedFetch(
- HSTMT hstmt,
- SQLUSMALLINT fFetchType,
- SQLINTEGER irow,
- SQLUINTEGER *pcrow,
- SQLUSMALLINT *rgfRowStatus)
+RETCODE SQL_API
+SQLExtendedFetch(
+ HSTMT hstmt,
+ SQLUSMALLINT fFetchType,
+ SQLINTEGER irow,
+ SQLUINTEGER * pcrow,
+ SQLUSMALLINT * rgfRowStatus)
{
mylog("[SQLExtendedFetch]");
return PGAPI_ExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus);
}
-RETCODE SQL_API SQLForeignKeys(
- HSTMT hstmt,
- SQLCHAR *szPkCatalogName,
- SQLSMALLINT cbPkCatalogName,
- SQLCHAR *szPkSchemaName,
- SQLSMALLINT cbPkSchemaName,
- SQLCHAR *szPkTableName,
- SQLSMALLINT cbPkTableName,
- SQLCHAR *szFkCatalogName,
- SQLSMALLINT cbFkCatalogName,
- SQLCHAR *szFkSchemaName,
- SQLSMALLINT cbFkSchemaName,
- SQLCHAR *szFkTableName,
- SQLSMALLINT cbFkTableName)
+RETCODE SQL_API
+SQLForeignKeys(
+ HSTMT hstmt,
+ SQLCHAR * szPkCatalogName,
+ SQLSMALLINT cbPkCatalogName,
+ SQLCHAR * szPkSchemaName,
+ SQLSMALLINT cbPkSchemaName,
+ SQLCHAR * szPkTableName,
+ SQLSMALLINT cbPkTableName,
+ SQLCHAR * szFkCatalogName,
+ SQLSMALLINT cbFkCatalogName,
+ SQLCHAR * szFkSchemaName,
+ SQLSMALLINT cbFkSchemaName,
+ SQLCHAR * szFkTableName,
+ SQLSMALLINT cbFkTableName)
{
mylog("[SQLForeignKeys]");
return PGAPI_ForeignKeys(hstmt, szPkCatalogName, cbPkCatalogName,
- szPkSchemaName, cbPkSchemaName, szPkTableName,
- cbPkTableName, szFkCatalogName, cbFkCatalogName,
- szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
+ szPkSchemaName, cbPkSchemaName, szPkTableName,
+ cbPkTableName, szFkCatalogName, cbFkCatalogName,
+ szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
}
-RETCODE SQL_API SQLMoreResults(HSTMT hstmt)
+RETCODE SQL_API
+SQLMoreResults(HSTMT hstmt)
{
mylog("[SQLMoreResults]");
return PGAPI_MoreResults(hstmt);
}
-
-RETCODE SQL_API SQLNativeSql(
- HDBC hdbc,
- SQLCHAR *szSqlStrIn,
- SQLINTEGER cbSqlStrIn,
- SQLCHAR *szSqlStr,
- SQLINTEGER cbSqlStrMax,
- SQLINTEGER *pcbSqlStr)
+
+RETCODE SQL_API
+SQLNativeSql(
+ HDBC hdbc,
+ SQLCHAR * szSqlStrIn,
+ SQLINTEGER cbSqlStrIn,
+ SQLCHAR * szSqlStr,
+ SQLINTEGER cbSqlStrMax,
+ SQLINTEGER * pcbSqlStr)
{
mylog("[SQLNativeSql]");
return PGAPI_NativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr,
- cbSqlStrMax, pcbSqlStr);
+ cbSqlStrMax, pcbSqlStr);
}
-RETCODE SQL_API SQLNumParams(
- HSTMT hstmt,
- SQLSMALLINT *pcpar)
+RETCODE SQL_API
+SQLNumParams(
+ HSTMT hstmt,
+ SQLSMALLINT * pcpar)
{
mylog("[SQLNumParams]");
return PGAPI_NumParams(hstmt, pcpar);
}
-RETCODE SQL_API SQLParamOptions(
- HSTMT hstmt,
- SQLUINTEGER crow,
- SQLUINTEGER *pirow)
+RETCODE SQL_API
+SQLParamOptions(
+ HSTMT hstmt,
+ SQLUINTEGER crow,
+ SQLUINTEGER * pirow)
{
mylog("[SQLParamOptions]");
return PGAPI_ParamOptions(hstmt, crow, pirow);
}
-RETCODE SQL_API SQLPrimaryKeys(
- HSTMT hstmt,
- SQLCHAR *szCatalogName,
- SQLSMALLINT cbCatalogName,
- SQLCHAR *szSchemaName,
- SQLSMALLINT cbSchemaName,
- SQLCHAR *szTableName,
- SQLSMALLINT cbTableName)
+RETCODE SQL_API
+SQLPrimaryKeys(
+ HSTMT hstmt,
+ SQLCHAR * szCatalogName,
+ SQLSMALLINT cbCatalogName,
+ SQLCHAR * szSchemaName,
+ SQLSMALLINT cbSchemaName,
+ SQLCHAR * szTableName,
+ SQLSMALLINT cbTableName)
{
mylog("[SQLPrimaryKeys]");
return PGAPI_PrimaryKeys(hstmt, szCatalogName, cbCatalogName,
- szSchemaName, cbSchemaName, szTableName, cbTableName);
+ szSchemaName, cbSchemaName, szTableName, cbTableName);
}
-RETCODE SQL_API SQLProcedureColumns(
- HSTMT hstmt,
- SQLCHAR *szCatalogName,
- SQLSMALLINT cbCatalogName,
- SQLCHAR *szSchemaName,
- SQLSMALLINT cbSchemaName,
- SQLCHAR *szProcName,
- SQLSMALLINT cbProcName,
- SQLCHAR *szColumnName,
- SQLSMALLINT cbColumnName)
+RETCODE SQL_API
+SQLProcedureColumns(
+ HSTMT hstmt,
+ SQLCHAR * szCatalogName,
+ SQLSMALLINT cbCatalogName,
+ SQLCHAR * szSchemaName,
+ SQLSMALLINT cbSchemaName,
+ SQLCHAR * szProcName,
+ SQLSMALLINT cbProcName,
+ SQLCHAR * szColumnName,
+ SQLSMALLINT cbColumnName)
{
mylog("[SQLProcedureColumns]");
return PGAPI_ProcedureColumns(hstmt, szCatalogName, cbCatalogName,
- szSchemaName, cbSchemaName, szProcName, cbProcName,
- szColumnName, cbColumnName);
+ szSchemaName, cbSchemaName, szProcName, cbProcName,
+ szColumnName, cbColumnName);
}
-RETCODE SQL_API SQLProcedures(
- HSTMT hstmt,
- SQLCHAR *szCatalogName,
- SQLSMALLINT cbCatalogName,
- SQLCHAR *szSchemaName,
- SQLSMALLINT cbSchemaName,
- SQLCHAR *szProcName,
- SQLSMALLINT cbProcName)
+RETCODE SQL_API
+SQLProcedures(
+ HSTMT hstmt,
+ SQLCHAR * szCatalogName,
+ SQLSMALLINT cbCatalogName,
+ SQLCHAR * szSchemaName,
+ SQLSMALLINT cbSchemaName,
+ SQLCHAR * szProcName,
+ SQLSMALLINT cbProcName)
{
mylog("[SQLProcedures]");
return PGAPI_Procedures(hstmt, szCatalogName, cbCatalogName,
- szSchemaName, cbSchemaName, szProcName, cbProcName);
+ szSchemaName, cbSchemaName, szProcName, cbProcName);
}
-RETCODE SQL_API SQLSetPos(
- HSTMT hstmt,
- SQLUSMALLINT irow,
- SQLUSMALLINT fOption,
- SQLUSMALLINT fLock)
+RETCODE SQL_API
+SQLSetPos(
+ HSTMT hstmt,
+ SQLUSMALLINT irow,
+ SQLUSMALLINT fOption,
+ SQLUSMALLINT fLock)
{
mylog("[SQLSetPos]");
return PGAPI_SetPos(hstmt, irow, fOption, fLock);
}
-RETCODE SQL_API SQLTablePrivileges(
- HSTMT hstmt,
- SQLCHAR *szCatalogName,
- SQLSMALLINT cbCatalogName,
- SQLCHAR *szSchemaName,
- SQLSMALLINT cbSchemaName,
- SQLCHAR *szTableName,
- SQLSMALLINT cbTableName)
+RETCODE SQL_API
+SQLTablePrivileges(
+ HSTMT hstmt,
+ SQLCHAR * szCatalogName,
+ SQLSMALLINT cbCatalogName,
+ SQLCHAR * szSchemaName,
+ SQLSMALLINT cbSchemaName,
+ SQLCHAR * szTableName,
+ SQLSMALLINT cbTableName)
{
mylog("[SQLTablePrivileges]");
return PGAPI_TablePrivileges(hstmt, szCatalogName, cbCatalogName,
- szSchemaName, cbSchemaName, szTableName, cbTableName);
-}
-
-RETCODE SQL_API SQLBindParameter(
- HSTMT hstmt,
- SQLUSMALLINT ipar,
- SQLSMALLINT fParamType,
- SQLSMALLINT fCType,
- SQLSMALLINT fSqlType,
- SQLUINTEGER cbColDef,
- SQLSMALLINT ibScale,
- PTR rgbValue,
- SQLINTEGER cbValueMax,
- SQLINTEGER *pcbValue)
+ szSchemaName, cbSchemaName, szTableName, cbTableName);
+}
+
+RETCODE SQL_API
+SQLBindParameter(
+ HSTMT hstmt,
+ SQLUSMALLINT ipar,
+ SQLSMALLINT fParamType,
+ SQLSMALLINT fCType,
+ SQLSMALLINT fSqlType,
+ SQLUINTEGER cbColDef,
+ SQLSMALLINT ibScale,
+ PTR rgbValue,
+ SQLINTEGER cbValueMax,
+ SQLINTEGER * pcbValue)
{
mylog("[SQLBindParameter]");
return PGAPI_BindParameter(hstmt, ipar, fParamType, fCType,
- fSqlType, cbColDef, ibScale, rgbValue, cbValueMax,
- pcbValue);
+ fSqlType, cbColDef, ibScale, rgbValue, cbValueMax,
+ pcbValue);
}
#include "pgapifunc.h"
/* SQLAllocConnect/SQLAllocEnv/SQLAllocStmt -> SQLAllocHandle */
-RETCODE SQL_API SQLAllocHandle(SQLSMALLINT HandleType,
- SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
+RETCODE SQL_API
+SQLAllocHandle(SQLSMALLINT HandleType,
+ SQLHANDLE InputHandle, SQLHANDLE * OutputHandle)
{
mylog("[[SQLAllocHandle]]");
switch (HandleType)
return PGAPI_AllocConnect(InputHandle, OutputHandle);
case SQL_HANDLE_STMT:
return PGAPI_AllocStmt(InputHandle, OutputHandle);
- default: break;
+ default:
+ break;
}
return SQL_ERROR;
}
+
/* SQLBindParameter/SQLSetParam -> SQLBindParam */
-RETCODE SQL_API SQLBindParam(HSTMT StatementHandle,
- SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
- SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
- SQLSMALLINT ParameterScale, PTR ParameterValue,
- SQLINTEGER *StrLen_or_Ind)
+RETCODE SQL_API
+SQLBindParam(HSTMT StatementHandle,
+ SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
+ SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
+ SQLSMALLINT ParameterScale, PTR ParameterValue,
+ SQLINTEGER * StrLen_or_Ind)
{
- int BufferLength = 512; /* Is it OK ? */
+ int BufferLength = 512; /* Is it OK ? */
+
mylog("[[SQLBindParam]]");
return PGAPI_BindParameter(StatementHandle, ParameterNumber, SQL_PARAM_INPUT, ValueType, ParameterType, LengthPrecision, ParameterScale, ParameterValue, BufferLength, StrLen_or_Ind);
}
+
/* New function */
-RETCODE SQL_API SQLCloseCursor(HSTMT StatementHandle)
+RETCODE SQL_API
+SQLCloseCursor(HSTMT StatementHandle)
{
mylog("[[SQLCloseCursor]]");
return PGAPI_FreeStmt(StatementHandle, SQL_CLOSE);
}
/* SQLColAttributes -> SQLColAttribute */
-RETCODE SQL_API SQLColAttribute (HSTMT StatementHandle,
- SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
- PTR CharacterAttribute, SQLSMALLINT BufferLength,
- SQLSMALLINT *StringLength, PTR NumericAttribute)
+RETCODE SQL_API
+SQLColAttribute(HSTMT StatementHandle,
+ SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
+ PTR CharacterAttribute, SQLSMALLINT BufferLength,
+ SQLSMALLINT * StringLength, PTR NumericAttribute)
{
mylog("[[SQLColAttribute]]");
return PGAPI_ColAttributes(StatementHandle, ColumnNumber,
- FieldIdentifier, CharacterAttribute, BufferLength,
- StringLength, NumericAttribute);
+ FieldIdentifier, CharacterAttribute, BufferLength,
+ StringLength, NumericAttribute);
}
+
/* new function */
-RETCODE SQL_API SQLCopyDesc(SQLHDESC SourceDescHandle,
- SQLHDESC TargetDescHandle)
+RETCODE SQL_API
+SQLCopyDesc(SQLHDESC SourceDescHandle,
+ SQLHDESC TargetDescHandle)
{
mylog("[[SQLCopyDesc]]\n");
return SQL_ERROR;
}
-/* SQLTransact -> SQLEndTran */
-RETCODE SQL_API SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle,
- SQLSMALLINT CompletionType)
+
+/* SQLTransact -> SQLEndTran */
+RETCODE SQL_API
+SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle,
+ SQLSMALLINT CompletionType)
{
mylog("[[SQLEndTran]]");
switch (HandleType)
{
- case SQL_HANDLE_ENV:
+ case SQL_HANDLE_ENV:
return PGAPI_Transact(Handle, SQL_NULL_HDBC, CompletionType);
- case SQL_HANDLE_DBC:
+ case SQL_HANDLE_DBC:
return PGAPI_Transact(SQL_NULL_HENV, Handle, CompletionType);
- default:break;
+ default:
+ break;
}
- return SQL_ERROR; /* SQLSTATE HY092 ("Invalid attribute/option identifier")*/
+ return SQL_ERROR; /* SQLSTATE HY092 ("Invalid
+ * attribute/option identifier") */
}
+
/* SQLExtendedFetch -> SQLFetchScroll */
-RETCODE SQL_API SQLFetchScroll(HSTMT StatementHandle,
- SQLSMALLINT FetchOrientation, SQLINTEGER FetchOffset)
+RETCODE SQL_API
+SQLFetchScroll(HSTMT StatementHandle,
+ SQLSMALLINT FetchOrientation, SQLINTEGER FetchOffset)
{
static char *func = "SQLFetchScroll";
- StatementClass *stmt = (StatementClass *) StatementHandle;
- RETCODE ret;
- SQLUSMALLINT *rowStatusArray = stmt->options.rowStatusArray;
- SQLINTEGER *pcRow = stmt->options.rowsFetched;
+ StatementClass *stmt = (StatementClass *) StatementHandle;
+ RETCODE ret;
+ SQLUSMALLINT *rowStatusArray = stmt->options.rowStatusArray;
+ SQLINTEGER *pcRow = stmt->options.rowsFetched;
+
mylog("[[%s]] %d,%d\n", func, FetchOrientation, FetchOffset);
if (FetchOrientation == SQL_FETCH_BOOKMARK)
{
}
}
ret = PGAPI_ExtendedFetch(StatementHandle, FetchOrientation, FetchOffset,
- pcRow, rowStatusArray);
+ pcRow, rowStatusArray);
if (ret != SQL_SUCCESS)
mylog("%s return = %d\n", func, ret);
return ret;
}
+
/* SQLFree(Connect/Env/Stmt) -> SQLFreeHandle */
-RETCODE SQL_API SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
+RETCODE SQL_API
+SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
{
mylog("[[SQLFreeHandle]]");
switch (HandleType)
return PGAPI_FreeConnect(Handle);
case SQL_HANDLE_STMT:
return PGAPI_FreeStmt(Handle, SQL_DROP);
- default: break;
+ default:
+ break;
}
return SQL_ERROR;
}
+
/* new function */
-RETCODE SQL_API SQLGetDescField(SQLHDESC DescriptorHandle,
- SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
- PTR Value, SQLINTEGER BufferLength,
- SQLINTEGER *StringLength)
+RETCODE SQL_API
+SQLGetDescField(SQLHDESC DescriptorHandle,
+ SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
+ PTR Value, SQLINTEGER BufferLength,
+ SQLINTEGER * StringLength)
{
mylog("[[SQLGetDescField]]\n");
return SQL_ERROR;
}
+
/* new function */
-RETCODE SQL_API SQLGetDescRec(SQLHDESC DescriptorHandle,
- SQLSMALLINT RecNumber, SQLCHAR *Name,
- SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
- SQLSMALLINT *Type, SQLSMALLINT *SubType,
- SQLINTEGER *Length, SQLSMALLINT *Precision,
- SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
+RETCODE SQL_API
+SQLGetDescRec(SQLHDESC DescriptorHandle,
+ SQLSMALLINT RecNumber, SQLCHAR * Name,
+ SQLSMALLINT BufferLength, SQLSMALLINT * StringLength,
+ SQLSMALLINT * Type, SQLSMALLINT * SubType,
+ SQLINTEGER * Length, SQLSMALLINT * Precision,
+ SQLSMALLINT * Scale, SQLSMALLINT * Nullable)
{
mylog("[[SQLGetDescRec]]\n");
return SQL_ERROR;
}
+
/* new function */
-RETCODE SQL_API SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
- SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
- PTR DiagInfo, SQLSMALLINT BufferLength,
- SQLSMALLINT *StringLength)
+RETCODE SQL_API
+SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
+ SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
+ PTR DiagInfo, SQLSMALLINT BufferLength,
+ SQLSMALLINT * StringLength)
{
mylog("[[SQLGetDiagField]]\n");
return SQL_ERROR;
}
+
/* SQLError -> SQLDiagRec */
-RETCODE SQL_API SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle,
- SQLSMALLINT RecNumber, SQLCHAR *Sqlstate,
- SQLINTEGER *NativeError, SQLCHAR *MessageText,
- SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
+RETCODE SQL_API
+SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle,
+ SQLSMALLINT RecNumber, SQLCHAR * Sqlstate,
+ SQLINTEGER * NativeError, SQLCHAR * MessageText,
+ SQLSMALLINT BufferLength, SQLSMALLINT * TextLength)
{
- RETCODE ret;
+ RETCODE ret;
+
mylog("[[SQLGetDiagRec]]\n");
switch (HandleType)
{
case SQL_HANDLE_ENV:
ret = PGAPI_Error(Handle, NULL, NULL, Sqlstate, NativeError,
- MessageText, BufferLength, TextLength);
+ MessageText, BufferLength, TextLength);
break;
case SQL_HANDLE_DBC:
- ret = PGAPI_Error(NULL, Handle, NULL, Sqlstate, NativeError,
- MessageText, BufferLength, TextLength);
+ ret = PGAPI_Error(NULL, Handle, NULL, Sqlstate, NativeError,
+ MessageText, BufferLength, TextLength);
break;
case SQL_HANDLE_STMT:
ret = PGAPI_Error(NULL, NULL, Handle, Sqlstate, NativeError,
- MessageText, BufferLength, TextLength);
+ MessageText, BufferLength, TextLength);
break;
default:
ret = SQL_ERROR;
}
if (ret == SQL_SUCCESS_WITH_INFO &&
- BufferLength == 0 &&
- *TextLength)
+ BufferLength == 0 &&
+ *TextLength)
{
- SQLSMALLINT BufferLength = *TextLength + 4;
- SQLCHAR *MessageText = malloc(BufferLength);
+ SQLSMALLINT BufferLength = *TextLength + 4;
+ SQLCHAR *MessageText = malloc(BufferLength);
+
ret = SQLGetDiagRec(HandleType, Handle, RecNumber, Sqlstate,
- NativeError, MessageText, BufferLength,
- TextLength);
+ NativeError, MessageText, BufferLength,
+ TextLength);
free(MessageText);
}
return ret;
}
+
/* new function */
-RETCODE SQL_API SQLGetEnvAttr(HENV EnvironmentHandle,
- SQLINTEGER Attribute, PTR Value,
- SQLINTEGER BufferLength, SQLINTEGER *StringLength)
+RETCODE SQL_API
+SQLGetEnvAttr(HENV EnvironmentHandle,
+ SQLINTEGER Attribute, PTR Value,
+ SQLINTEGER BufferLength, SQLINTEGER * StringLength)
{
EnvironmentClass *env = (EnvironmentClass *) EnvironmentHandle;
+
mylog("[[SQLGetEnvAttr]] %d\n", Attribute);
switch (Attribute)
{
}
return SQL_SUCCESS;
}
+
/* SQLGetConnectOption -> SQLGetconnectAttr */
-RETCODE SQL_API SQLGetConnectAttr(HDBC ConnectionHandle,
- SQLINTEGER Attribute, PTR Value,
- SQLINTEGER BufferLength, SQLINTEGER *StringLength)
+RETCODE SQL_API
+SQLGetConnectAttr(HDBC ConnectionHandle,
+ SQLINTEGER Attribute, PTR Value,
+ SQLINTEGER BufferLength, SQLINTEGER * StringLength)
{
- ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;
+ ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;
+
mylog("[[SQLGetConnectAttr]] %d\n", Attribute);
switch (Attribute)
{
conn->errormsg = "Unsupported connection option (Set)";
return SQL_ERROR;
}
- return PGAPI_GetConnectOption (ConnectionHandle, (UWORD) Attribute, Value);
+ return PGAPI_GetConnectOption(ConnectionHandle, (UWORD) Attribute, Value);
}
+
/* SQLGetStmtOption -> SQLGetStmtAttr */
-RETCODE SQL_API SQLGetStmtAttr(HSTMT StatementHandle,
- SQLINTEGER Attribute, PTR Value,
- SQLINTEGER BufferLength, SQLINTEGER *StringLength)
+RETCODE SQL_API
+SQLGetStmtAttr(HSTMT StatementHandle,
+ SQLINTEGER Attribute, PTR Value,
+ SQLINTEGER BufferLength, SQLINTEGER * StringLength)
{
static char *func = "SQLGetStmtAttr";
- StatementClass *stmt = (StatementClass *) StatementHandle;
- RETCODE ret = SQL_SUCCESS;
- int len = 0;
+ StatementClass *stmt = (StatementClass *) StatementHandle;
+ RETCODE ret = SQL_SUCCESS;
+ int len = 0;
+
mylog("[[%s]] %d\n", func, Attribute);
switch (Attribute)
{
- case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */
+ case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */
Value = stmt->options.bookmark_ptr;
+
len = 4;
- break;
+ break;
case SQL_ATTR_ROW_STATUS_PTR: /* 25 */
Value = stmt->options.rowStatusArray;
+
len = 4;
break;
- case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */
+ case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */
Value = stmt->options.rowsFetched;
+
len = 4;
break;
case SQL_ATTR_ROW_ARRAY_SIZE: /* 27 */
*((SQLUINTEGER *) Value) = stmt->options.rowset_size;
len = 4;
- break;
- case SQL_ATTR_APP_ROW_DESC: /* 10010 */
- *((HSTMT *) Value) = StatementHandle; /* this is useless */
+ break;
+ case SQL_ATTR_APP_ROW_DESC: /* 10010 */
+ *((HSTMT *) Value) = StatementHandle; /* this is useless */
len = 4;
- break;
+ break;
case SQL_ATTR_APP_PARAM_DESC: /* 10011 */
- *((HSTMT *) Value) = StatementHandle; /* this is useless */
+ *((HSTMT *) Value) = StatementHandle; /* this is useless */
len = 4;
- break;
- case SQL_ATTR_IMP_ROW_DESC: /* 10012 */
- *((HSTMT *) Value) = StatementHandle; /* this is useless */
+ break;
+ case SQL_ATTR_IMP_ROW_DESC: /* 10012 */
+ *((HSTMT *) Value) = StatementHandle; /* this is useless */
len = 4;
- break;
+ break;
case SQL_ATTR_IMP_PARAM_DESC: /* 10013 */
- *((HSTMT *) Value) = StatementHandle; /* this is useless */
+ *((HSTMT *) Value) = StatementHandle; /* this is useless */
len = 4;
- break;
- case SQL_ATTR_AUTO_IPD: /* 10001 */
+ break;
+ case SQL_ATTR_AUTO_IPD:/* 10001 */
case SQL_ATTR_ROW_BIND_TYPE: /* == SQL_BIND_TYPE */
case SQL_ATTR_PARAMSET_SIZE: /* 22 */
- case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */
- case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */
+ case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */
+ case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */
- case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */
- case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */
+ case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */
+ case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */
case SQL_ATTR_ENABLE_AUTO_IPD: /* 15 */
- case SQL_ATTR_METADATA_ID: /* 10014 */
- /* case SQL_ATTR_PREDICATE_PTR:
- case SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR: */
+ case SQL_ATTR_METADATA_ID: /* 10014 */
+
+ /*
+ * case SQL_ATTR_PREDICATE_PTR: case
+ * SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR:
+ */
case SQL_ATTR_PARAM_BIND_OFFSET_PTR: /* 17 */
- case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */
- case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */
- case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */
- case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */
+ case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */
+ case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */
+ case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */
+ case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */
stmt->errornumber = STMT_INVALID_OPTION_IDENTIFIER;
stmt->errormsg = "Unsupported statement option (Get)";
SC_log_error(func, "", stmt);
}
/* SQLSetConnectOption -> SQLSetConnectAttr */
-RETCODE SQL_API SQLSetConnectAttr(HDBC ConnectionHandle,
- SQLINTEGER Attribute, PTR Value,
- SQLINTEGER StringLength)
+RETCODE SQL_API
+SQLSetConnectAttr(HDBC ConnectionHandle,
+ SQLINTEGER Attribute, PTR Value,
+ SQLINTEGER StringLength)
{
- ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;
+ ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;
mylog("[[SQLSetConnectAttr]] %d\n", Attribute);
switch (Attribute)
}
return PGAPI_SetConnectOption(ConnectionHandle, (UWORD) Attribute, (UDWORD) Value);
}
+
/* new function */
-RETCODE SQL_API SQLSetDescField(SQLHDESC DescriptorHandle,
- SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
- PTR Value, SQLINTEGER BufferLength)
+RETCODE SQL_API
+SQLSetDescField(SQLHDESC DescriptorHandle,
+ SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
+ PTR Value, SQLINTEGER BufferLength)
{
mylog("[[SQLSetDescField]]\n");
return SQL_ERROR;
}
+
/* new fucntion */
-RETCODE SQL_API SQLSetDescRec(SQLHDESC DescriptorHandle,
- SQLSMALLINT RecNumber, SQLSMALLINT Type,
- SQLSMALLINT SubType, SQLINTEGER Length,
- SQLSMALLINT Precision, SQLSMALLINT Scale,
- PTR Data, SQLINTEGER *StringLength,
- SQLINTEGER *Indicator)
+RETCODE SQL_API
+SQLSetDescRec(SQLHDESC DescriptorHandle,
+ SQLSMALLINT RecNumber, SQLSMALLINT Type,
+ SQLSMALLINT SubType, SQLINTEGER Length,
+ SQLSMALLINT Precision, SQLSMALLINT Scale,
+ PTR Data, SQLINTEGER * StringLength,
+ SQLINTEGER * Indicator)
{
mylog("[[SQLsetDescRec]]\n");
return SQL_ERROR;
}
+
/* new function */
-RETCODE SQL_API SQLSetEnvAttr(HENV EnvironmentHandle,
- SQLINTEGER Attribute, PTR Value,
- SQLINTEGER StringLength)
+RETCODE SQL_API
+SQLSetEnvAttr(HENV EnvironmentHandle,
+ SQLINTEGER Attribute, PTR Value,
+ SQLINTEGER StringLength)
{
EnvironmentClass *env = (EnvironmentClass *) EnvironmentHandle;
+
mylog("[[SQLSetEnvAttr]] att=%d,%u\n", Attribute, Value);
switch (Attribute)
{
env->errormsg = "SetEnv changed to ";
return SQL_SUCCESS_WITH_INFO;
}
+
/* SQLSet(Param/Scroll/Stmt)Option -> SQLSetStmtAttr */
-RETCODE SQL_API SQLSetStmtAttr(HSTMT StatementHandle,
- SQLINTEGER Attribute, PTR Value,
- SQLINTEGER StringLength)
+RETCODE SQL_API
+SQLSetStmtAttr(HSTMT StatementHandle,
+ SQLINTEGER Attribute, PTR Value,
+ SQLINTEGER StringLength)
{
static char *func = "SQLSetStmtAttr";
- StatementClass *stmt = (StatementClass *) StatementHandle;
- UDWORD rowcount;
+ StatementClass *stmt = (StatementClass *) StatementHandle;
+ UDWORD rowcount;
+
mylog("[[%s]] %d,%u\n", func, Attribute, Value);
switch (Attribute)
{
case SQL_ATTR_PARAMSET_SIZE: /* 22 */
return PGAPI_ParamOptions(StatementHandle, (UWORD) Value, &rowcount);
- case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */
- case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */
+ case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */
+ case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */
- case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */
- case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */
+ case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */
+ case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */
case SQL_ATTR_ENABLE_AUTO_IPD: /* 15 */
- case SQL_ATTR_APP_ROW_DESC: /* 10010 */
+ case SQL_ATTR_APP_ROW_DESC: /* 10010 */
case SQL_ATTR_APP_PARAM_DESC: /* 10011 */
- case SQL_ATTR_AUTO_IPD: /* 10001 */
- /*case SQL_ATTR_ROW_BIND_TYPE:*/ /* == SQL_BIND_TYPE */
- case SQL_ATTR_IMP_ROW_DESC: /* 10012 */
+ case SQL_ATTR_AUTO_IPD:/* 10001 */
+ /* case SQL_ATTR_ROW_BIND_TYPE: *//* == SQL_BIND_TYPE */
+ case SQL_ATTR_IMP_ROW_DESC: /* 10012 */
case SQL_ATTR_IMP_PARAM_DESC: /* 10013 */
- case SQL_ATTR_METADATA_ID: /* 10014 */
- /* case SQL_ATTR_PREDICATE_PTR:
- case SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR: */
+ case SQL_ATTR_METADATA_ID: /* 10014 */
+
+ /*
+ * case SQL_ATTR_PREDICATE_PTR: case
+ * SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR:
+ */
case SQL_ATTR_PARAM_BIND_OFFSET_PTR: /* 17 */
- case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */
- case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */
- case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */
- case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */
+ case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */
+ case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */
+ case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */
+ case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */
stmt->errornumber = STMT_INVALID_OPTION_IDENTIFIER;
stmt->errormsg = "Unsupported statement option (Set)";
SC_log_error(func, "", stmt);
return SQL_ERROR;
-
- case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */
+
+ case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */
stmt->options.bookmark_ptr = Value;
+
break;
case SQL_ATTR_ROW_STATUS_PTR: /* 25 */
stmt->options.rowStatusArray = (SQLUSMALLINT *) Value;
+
break;
- case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */
+ case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */
stmt->options.rowsFetched = (SQLUINTEGER *) Value;
+
break;
- case SQL_ATTR_ROW_ARRAY_SIZE: /* 27 */
+ case SQL_ATTR_ROW_ARRAY_SIZE: /* 27 */
stmt->options.rowset_size = (SQLUINTEGER) Value;
+
break;
- default:
+ default:
return PGAPI_SetStmtOption(StatementHandle, (UWORD) Attribute, (UDWORD) Value);
}
return SQL_SUCCESS;
(*(((UWORD*) (pfExists)) + ((uwAPI) >> 4)) \
|= (1 << ((uwAPI) & 0x000F)) \
)
-RETCODE SQL_API
-PGAPI_GetFunctions30(HDBC hdbc, UWORD fFunction, UWORD FAR *pfExists)
+RETCODE SQL_API
+PGAPI_GetFunctions30(HDBC hdbc, UWORD fFunction, UWORD FAR * pfExists)
{
if (fFunction != SQL_API_ODBC3_ALL_FUNCTIONS)
return SQL_ERROR;
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCCONNECT); 1 deprecated */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCENV); 2 deprecated */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCSTMT); 3 deprecated */
- /* for (i = SQL_API_SQLBINDCOL; i <= 23; i++)
- SQL_FUNC_ESET(pfExists, i); */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDCOL); /* 4 */
+
+ /*
+ * for (i = SQL_API_SQLBINDCOL; i <= 23; i++) SQL_FUNC_ESET(pfExists,
+ * i);
+ */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDCOL); /* 4 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLCANCEL); /* 5 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLATTRIBUTE); /* 6 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLCONNECT); /* 7 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBECOL); /* 8 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLDISCONNECT); /* 9 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLATTRIBUTE); /* 6 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLCONNECT); /* 7 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBECOL); /* 8 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLDISCONNECT); /* 9 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLERROR); 10 deprecated */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECDIRECT); /* 11 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECUTE); /* 12 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCH); /* 13 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECDIRECT); /* 11 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECUTE); /* 12 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCH); /* 13 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLFREECONNECT); 14 deprecated */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEENV); 15 deprecated */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLFREESTMT); /* 16 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCURSORNAME); /* 17 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMRESULTCOLS); /* 18 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLPREPARE); /* 19 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLROWCOUNT); /* 20 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCURSORNAME); /* 21 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLFREESTMT); /* 16 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCURSORNAME); /* 17 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMRESULTCOLS); /* 18 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLPREPARE); /* 19 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLROWCOUNT); /* 20 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCURSORNAME); /* 21 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETPARAM); 22 deprecated */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLTRANSACT); 23 deprecated */
- /*for (i = 40; i < SQL_API_SQLEXTENDEDFETCH; i++)
- SQL_FUNC_ESET(pfExists, i);*/
- SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNS); /* 40 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERCONNECT); /* 41 */
+
+ /*
+ * for (i = 40; i < SQL_API_SQLEXTENDEDFETCH; i++)
+ * SQL_FUNC_ESET(pfExists, i);
+ */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNS); /* 40 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERCONNECT); /* 41 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCONNECTOPTION); 42 deprecated */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDATA); /* 43 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLGETFUNCTIONS); /* 44 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLGETINFO); /* 45 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDATA); /* 43 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETFUNCTIONS); /* 44 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETINFO); /* 45 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTOPTION); 46 deprecated */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLGETTYPEINFO); /* 47 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLPARAMDATA); /* 48 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLPUTDATA); /* 49 */
- /* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTIONOPTION); 50 deprecated */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETTYPEINFO); /* 47 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLPARAMDATA); /* 48 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLPUTDATA); /* 49 */
+
+ /*
+ * SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTIONOPTION); 50
+ * deprecated
+ */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTOPTION); 51 deprecated */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSPECIALCOLUMNS); /* 52 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLSTATISTICS); /* 53 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLSTATISTICS); /* 53 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLTABLES); /* 54 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLBROWSECONNECT); /* 55 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNPRIVILEGES); /* 56 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLDATASOURCES); /* 57 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBEPARAM); /* 58 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLBROWSECONNECT); /* 55 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNPRIVILEGES); /* 56 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLDATASOURCES); /* 57 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBEPARAM); /* 58 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLEXTENDEDFETCH); 59 deprecated */
- /*for (++i; i < SQL_API_SQLBINDPARAMETER; i++)
- SQL_FUNC_ESET(pfExists, i);*/
- SQL_FUNC_ESET(pfExists, SQL_API_SQLFOREIGNKEYS); /* 60 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLMORERESULTS); /* 61 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLNATIVESQL); /* 62 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMPARAMS); /* 63 */
+
+ /*
+ * for (++i; i < SQL_API_SQLBINDPARAMETER; i++)
+ * SQL_FUNC_ESET(pfExists, i);
+ */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLFOREIGNKEYS); /* 60 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLMORERESULTS); /* 61 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLNATIVESQL); /* 62 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMPARAMS); /* 63 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLPARAMOPTIONS); 64 deprecated */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLPRIMARYKEYS); /* 65 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURECOLUMNS); /* 66 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURES); /* 67 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLPRIMARYKEYS); /* 65 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURECOLUMNS); /* 66 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURES); /* 67 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETPOS); /* 68 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSCROLLOPTIONS); /* 69 deprecated */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLTABLEPRIVILEGES); /* 70 */
- /*SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERS);*/ /* 71 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAMETER); /* 72 */
-
- SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCHANDLE); /* 1001 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAM); /* 1002 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLCLOSECURSOR); /* 1003 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLCOPYDESC);/* 1004 not implemented yet */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLENDTRAN); /* 1005 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEHANDLE); /* 1006 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSCROLLOPTIONS); /* 69 deprecated */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLTABLEPRIVILEGES); /* 70 */
+ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERS); *//* 71 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAMETER); /* 72 */
+
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCHANDLE); /* 1001 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAM); /* 1002 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLCLOSECURSOR); /* 1003 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLCOPYDESC); /* 1004 not implemented
+ * yet */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLENDTRAN); /* 1005 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEHANDLE); /* 1006 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCONNECTATTR); /* 1007 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCFIELD);/* 1008 not implemented yet */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCREC);/* 1009 not implemented yet */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGFIELD);/* 1010 not implemented yet */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGREC); /* 1011 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLGETENVATTR); /* 1012 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTATTR); /* 1014 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCFIELD); /* 1008 not implemented
+ * yet */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCREC); /* 1009 not implemented
+ * yet */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGFIELD); /* 1010 not implemented
+ * yet */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGREC); /* 1011 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETENVATTR); /* 1012 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTATTR); /* 1014 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTATTR); /* 1016 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCFIELD); /* 1017 not implemeted yet */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCREC); /* 1018 not implemented yet */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLSETENVATTR); /* 1019 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTATTR); /* 1020 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCHSCROLL); /* 1021 */
- SQL_FUNC_ESET(pfExists, SQL_API_SQLBULKOPERATIONS);/* 24 not implemented yet */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCFIELD); /* 1017 not implemeted
+ * yet */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCREC); /* 1018 not implemented
+ * yet */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETENVATTR); /* 1019 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTATTR); /* 1020 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCHSCROLL); /* 1021 */
+ SQL_FUNC_ESET(pfExists, SQL_API_SQLBULKOPERATIONS); /* 24 not implemented
+ * yet */
return SQL_SUCCESS;
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_GetInfo30(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue,
- SWORD cbInfoValueMax, SWORD FAR *pcbInfoValue)
+ SWORD cbInfoValueMax, SWORD FAR * pcbInfoValue)
{
static char *func = "PGAPI_GetInfo30";
ConnectionClass *conn = (ConnectionClass *) hdbc;
- char *p = NULL;
- int len = 0, value = 0;
- RETCODE result;
+ char *p = NULL;
+ int len = 0,
+ value = 0;
+ RETCODE result;
switch (fInfoType)
{
-RETCODE set_statement_option(ConnectionClass *conn,
- StatementClass *stmt,
+RETCODE set_statement_option(ConnectionClass * conn,
+ StatementClass * stmt,
UWORD fOption,
UDWORD vParam);
RETCODE
-set_statement_option(ConnectionClass *conn,
- StatementClass *stmt,
+set_statement_option(ConnectionClass * conn,
+ StatementClass * stmt,
UWORD fOption,
UDWORD vParam)
{
static char *func = "set_statement_option";
char changed = FALSE;
- ConnInfo *ci = NULL;
+ ConnInfo *ci = NULL;
if (conn)
ci = &(conn->connInfo);
if (ci->drivers.lie || vParam == SQL_CONCUR_READ_ONLY || vParam == SQL_CONCUR_ROWVER)
{
if (conn)
- conn->stmtOptions.scroll_concurrency = vParam;
- if (stmt)
- stmt->options.scroll_concurrency = vParam;
+ conn->stmtOptions.scroll_concurrency = vParam;
+ if (stmt)
+ stmt->options.scroll_concurrency = vParam;
}
- else
+ else
{
- if (conn)
- conn->stmtOptions.scroll_concurrency = SQL_CONCUR_ROWVER;
- if (stmt)
- stmt->options.scroll_concurrency = SQL_CONCUR_ROWVER;
- changed = TRUE;
- }
- break;
+ if (conn)
+ conn->stmtOptions.scroll_concurrency = SQL_CONCUR_ROWVER;
+ if (stmt)
+ stmt->options.scroll_concurrency = SQL_CONCUR_ROWVER;
+ changed = TRUE;
+ }
+ break;
case SQL_CURSOR_TYPE:
/* Implements only SQL_AUTOCOMMIT */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_SetConnectOption(
- HDBC hdbc,
- UWORD fOption,
- UDWORD vParam)
+ HDBC hdbc,
+ UWORD fOption,
+ UDWORD vParam)
{
static char *func = "PGAPI_SetConnectOption";
ConnectionClass *conn = (ConnectionClass *) hdbc;
switch (fOption)
{
-
/*
* Statement Options (apply to all stmts on the connection and
* become defaults for new stmts)
/* This function just can tell you whether you are in Autcommit mode or not */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_GetConnectOption(
- HDBC hdbc,
- UWORD fOption,
- PTR pvParam)
+ HDBC hdbc,
+ UWORD fOption,
+ PTR pvParam)
{
static char *func = "PGAPI_GetConnectOption";
ConnectionClass *conn = (ConnectionClass *) hdbc;
- ConnInfo *ci = &(conn->connInfo);
+ ConnInfo *ci = &(conn->connInfo);
mylog("%s: entering...\n", func);
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_SetStmtOption(
- HSTMT hstmt,
- UWORD fOption,
- UDWORD vParam)
+ HSTMT hstmt,
+ UWORD fOption,
+ UDWORD vParam)
{
static char *func = "PGAPI_SetStmtOption";
StatementClass *stmt = (StatementClass *) hstmt;
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_GetStmtOption(
- HSTMT hstmt,
- UWORD fOption,
- PTR pvParam)
+ HSTMT hstmt,
+ UWORD fOption,
+ PTR pvParam)
{
static char *func = "PGAPI_GetStmtOption";
StatementClass *stmt = (StatementClass *) hstmt;
QResultClass *res;
- ConnInfo *ci = &(SC_get_conn(stmt)->connInfo);
+ ConnInfo *ci = &(SC_get_conn(stmt)->connInfo);
mylog("%s: entering...\n", func);
#define COL_INCR 16
char *getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dquote, char *numeric);
-void getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k);
-char searchColInfo(COL_INFO *col_info, FIELD_INFO *fi);
+void getColInfo(COL_INFO * col_info, FIELD_INFO * fi, int k);
+char searchColInfo(COL_INFO * col_info, FIELD_INFO * fi);
char *
token[out++] = s[i++];
continue;
}
-#endif
+#endif
/* Handle quoted stuff */
if (out == 0 && (s[i] == '\"' || s[i] == '\''))
{
token[out++] = s[i++];
continue;
}
-#endif
+#endif
if (s[i] == qc && !in_escape)
break;
if (s[i] == '\\' && !in_escape)
- {
in_escape = TRUE;
- }
else
{
in_escape = FALSE;
#endif
void
-getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k)
+getColInfo(COL_INFO * col_info, FIELD_INFO * fi, int k)
{
- char *str;
+ char *str;
+
if (fi->name[0] == '\0')
strcpy(fi->name, QR_get_value_manual(col_info->result, k, 3));
char
-searchColInfo(COL_INFO *col_info, FIELD_INFO *fi)
+searchColInfo(COL_INFO * col_info, FIELD_INFO * fi)
{
int k,
cmp;
char
-parse_statement(StatementClass *stmt)
+parse_statement(StatementClass * stmt)
{
static char *func = "parse_statement";
char token[256];
dquote,
numeric,
unquoted;
- char *ptr, *pptr = NULL;
+ char *ptr,
+ *pptr = NULL;
char in_select = FALSE,
in_distinct = FALSE,
in_on = FALSE,
in_select = FALSE;
in_from = TRUE;
if (!from_found &&
- (!strnicmp(pptr, "from", 4)))
+ (!strnicmp(pptr, "from", 4)))
{
mylog("First ");
from_found = TRUE;
if (unquoted && blevel == 0)
{
if ((!stricmp(token, "where") ||
- !stricmp(token, "union") ||
- !stricmp(token, "intersect") ||
- !stricmp(token, "except") ||
- !stricmp(token, "order") ||
- !stricmp(token, "group") ||
- !stricmp(token, "having")))
+ !stricmp(token, "union") ||
+ !stricmp(token, "intersect") ||
+ !stricmp(token, "except") ||
+ !stricmp(token, "order") ||
+ !stricmp(token, "group") ||
+ !stricmp(token, "having")))
{
in_select = FALSE;
in_from = FALSE;
in_where = TRUE;
if (!first_where &&
- (!stricmp(token, "where")))
+ (!stricmp(token, "where")))
first_where = ptr - stmt->statement;
-
+
mylog("WHERE...\n");
break;
}
if (quote)
{
fi[stmt->nfld++]->quote = TRUE;
-in_expr = TRUE;
+ in_expr = TRUE;
continue;
}
else if (numeric)
if ((unsigned char) *ptr >= 0x80)
ptr++;
else
-#endif /* MULTIBYTE */
- *ptr = tolower((unsigned char) *ptr);
+#endif /* MULTIBYTE */
+ *ptr = tolower((unsigned char) *ptr);
}
}
mylog("got table = '%s'\n", ti[stmt->ntab]->name);
else if (fi[i]->quote)
{ /* handle as text */
fi[i]->ti = NULL;
+
/*
- fi[i]->type = PG_TYPE_TEXT;
- fi[i]->precision = 0;
- the following may be better */
+ * fi[i]->type = PG_TYPE_TEXT; fi[i]->precision = 0; the
+ * following may be better
+ */
fi[i]->type = PG_TYPE_UNKNOWN;
fi[i]->precision = 254;
continue;
*
*-------
*/
-#ifndef _PG_API_FUNC_H__
-#define _PG_API_FUNC_H__
+#ifndef _PG_API_FUNC_H__
+#define _PG_API_FUNC_H__
#include "psqlodbc.h"
#include
#include
-RETCODE SQL_API PGAPI_AllocConnect(HENV EnvironmentHandle,
- HDBC FAR *ConnectionHandle);
-RETCODE SQL_API PGAPI_AllocEnv(HENV FAR *EnvironmentHandle);
-RETCODE SQL_API PGAPI_AllocStmt(HDBC ConnectionHandle,
- HSTMT *StatementHandle);
-RETCODE SQL_API PGAPI_BindCol(HSTMT StatementHandle,
- SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
- PTR TargetValue, SQLINTEGER BufferLength,
- SQLINTEGER *StrLen_or_Ind);
-RETCODE SQL_API PGAPI_Cancel(HSTMT StatementHandle);
-RETCODE SQL_API PGAPI_Columns(HSTMT StatementHandle,
- SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
- SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
- SQLCHAR *TableName, SQLSMALLINT NameLength3,
- SQLCHAR *ColumnName, SQLSMALLINT NameLength4);
-RETCODE SQL_API PGAPI_Connect(HDBC ConnectionHandle,
- SQLCHAR *ServerName, SQLSMALLINT NameLength1,
- SQLCHAR *UserName, SQLSMALLINT NameLength2,
- SQLCHAR *Authentication, SQLSMALLINT NameLength3);
-RETCODE SQL_API PGAPI_DriverConnect(HDBC hdbc, HWND hwnd,
- UCHAR FAR *szConnStrIn, SWORD cbConnStrIn,
- UCHAR FAR *szConnStrOut, SWORD cbConnStrOutMax,
- SWORD FAR *pcbConnStrOut, UWORD fDriverCompletion);
+RETCODE SQL_API PGAPI_AllocConnect(HENV EnvironmentHandle,
+ HDBC FAR * ConnectionHandle);
+RETCODE SQL_API PGAPI_AllocEnv(HENV FAR * EnvironmentHandle);
+RETCODE SQL_API PGAPI_AllocStmt(HDBC ConnectionHandle,
+ HSTMT * StatementHandle);
+RETCODE SQL_API PGAPI_BindCol(HSTMT StatementHandle,
+ SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
+ PTR TargetValue, SQLINTEGER BufferLength,
+ SQLINTEGER * StrLen_or_Ind);
+RETCODE SQL_API PGAPI_Cancel(HSTMT StatementHandle);
+RETCODE SQL_API PGAPI_Columns(HSTMT StatementHandle,
+ SQLCHAR * CatalogName, SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName, SQLSMALLINT NameLength2,
+ SQLCHAR * TableName, SQLSMALLINT NameLength3,
+ SQLCHAR * ColumnName, SQLSMALLINT NameLength4);
+RETCODE SQL_API PGAPI_Connect(HDBC ConnectionHandle,
+ SQLCHAR * ServerName, SQLSMALLINT NameLength1,
+ SQLCHAR * UserName, SQLSMALLINT NameLength2,
+ SQLCHAR * Authentication, SQLSMALLINT NameLength3);
+RETCODE SQL_API PGAPI_DriverConnect(HDBC hdbc, HWND hwnd,
+ UCHAR FAR * szConnStrIn, SWORD cbConnStrIn,
+ UCHAR FAR * szConnStrOut, SWORD cbConnStrOutMax,
+ SWORD FAR * pcbConnStrOut, UWORD fDriverCompletion);
RETCODE SQL_API PGAPI_BrowseConnect(HDBC hdbc,
- SQLCHAR *szConnStrIn, SQLSMALLINT cbConnStrIn,
- SQLCHAR *szConnStrOut, SQLSMALLINT cbConnStrOutMax,
- SQLSMALLINT *pcbConnStrOut);
-RETCODE SQL_API PGAPI_DataSources(HENV EnvironmentHandle,
- SQLUSMALLINT Direction, SQLCHAR *ServerName,
- SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
- SQLCHAR *Description, SQLSMALLINT BufferLength2,
- SQLSMALLINT *NameLength2);
-RETCODE SQL_API PGAPI_DescribeCol(HSTMT StatementHandle,
- SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName,
- SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
- SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize,
- SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable);
-RETCODE SQL_API PGAPI_Disconnect(HDBC ConnectionHandle);
-RETCODE SQL_API PGAPI_Error(HENV EnvironmentHandle,
- HDBC ConnectionHandle, HSTMT StatementHandle,
- SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
- SQLCHAR *MessageText, SQLSMALLINT BufferLength,
- SQLSMALLINT *TextLength);
-RETCODE SQL_API PGAPI_ExecDirect(HSTMT StatementHandle,
- SQLCHAR *StatementText, SQLINTEGER TextLength);
-RETCODE SQL_API PGAPI_Execute(HSTMT StatementHandle);
-RETCODE SQL_API PGAPI_Fetch(HSTMT StatementHandle);
-RETCODE SQL_API PGAPI_FreeConnect(HDBC ConnectionHandle);
-RETCODE SQL_API PGAPI_FreeEnv(HENV EnvironmentHandle);
-RETCODE SQL_API PGAPI_FreeStmt(HSTMT StatementHandle,
- SQLUSMALLINT Option);
-RETCODE SQL_API PGAPI_GetConnectOption(HDBC ConnectionHandle,
- SQLUSMALLINT Option, PTR Value);
-RETCODE SQL_API PGAPI_GetCursorName(HSTMT StatementHandle,
- SQLCHAR *CursorName, SQLSMALLINT BufferLength,
- SQLSMALLINT *NameLength);
-RETCODE SQL_API PGAPI_GetData(HSTMT StatementHandle,
- SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
- PTR TargetValue, SQLINTEGER BufferLength,
- SQLINTEGER *StrLen_or_Ind);
-RETCODE SQL_API PGAPI_GetFunctions(HDBC ConnectionHandle,
- SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported);
-RETCODE SQL_API PGAPI_GetFunctions30(HDBC ConnectionHandle,
- SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported);
-RETCODE SQL_API PGAPI_GetInfo(HDBC ConnectionHandle,
- SQLUSMALLINT InfoType, PTR InfoValue,
- SQLSMALLINT BufferLength, SQLSMALLINT *StringLength);
-RETCODE SQL_API PGAPI_GetInfo30(HDBC ConnectionHandle,
- SQLUSMALLINT InfoType, PTR InfoValue,
- SQLSMALLINT BufferLength, SQLSMALLINT *StringLength);
-RETCODE SQL_API PGAPI_GetStmtOption(HSTMT StatementHandle,
- SQLUSMALLINT Option, PTR Value);
-RETCODE SQL_API PGAPI_GetTypeInfo(HSTMT StatementHandle,
- SQLSMALLINT DataType);
-RETCODE SQL_API PGAPI_NumResultCols(HSTMT StatementHandle,
- SQLSMALLINT *ColumnCount);
-RETCODE SQL_API PGAPI_ParamData(HSTMT StatementHandle,
- PTR *Value);
-RETCODE SQL_API PGAPI_Prepare(HSTMT StatementHandle,
- SQLCHAR *StatementText, SQLINTEGER TextLength);
-RETCODE SQL_API PGAPI_PutData(HSTMT StatementHandle,
- PTR Data, SQLINTEGER StrLen_or_Ind);
-RETCODE SQL_API PGAPI_RowCount(HSTMT StatementHandle,
- SQLINTEGER *RowCount);
-RETCODE SQL_API PGAPI_SetConnectOption(HDBC ConnectionHandle,
- SQLUSMALLINT Option, SQLUINTEGER Value);
-RETCODE SQL_API PGAPI_SetCursorName(HSTMT StatementHandle,
- SQLCHAR *CursorName, SQLSMALLINT NameLength);
-RETCODE SQL_API PGAPI_SetParam(HSTMT StatementHandle,
- SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
- SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
- SQLSMALLINT ParameterScale, PTR ParameterValue,
- SQLINTEGER *StrLen_or_Ind);
-RETCODE SQL_API PGAPI_SetStmtOption(HSTMT StatementHandle,
- SQLUSMALLINT Option, SQLUINTEGER Value);
-RETCODE SQL_API PGAPI_SpecialColumns(HSTMT StatementHandle,
- SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName,
- SQLSMALLINT NameLength1, SQLCHAR *SchemaName,
- SQLSMALLINT NameLength2, SQLCHAR *TableName,
- SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
- SQLUSMALLINT Nullable);
-RETCODE SQL_API PGAPI_Statistics(HSTMT StatementHandle,
- SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
- SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
- SQLCHAR *TableName, SQLSMALLINT NameLength3,
- SQLUSMALLINT Unique, SQLUSMALLINT Reserved);
-RETCODE SQL_API PGAPI_Tables(HSTMT StatementHandle,
- SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
- SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
- SQLCHAR *TableName, SQLSMALLINT NameLength3,
- SQLCHAR *TableType, SQLSMALLINT NameLength4);
-RETCODE SQL_API PGAPI_Transact(HENV EnvironmentHandle,
- HDBC ConnectionHandle, SQLUSMALLINT CompletionType);
+ SQLCHAR * szConnStrIn, SQLSMALLINT cbConnStrIn,
+ SQLCHAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax,
+ SQLSMALLINT * pcbConnStrOut);
+RETCODE SQL_API PGAPI_DataSources(HENV EnvironmentHandle,
+ SQLUSMALLINT Direction, SQLCHAR * ServerName,
+ SQLSMALLINT BufferLength1, SQLSMALLINT * NameLength1,
+ SQLCHAR * Description, SQLSMALLINT BufferLength2,
+ SQLSMALLINT * NameLength2);
+RETCODE SQL_API PGAPI_DescribeCol(HSTMT StatementHandle,
+ SQLUSMALLINT ColumnNumber, SQLCHAR * ColumnName,
+ SQLSMALLINT BufferLength, SQLSMALLINT * NameLength,
+ SQLSMALLINT * DataType, SQLUINTEGER * ColumnSize,
+ SQLSMALLINT * DecimalDigits, SQLSMALLINT * Nullable);
+RETCODE SQL_API PGAPI_Disconnect(HDBC ConnectionHandle);
+RETCODE SQL_API PGAPI_Error(HENV EnvironmentHandle,
+ HDBC ConnectionHandle, HSTMT StatementHandle,
+ SQLCHAR * Sqlstate, SQLINTEGER * NativeError,
+ SQLCHAR * MessageText, SQLSMALLINT BufferLength,
+ SQLSMALLINT * TextLength);
+RETCODE SQL_API PGAPI_ExecDirect(HSTMT StatementHandle,
+ SQLCHAR * StatementText, SQLINTEGER TextLength);
+RETCODE SQL_API PGAPI_Execute(HSTMT StatementHandle);
+RETCODE SQL_API PGAPI_Fetch(HSTMT StatementHandle);
+RETCODE SQL_API PGAPI_FreeConnect(HDBC ConnectionHandle);
+RETCODE SQL_API PGAPI_FreeEnv(HENV EnvironmentHandle);
+RETCODE SQL_API PGAPI_FreeStmt(HSTMT StatementHandle,
+ SQLUSMALLINT Option);
+RETCODE SQL_API PGAPI_GetConnectOption(HDBC ConnectionHandle,
+ SQLUSMALLINT Option, PTR Value);
+RETCODE SQL_API PGAPI_GetCursorName(HSTMT StatementHandle,
+ SQLCHAR * CursorName, SQLSMALLINT BufferLength,
+ SQLSMALLINT * NameLength);
+RETCODE SQL_API PGAPI_GetData(HSTMT StatementHandle,
+ SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
+ PTR TargetValue, SQLINTEGER BufferLength,
+ SQLINTEGER * StrLen_or_Ind);
+RETCODE SQL_API PGAPI_GetFunctions(HDBC ConnectionHandle,
+ SQLUSMALLINT FunctionId, SQLUSMALLINT * Supported);
+RETCODE SQL_API PGAPI_GetFunctions30(HDBC ConnectionHandle,
+ SQLUSMALLINT FunctionId, SQLUSMALLINT * Supported);
+RETCODE SQL_API PGAPI_GetInfo(HDBC ConnectionHandle,
+ SQLUSMALLINT InfoType, PTR InfoValue,
+ SQLSMALLINT BufferLength, SQLSMALLINT * StringLength);
+RETCODE SQL_API PGAPI_GetInfo30(HDBC ConnectionHandle,
+ SQLUSMALLINT InfoType, PTR InfoValue,
+ SQLSMALLINT BufferLength, SQLSMALLINT * StringLength);
+RETCODE SQL_API PGAPI_GetStmtOption(HSTMT StatementHandle,
+ SQLUSMALLINT Option, PTR Value);
+RETCODE SQL_API PGAPI_GetTypeInfo(HSTMT StatementHandle,
+ SQLSMALLINT DataType);
+RETCODE SQL_API PGAPI_NumResultCols(HSTMT StatementHandle,
+ SQLSMALLINT * ColumnCount);
+RETCODE SQL_API PGAPI_ParamData(HSTMT StatementHandle,
+ PTR * Value);
+RETCODE SQL_API PGAPI_Prepare(HSTMT StatementHandle,
+ SQLCHAR * StatementText, SQLINTEGER TextLength);
+RETCODE SQL_API PGAPI_PutData(HSTMT StatementHandle,
+ PTR Data, SQLINTEGER StrLen_or_Ind);
+RETCODE SQL_API PGAPI_RowCount(HSTMT StatementHandle,
+ SQLINTEGER * RowCount);
+RETCODE SQL_API PGAPI_SetConnectOption(HDBC ConnectionHandle,
+ SQLUSMALLINT Option, SQLUINTEGER Value);
+RETCODE SQL_API PGAPI_SetCursorName(HSTMT StatementHandle,
+ SQLCHAR * CursorName, SQLSMALLINT NameLength);
+RETCODE SQL_API PGAPI_SetParam(HSTMT StatementHandle,
+ SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
+ SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
+ SQLSMALLINT ParameterScale, PTR ParameterValue,
+ SQLINTEGER * StrLen_or_Ind);
+RETCODE SQL_API PGAPI_SetStmtOption(HSTMT StatementHandle,
+ SQLUSMALLINT Option, SQLUINTEGER Value);
+RETCODE SQL_API PGAPI_SpecialColumns(HSTMT StatementHandle,
+ SQLUSMALLINT IdentifierType, SQLCHAR * CatalogName,
+ SQLSMALLINT NameLength1, SQLCHAR * SchemaName,
+ SQLSMALLINT NameLength2, SQLCHAR * TableName,
+ SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
+ SQLUSMALLINT Nullable);
+RETCODE SQL_API PGAPI_Statistics(HSTMT StatementHandle,
+ SQLCHAR * CatalogName, SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName, SQLSMALLINT NameLength2,
+ SQLCHAR * TableName, SQLSMALLINT NameLength3,
+ SQLUSMALLINT Unique, SQLUSMALLINT Reserved);
+RETCODE SQL_API PGAPI_Tables(HSTMT StatementHandle,
+ SQLCHAR * CatalogName, SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName, SQLSMALLINT NameLength2,
+ SQLCHAR * TableName, SQLSMALLINT NameLength3,
+ SQLCHAR * TableType, SQLSMALLINT NameLength4);
+RETCODE SQL_API PGAPI_Transact(HENV EnvironmentHandle,
+ HDBC ConnectionHandle, SQLUSMALLINT CompletionType);
RETCODE SQL_API PGAPI_ColAttributes(
- HSTMT hstmt,
- SQLUSMALLINT icol,
- SQLUSMALLINT fDescType,
- PTR rgbDesc,
- SQLSMALLINT cbDescMax,
- SQLSMALLINT *pcbDesc,
- SQLINTEGER *pfDesc);
+ HSTMT hstmt,
+ SQLUSMALLINT icol,
+ SQLUSMALLINT fDescType,
+ PTR rgbDesc,
+ SQLSMALLINT cbDescMax,
+ SQLSMALLINT * pcbDesc,
+ SQLINTEGER * pfDesc);
RETCODE SQL_API PGAPI_ColumnPrivileges(
- HSTMT hstmt,
- SQLCHAR *szCatalogName,
- SQLSMALLINT cbCatalogName,
- SQLCHAR *szSchemaName,
- SQLSMALLINT cbSchemaName,
- SQLCHAR *szTableName,
- SQLSMALLINT cbTableName,
- SQLCHAR *szColumnName,
- SQLSMALLINT cbColumnName);
+ HSTMT hstmt,
+ SQLCHAR * szCatalogName,
+ SQLSMALLINT cbCatalogName,
+ SQLCHAR * szSchemaName,
+ SQLSMALLINT cbSchemaName,
+ SQLCHAR * szTableName,
+ SQLSMALLINT cbTableName,
+ SQLCHAR * szColumnName,
+ SQLSMALLINT cbColumnName);
RETCODE SQL_API PGAPI_DescribeParam(
- HSTMT hstmt,
- SQLUSMALLINT ipar,
- SQLSMALLINT *pfSqlType,
- SQLUINTEGER *pcbParamDef,
- SQLSMALLINT *pibScale,
- SQLSMALLINT *pfNullable);
+ HSTMT hstmt,
+ SQLUSMALLINT ipar,
+ SQLSMALLINT * pfSqlType,
+ SQLUINTEGER * pcbParamDef,
+ SQLSMALLINT * pibScale,
+ SQLSMALLINT * pfNullable);
RETCODE SQL_API PGAPI_ExtendedFetch(
- HSTMT hstmt,
- SQLUSMALLINT fFetchType,
- SQLINTEGER irow,
- SQLUINTEGER *pcrow,
- SQLUSMALLINT *rgfRowStatus);
+ HSTMT hstmt,
+ SQLUSMALLINT fFetchType,
+ SQLINTEGER irow,
+ SQLUINTEGER * pcrow,
+ SQLUSMALLINT * rgfRowStatus);
RETCODE SQL_API PGAPI_ForeignKeys(
- HSTMT hstmt,
- SQLCHAR *szPkCatalogName,
- SQLSMALLINT cbPkCatalogName,
- SQLCHAR *szPkSchemaName,
- SQLSMALLINT cbPkSchemaName,
- SQLCHAR *szPkTableName,
- SQLSMALLINT cbPkTableName,
- SQLCHAR *szFkCatalogName,
- SQLSMALLINT cbFkCatalogName,
- SQLCHAR *szFkSchemaName,
- SQLSMALLINT cbFkSchemaName,
- SQLCHAR *szFkTableName,
- SQLSMALLINT cbFkTableName);
+ HSTMT hstmt,
+ SQLCHAR * szPkCatalogName,
+ SQLSMALLINT cbPkCatalogName,
+ SQLCHAR * szPkSchemaName,
+ SQLSMALLINT cbPkSchemaName,
+ SQLCHAR * szPkTableName,
+ SQLSMALLINT cbPkTableName,
+ SQLCHAR * szFkCatalogName,
+ SQLSMALLINT cbFkCatalogName,
+ SQLCHAR * szFkSchemaName,
+ SQLSMALLINT cbFkSchemaName,
+ SQLCHAR * szFkTableName,
+ SQLSMALLINT cbFkTableName);
RETCODE SQL_API PGAPI_MoreResults(
- HSTMT hstmt);
+ HSTMT hstmt);
RETCODE SQL_API PGAPI_NativeSql(
- HDBC hdbc,
- SQLCHAR *szSqlStrIn,
- SQLINTEGER cbSqlStrIn,
- SQLCHAR *szSqlStr,
- SQLINTEGER cbSqlStrMax,
- SQLINTEGER *pcbSqlStr);
+ HDBC hdbc,
+ SQLCHAR * szSqlStrIn,
+ SQLINTEGER cbSqlStrIn,
+ SQLCHAR * szSqlStr,
+ SQLINTEGER cbSqlStrMax,
+ SQLINTEGER * pcbSqlStr);
RETCODE SQL_API PGAPI_NumParams(
- HSTMT hstmt,
- SQLSMALLINT *pcpar);
+ HSTMT hstmt,
+ SQLSMALLINT * pcpar);
RETCODE SQL_API PGAPI_ParamOptions(
- HSTMT hstmt,
- SQLUINTEGER crow,
- SQLUINTEGER *pirow);
+ HSTMT hstmt,
+ SQLUINTEGER crow,
+ SQLUINTEGER * pirow);
RETCODE SQL_API PGAPI_PrimaryKeys(
- HSTMT hstmt,
- SQLCHAR *szCatalogName,
- SQLSMALLINT cbCatalogName,
- SQLCHAR *szSchemaName,
- SQLSMALLINT cbSchemaName,
- SQLCHAR *szTableName,
- SQLSMALLINT cbTableName);
+ HSTMT hstmt,
+ SQLCHAR * szCatalogName,
+ SQLSMALLINT cbCatalogName,
+ SQLCHAR * szSchemaName,
+ SQLSMALLINT cbSchemaName,
+ SQLCHAR * szTableName,
+ SQLSMALLINT cbTableName);
RETCODE SQL_API PGAPI_ProcedureColumns(
- HSTMT hstmt,
- SQLCHAR *szCatalogName,
- SQLSMALLINT cbCatalogName,
- SQLCHAR *szSchemaName,
- SQLSMALLINT cbSchemaName,
- SQLCHAR *szProcName,
- SQLSMALLINT cbProcName,
- SQLCHAR *szColumnName,
- SQLSMALLINT cbColumnName);
+ HSTMT hstmt,
+ SQLCHAR * szCatalogName,
+ SQLSMALLINT cbCatalogName,
+ SQLCHAR * szSchemaName,
+ SQLSMALLINT cbSchemaName,
+ SQLCHAR * szProcName,
+ SQLSMALLINT cbProcName,
+ SQLCHAR * szColumnName,
+ SQLSMALLINT cbColumnName);
RETCODE SQL_API PGAPI_Procedures(
- HSTMT hstmt,
- SQLCHAR *szCatalogName,
- SQLSMALLINT cbCatalogName,
- SQLCHAR *szSchemaName,
- SQLSMALLINT cbSchemaName,
- SQLCHAR *szProcName,
- SQLSMALLINT cbProcName);
+ HSTMT hstmt,
+ SQLCHAR * szCatalogName,
+ SQLSMALLINT cbCatalogName,
+ SQLCHAR * szSchemaName,
+ SQLSMALLINT cbSchemaName,
+ SQLCHAR * szProcName,
+ SQLSMALLINT cbProcName);
RETCODE SQL_API PGAPI_SetPos(
- HSTMT hstmt,
- SQLUSMALLINT irow,
- SQLUSMALLINT fOption,
- SQLUSMALLINT fLock);
+ HSTMT hstmt,
+ SQLUSMALLINT irow,
+ SQLUSMALLINT fOption,
+ SQLUSMALLINT fLock);
RETCODE SQL_API PGAPI_TablePrivileges(
- HSTMT hstmt,
- SQLCHAR *szCatalogName,
- SQLSMALLINT cbCatalogName,
- SQLCHAR *szSchemaName,
- SQLSMALLINT cbSchemaName,
- SQLCHAR *szTableName,
- SQLSMALLINT cbTableName);
+ HSTMT hstmt,
+ SQLCHAR * szCatalogName,
+ SQLSMALLINT cbCatalogName,
+ SQLCHAR * szSchemaName,
+ SQLSMALLINT cbSchemaName,
+ SQLCHAR * szTableName,
+ SQLSMALLINT cbTableName);
RETCODE SQL_API PGAPI_BindParameter(
- HSTMT hstmt,
- SQLUSMALLINT ipar,
- SQLSMALLINT fParamType,
- SQLSMALLINT fCType,
- SQLSMALLINT fSqlType,
- SQLUINTEGER cbColDef,
- SQLSMALLINT ibScale,
- PTR rgbValue,
- SQLINTEGER cbValueMax,
- SQLINTEGER *pcbValue);
+ HSTMT hstmt,
+ SQLUSMALLINT ipar,
+ SQLSMALLINT fParamType,
+ SQLSMALLINT fCType,
+ SQLSMALLINT fSqlType,
+ SQLUINTEGER cbColDef,
+ SQLSMALLINT ibScale,
+ PTR rgbValue,
+ SQLINTEGER cbValueMax,
+ SQLINTEGER * pcbValue);
RETCODE SQL_API PGAPI_SetScrollOptions(
- HSTMT hstmt,
- UWORD fConcurrency,
- SDWORD crowKeyset,
- UWORD crowRowset);
-#endif /* define_PG_API_FUNC_H__ */
+ HSTMT hstmt,
+ UWORD fConcurrency,
+ SDWORD crowKeyset,
+ UWORD crowRowset);
+#endif /* define_PG_API_FUNC_H__ */
-Int4 getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as);
+Int4 getCharPrecision(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as);
/*
* these are the types we support. all of the pgtype_ functions should
Int4
-sqltype_to_pgtype(StatementClass *stmt, SWORD fSqlType)
+sqltype_to_pgtype(StatementClass * stmt, SWORD fSqlType)
{
Int4 pgType;
- ConnInfo *ci = &(SC_get_conn(stmt)->connInfo);
+ ConnInfo *ci = &(SC_get_conn(stmt)->connInfo);
switch (fSqlType)
{
* types that are unknown. All other pg routines in here return a suitable default.
*/
Int2
-pgtype_to_sqltype(StatementClass *stmt, Int4 type)
+pgtype_to_sqltype(StatementClass * stmt, Int4 type)
{
- ConnInfo *ci = &(SC_get_conn(stmt)->connInfo);
+ ConnInfo *ci = &(SC_get_conn(stmt)->connInfo);
+
switch (type)
{
case PG_TYPE_CHAR:
Int2
-pgtype_to_ctype(StatementClass *stmt, Int4 type)
+pgtype_to_ctype(StatementClass * stmt, Int4 type)
{
- ConnInfo *ci = &(SC_get_conn(stmt)->connInfo);
+ ConnInfo *ci = &(SC_get_conn(stmt)->connInfo);
+
switch (type)
{
case PG_TYPE_INT8:
char *
-pgtype_to_name(StatementClass *stmt, Int4 type)
+pgtype_to_name(StatementClass * stmt, Int4 type)
{
switch (type)
{
static Int2
-getNumericScale(StatementClass *stmt, Int4 type, int col)
+getNumericScale(StatementClass * stmt, Int4 type, int col)
{
Int4 atttypmod;
QResultClass *result;
static Int4
-getNumericPrecision(StatementClass *stmt, Int4 type, int col)
+getNumericPrecision(StatementClass * stmt, Int4 type, int col)
{
Int4 atttypmod;
QResultClass *result;
Int4
-getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as)
+getCharPrecision(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as)
{
int p = -1,
maxsize;
QResultClass *result;
ColumnInfoClass *flds;
- ConnInfo *ci = &(SC_get_conn(stmt)->connInfo);
+ ConnInfo *ci = &(SC_get_conn(stmt)->connInfo);
mylog("getCharPrecision: type=%d, col=%d, unknown = %d\n", type, col, handle_unknown_size_as);
{
if (PG_VERSION_GE(SC_get_conn(stmt), 7.1))
maxsize = 0;
- else
+ else
maxsize = TEXT_FIELD_SIZE;
}
if (col < 0)
* This is used for functions SQLDescribeCol and SQLColAttributes.
*/
Int4
-pgtype_precision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as)
+pgtype_precision(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as)
{
switch (type)
{
Int4
-pgtype_display_size(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as)
+pgtype_display_size(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as)
{
switch (type)
{
* override this length with the atttypmod length from pg_attribute
*/
Int4
-pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as)
+pgtype_length(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as)
{
switch (type)
{
case PG_TYPE_DATE:
case PG_TYPE_TIME:
- return 6; /* sizeof(DATE(TIME)_STRUCT) */
+ return 6; /* sizeof(DATE(TIME)_STRUCT) */
case PG_TYPE_ABSTIME:
case PG_TYPE_DATETIME:
case PG_TYPE_TIMESTAMP:
- return 16; /* sizeof(TIMESTAMP_STRUCT) */
+ return 16; /* sizeof(TIMESTAMP_STRUCT) */
/* Character types (and NUMERIC) use the default precision */
case PG_TYPE_VARCHAR:
else
#else
/* CR -> CR/LF */
- return 2 * pgtype_precision(stmt, type, col, handle_unknown_size_as);
-#endif /* MULTIBYTE */
+ return 2 * pgtype_precision(stmt, type, col, handle_unknown_size_as);
+#endif /* MULTIBYTE */
default:
return pgtype_precision(stmt, type, col, handle_unknown_size_as);
}
Int2
-pgtype_scale(StatementClass *stmt, Int4 type, int col)
+pgtype_scale(StatementClass * stmt, Int4 type, int col)
{
switch (type)
{
Int2
-pgtype_radix(StatementClass *stmt, Int4 type)
+pgtype_radix(StatementClass * stmt, Int4 type)
{
switch (type)
{
Int2
-pgtype_nullable(StatementClass *stmt, Int4 type)
+pgtype_nullable(StatementClass * stmt, Int4 type)
{
return SQL_NULLABLE; /* everything should be nullable */
}
Int2
-pgtype_auto_increment(StatementClass *stmt, Int4 type)
+pgtype_auto_increment(StatementClass * stmt, Int4 type)
{
switch (type)
{
Int2
-pgtype_case_sensitive(StatementClass *stmt, Int4 type)
+pgtype_case_sensitive(StatementClass * stmt, Int4 type)
{
switch (type)
{
Int2
-pgtype_money(StatementClass *stmt, Int4 type)
+pgtype_money(StatementClass * stmt, Int4 type)
{
switch (type)
{
Int2
-pgtype_searchable(StatementClass *stmt, Int4 type)
+pgtype_searchable(StatementClass * stmt, Int4 type)
{
switch (type)
{
Int2
-pgtype_unsigned(StatementClass *stmt, Int4 type)
+pgtype_unsigned(StatementClass * stmt, Int4 type)
{
switch (type)
{
char *
-pgtype_literal_prefix(StatementClass *stmt, Int4 type)
+pgtype_literal_prefix(StatementClass * stmt, Int4 type)
{
switch (type)
{
- case PG_TYPE_INT2:
- case PG_TYPE_OID:
- case PG_TYPE_XID:
- case PG_TYPE_INT4:
- case PG_TYPE_INT8:
- case PG_TYPE_NUMERIC:
- case PG_TYPE_FLOAT4:
- case PG_TYPE_FLOAT8:
- case PG_TYPE_MONEY:return NULL;
+ case PG_TYPE_INT2:
+ case PG_TYPE_OID:
+ case PG_TYPE_XID:
+ case PG_TYPE_INT4:
+ case PG_TYPE_INT8:
+ case PG_TYPE_NUMERIC:
+ case PG_TYPE_FLOAT4:
+ case PG_TYPE_FLOAT8:
+ case PG_TYPE_MONEY:
+ return NULL;
default:
return "'";
char *
-pgtype_literal_suffix(StatementClass *stmt, Int4 type)
+pgtype_literal_suffix(StatementClass * stmt, Int4 type)
{
switch (type)
{
- case PG_TYPE_INT2:
- case PG_TYPE_OID:
- case PG_TYPE_XID:
- case PG_TYPE_INT4:
- case PG_TYPE_INT8:
- case PG_TYPE_NUMERIC:
- case PG_TYPE_FLOAT4:
- case PG_TYPE_FLOAT8:
- case PG_TYPE_MONEY:return NULL;
+ case PG_TYPE_INT2:
+ case PG_TYPE_OID:
+ case PG_TYPE_XID:
+ case PG_TYPE_INT4:
+ case PG_TYPE_INT8:
+ case PG_TYPE_NUMERIC:
+ case PG_TYPE_FLOAT4:
+ case PG_TYPE_FLOAT8:
+ case PG_TYPE_MONEY:
+ return NULL;
default:
return "'";
char *
-pgtype_create_params(StatementClass *stmt, Int4 type)
+pgtype_create_params(StatementClass * stmt, Int4 type)
{
switch (type)
{
- case PG_TYPE_CHAR:
- case PG_TYPE_VARCHAR:return "max. length";
+ case PG_TYPE_CHAR:
+ case PG_TYPE_VARCHAR:
+ return "max. length";
default:
return NULL;
}
Int2
sqltype_to_default_ctype(Int2 sqltype)
{
-
/*
* from the table on page 623 of ODBC 2.0 Programmer's Reference
* (Appendix D)
/* Defines for pgtype_precision */
#define PG_STATIC (-1)
-Int4 sqltype_to_pgtype(StatementClass *stmt, Int2 fSqlType);
+Int4 sqltype_to_pgtype(StatementClass * stmt, Int2 fSqlType);
-Int2 pgtype_to_sqltype(StatementClass *stmt, Int4 type);
-Int2 pgtype_to_ctype(StatementClass *stmt, Int4 type);
-char *pgtype_to_name(StatementClass *stmt, Int4 type);
+Int2 pgtype_to_sqltype(StatementClass * stmt, Int4 type);
+Int2 pgtype_to_ctype(StatementClass * stmt, Int4 type);
+char *pgtype_to_name(StatementClass * stmt, Int4 type);
/* These functions can use static numbers or result sets(col parameter) */
-Int4 pgtype_precision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as);
-Int4 pgtype_display_size(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as);
-Int4 pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as);
+Int4 pgtype_precision(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as);
+Int4 pgtype_display_size(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as);
+Int4 pgtype_length(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as);
-Int2 pgtype_scale(StatementClass *stmt, Int4 type, int col);
-Int2 pgtype_radix(StatementClass *stmt, Int4 type);
-Int2 pgtype_nullable(StatementClass *stmt, Int4 type);
-Int2 pgtype_auto_increment(StatementClass *stmt, Int4 type);
-Int2 pgtype_case_sensitive(StatementClass *stmt, Int4 type);
-Int2 pgtype_money(StatementClass *stmt, Int4 type);
-Int2 pgtype_searchable(StatementClass *stmt, Int4 type);
-Int2 pgtype_unsigned(StatementClass *stmt, Int4 type);
-char *pgtype_literal_prefix(StatementClass *stmt, Int4 type);
-char *pgtype_literal_suffix(StatementClass *stmt, Int4 type);
-char *pgtype_create_params(StatementClass *stmt, Int4 type);
+Int2 pgtype_scale(StatementClass * stmt, Int4 type, int col);
+Int2 pgtype_radix(StatementClass * stmt, Int4 type);
+Int2 pgtype_nullable(StatementClass * stmt, Int4 type);
+Int2 pgtype_auto_increment(StatementClass * stmt, Int4 type);
+Int2 pgtype_case_sensitive(StatementClass * stmt, Int4 type);
+Int2 pgtype_money(StatementClass * stmt, Int4 type);
+Int2 pgtype_searchable(StatementClass * stmt, Int4 type);
+Int2 pgtype_unsigned(StatementClass * stmt, Int4 type);
+char *pgtype_literal_prefix(StatementClass * stmt, Int4 type);
+char *pgtype_literal_suffix(StatementClass * stmt, Int4 type);
+char *pgtype_create_params(StatementClass * stmt, Int4 type);
Int2 sqltype_to_default_ctype(Int2 sqltype);
Int4 ctype_length(Int2 ctype);
-
#endif
{
return TRUE;
}
-
#endif /* not __GNUC__ */
-
#endif /* not WIN32 */
* Driver Manager do this. Also, the ordinal values of the
* functions must match the value of fFunction in SQLGetFunctions()
*/
-RETCODE SQL_API
+RETCODE SQL_API
SQLDummyOrdinal(void)
{
return SQL_SUCCESS;
*
* Comments: See "notice.txt" for copyright and license information.
*
- * $Id: psqlodbc.h,v 1.51 2001/10/12 09:41:49 inoue Exp $
+ * $Id: psqlodbc.h,v 1.52 2001/10/25 05:50:15 momjian Exp $
*
*/
#define ODBCVER ODBCVER_REP
#else
#define ODBCVER 0x0250
-#endif /* ODBCVER_REP */
+#endif /* ODBCVER_REP */
#if defined(WIN32) || defined(WITH_UNIXODBC) || defined(WITH_IODBC)
char extra_systable_prefixes[MEDIUM_REGISTRY_LEN];
char conn_settings[LARGE_REGISTRY_LEN];
char protocol[SMALL_REGISTRY_LEN];
-} GLOBAL_VALUES;
+} GLOBAL_VALUES;
typedef struct StatementOptions_
{
int bind_size; /* size of each structure if using Row
* Binding */
int use_bookmarks;
- UInt4 *rowsFetched;
- UInt2 *rowStatusArray;
- void *bookmark_ptr;
-} StatementOptions;
+ UInt4 *rowsFetched;
+ UInt2 *rowStatusArray;
+ void *bookmark_ptr;
+} StatementOptions;
/* Used to pass extra query info to send_query */
typedef struct QueryInfo_
int row_size;
QResultClass *result_in;
char *cursor;
-} QueryInfo;
+} QueryInfo;
-void logs_on_off(int cnopen, int, int);
+void logs_on_off(int cnopen, int, int);
#define PG_TYPE_LO (-999) /* hack until permanent
* type available */
#define PG_NUMERIC_MAX_PRECISION 1000
#define PG_NUMERIC_MAX_SCALE 1000
-#define INFO_INQUIRY_LEN 8192 /* this seems sufficiently big for
-queries used in info.c inoue 2001/05/17 */
+#define INFO_INQUIRY_LEN 8192 /* this seems sufficiently big for
+ * queries used in info.c inoue
+ * 2001/05/17 */
#include "misc.h"
#ifdef _MEMORY_DEBUG_
-void * debug_alloc(size_t);
-void * debug_realloc(void *, size_t);
-char * debug_strdup(const char *);
-void debug_free(void *);
-void debug_memory_check(void);
-#define malloc debug_alloc
-#define realloc debug_realloc
-#define strdup debug_strdup
-#define free debug_free
-#endif /* _MEMORY_DEBUG_ */
+void *debug_alloc(size_t);
+void *debug_realloc(void *, size_t);
+char *debug_strdup(const char *);
+void debug_free(void *);
+void debug_memory_check(void);
+
+#define malloc debug_alloc
+#define realloc debug_realloc
+#define strdup debug_strdup
+#define free debug_free
+#endif /* _MEMORY_DEBUG_ */
#endif
* All info functions call this function to create the manual result set.
*/
void
-QR_set_num_fields(QResultClass *self, int new_num_fields)
+QR_set_num_fields(QResultClass * self, int new_num_fields)
{
mylog("in QR_set_num_fields\n");
void
-QR_set_position(QResultClass *self, int pos)
+QR_set_position(QResultClass * self, int pos)
{
self->tupleField = self->backend_tuples + ((self->base + pos) * self->num_fields);
}
void
-QR_set_cache_size(QResultClass *self, int cache_size)
+QR_set_cache_size(QResultClass * self, int cache_size)
{
self->cache_size = cache_size;
}
void
-QR_set_rowset_size(QResultClass *self, int rowset_size)
+QR_set_rowset_size(QResultClass * self, int rowset_size)
{
self->rowset_size = rowset_size;
}
void
-QR_inc_base(QResultClass *self, int base_inc)
+QR_inc_base(QResultClass * self, int base_inc)
{
self->base += base_inc;
}
void
-QR_Destructor(QResultClass *self)
+QR_Destructor(QResultClass * self)
{
mylog("QResult: in DESTRUCTOR\n");
void
-QR_set_command(QResultClass *self, char *msg)
+QR_set_command(QResultClass * self, char *msg)
{
if (self->command)
free(self->command);
void
-QR_set_notice(QResultClass *self, char *msg)
+QR_set_notice(QResultClass * self, char *msg)
{
if (self->notice)
free(self->notice);
void
-QR_free_memory(QResultClass *self)
+QR_free_memory(QResultClass * self)
{
register int lf,
row;
free(tuple[lf].value);
}
}
- tuple += num_fields;/* next row */
+ tuple += num_fields; /* next row */
}
free(self->backend_tuples);
/* This function is called by send_query() */
char
-QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor)
+QR_fetch_tuples(QResultClass * self, ConnectionClass * conn, char *cursor)
{
int tuple_size;
*/
if (conn != NULL)
{
- ConnInfo *ci = &(conn->connInfo);
- BOOL fetch_cursor = (ci->drivers.use_declarefetch && cursor && cursor[0]);
+ ConnInfo *ci = &(conn->connInfo);
+ BOOL fetch_cursor = (ci->drivers.use_declarefetch && cursor && cursor[0]);
+
self->conn = conn;
mylog("QR_fetch_tuples: cursor = '%s', self->cursor=%u\n", (cursor == NULL) ? "" : cursor, self->cursor);
}
else
{
-
/*
* Always have to read the field attributes. But we dont have to
* reallocate memory for them!
* We only close cursor/end the transaction if a cursor was used.
*/
int
-QR_close(QResultClass *self)
+QR_close(QResultClass * self)
{
QResultClass *res;
/* This function is called by fetch_tuples() AND SQLFetch() */
int
-QR_next_tuple(QResultClass *self)
+QR_next_tuple(QResultClass * self)
{
int id;
QResultClass *res;
char cmdbuffer[ERROR_MSG_LENGTH + 1];
char fetch[128];
QueryInfo qi;
- ConnInfo *ci = NULL;
+ ConnInfo *ci = NULL;
if (fetch_count < fcount)
{
}
else
{
-
/*
* See if we need to fetch another group of rows. We may be being
* called from send_query(), and if so, don't send another fetch,
if ((!self->cursor || !ci->drivers.use_declarefetch) && self->fcount >= self->count_allocated)
{
- int tuple_size = self->count_allocated;
+ int tuple_size = self->count_allocated;
mylog("REALLOC: old_count = %d, size = %d\n", tuple_size, self->num_fields * sizeof(TupleField) * tuple_size);
tuple_size *= 2;
self->backend_tuples = (TupleField *) realloc(self->backend_tuples,
- tuple_size * self->num_fields * sizeof(TupleField));
+ tuple_size * self->num_fields * sizeof(TupleField));
if (!self->backend_tuples)
{
self->status = PGRES_FATAL_ERROR;
char
-QR_read_tuple(QResultClass *self, char binary)
+QR_read_tuple(QResultClass * self, char binary)
{
Int2 field_lf;
TupleField *this_tuplefield;
}
else
{
-
/*
* NO, the field is not null. so get at first the length of
* the field (four bytes)
enum QueryResultCode_
{
- PGRES_EMPTY_QUERY = 0,
- PGRES_COMMAND_OK, /* a query command that doesn't return */
+ PGRES_EMPTY_QUERY = 0,
+ PGRES_COMMAND_OK, /* a query command that doesn't
+ * return */
/* anything was executed properly by the backend */
- PGRES_TUPLES_OK, /* a query command that returns tuples */
+ PGRES_TUPLES_OK,/* a query command that returns tuples */
/* was executed properly by the backend, PGresult */
/* contains the resulttuples */
- PGRES_COPY_OUT,
- PGRES_COPY_IN,
- PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from
- * the backend */
- PGRES_NONFATAL_ERROR,
- PGRES_FATAL_ERROR,
- PGRES_FIELDS_OK, /* field information from a query was
+ PGRES_COPY_OUT,
+ PGRES_COPY_IN,
+ PGRES_BAD_RESPONSE, /* an unexpected response was
+ * recv'd from the backend */
+ PGRES_NONFATAL_ERROR,
+ PGRES_FATAL_ERROR,
+ PGRES_FIELDS_OK,/* field information from a query was
* successful */
- PGRES_END_TUPLES,
- PGRES_INTERNAL_ERROR
+ PGRES_END_TUPLES,
+ PGRES_INTERNAL_ERROR
};
typedef enum QueryResultCode_ QueryResultCode;
* (backend) */
/* Stuff for declare/fetch tuples */
- int count_allocated; /* m(re)alloced count */
+ int count_allocated; /* m(re)alloced count */
int fetch_count; /* logical rows read so far */
int fcount; /* actual rows read in the fetch */
int currTuple;
/* Core Functions */
QResultClass *QR_Constructor(void);
-void QR_Destructor(QResultClass *self);
-char QR_read_tuple(QResultClass *self, char binary);
-int QR_next_tuple(QResultClass *self);
-int QR_close(QResultClass *self);
-char QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor);
-void QR_free_memory(QResultClass *self);
-void QR_set_command(QResultClass *self, char *msg);
-void QR_set_notice(QResultClass *self, char *msg);
-
-void QR_set_num_fields(QResultClass *self, int new_num_fields); /* manual result only */
-
-void QR_inc_base(QResultClass *self, int base_inc);
-void QR_set_cache_size(QResultClass *self, int cache_size);
-void QR_set_rowset_size(QResultClass *self, int rowset_size);
-void QR_set_position(QResultClass *self, int pos);
-
+void QR_Destructor(QResultClass * self);
+char QR_read_tuple(QResultClass * self, char binary);
+int QR_next_tuple(QResultClass * self);
+int QR_close(QResultClass * self);
+char QR_fetch_tuples(QResultClass * self, ConnectionClass * conn, char *cursor);
+void QR_free_memory(QResultClass * self);
+void QR_set_command(QResultClass * self, char *msg);
+void QR_set_notice(QResultClass * self, char *msg);
+
+void QR_set_num_fields(QResultClass * self, int new_num_fields); /* manual result only */
+
+void QR_inc_base(QResultClass * self, int base_inc);
+void QR_set_cache_size(QResultClass * self, int cache_size);
+void QR_set_rowset_size(QResultClass * self, int rowset_size);
+void QR_set_position(QResultClass * self, int pos);
#endif
-//{{NO_DEPENDENCIES}}\r
-// Microsoft Developer Studio generated include file.\r
-// Used by psqlodbc.rc\r
-//\r
-#define IDS_BADDSN 1\r
-#define IDS_MSGTITLE 2\r
-#define DLG_OPTIONS_DRV 102\r
-#define DLG_OPTIONS_DS 103\r
-#define IDC_DSNAME 400\r
-#define IDC_DSNAMETEXT 401\r
-#define IDC_DESC 404\r
-#define IDC_SERVER 407\r
-#define IDC_DATABASE 408\r
-#define DLG_CONFIG 1001\r
-#define IDC_PORT 1002\r
-#define IDC_USER 1006\r
-#define IDC_PASSWORD 1009\r
-#define DS_READONLY 1011\r
-#define DS_SHOWOIDCOLUMN 1012\r
-#define DS_FAKEOIDINDEX 1013\r
-#define DRV_COMMLOG 1014\r
-#define DS_PG62 1016\r
-#define IDC_DATASOURCE 1018\r
-#define DRV_OPTIMIZER 1019\r
-#define DS_CONNSETTINGS 1020\r
-#define IDC_DRIVER 1021\r
-#define DRV_CONNSETTINGS 1031\r
-#define DRV_UNIQUEINDEX 1032\r
-#define DRV_UNKNOWN_MAX 1035\r
-#define DRV_UNKNOWN_DONTKNOW 1036\r
-#define DRV_READONLY 1037\r
-#define IDC_DESCTEXT 1039\r
-#define DRV_MSG_LABEL 1040\r
-#define DRV_UNKNOWN_LONGEST 1041\r
-#define DRV_TEXT_LONGVARCHAR 1043\r
-#define DRV_UNKNOWNS_LONGVARCHAR 1044\r
-#define DRV_CACHE_SIZE 1045\r
-#define DRV_VARCHAR_SIZE 1046\r
-#define DRV_LONGVARCHAR_SIZE 1047\r
-#define IDDEFAULTS 1048\r
-#define DRV_USEDECLAREFETCH 1049\r
-#define DRV_BOOLS_CHAR 1050\r
-#define DS_SHOWSYSTEMTABLES 1051\r
-#define DRV_EXTRASYSTABLEPREFIXES 1051\r
-#define DS_ROWVERSIONING 1052\r
-#define DRV_PARSE 1052\r
-#define DRV_CANCELASFREESTMT 1053\r
-#define IDC_OPTIONS 1054\r
-#define DRV_KSQO 1055\r
-#define DS_PG64 1057\r
-#define DS_PG63 1058\r
-#define DRV_OR_DSN 1059\r
+/* {{NO_DEPENDENCIES}}\r */
+/* Microsoft Developer Studio generated include file.\r */
+/* Used by psqlodbc.rc\r */
+/*\r */
+#define IDS_BADDSN 1\r
+#define IDS_MSGTITLE 2\r
+#define DLG_OPTIONS_DRV 102\r
+#define DLG_OPTIONS_DS 103\r
+#define IDC_DSNAME 400\r
+#define IDC_DSNAMETEXT 401\r
+#define IDC_DESC 404\r
+#define IDC_SERVER 407\r
+#define IDC_DATABASE 408\r
+#define DLG_CONFIG 1001\r
+#define IDC_PORT 1002\r
+#define IDC_USER 1006\r
+#define IDC_PASSWORD 1009\r
+#define DS_READONLY 1011\r
+#define DS_SHOWOIDCOLUMN 1012\r
+#define DS_FAKEOIDINDEX 1013\r
+#define DRV_COMMLOG 1014\r
+#define DS_PG62 1016\r
+#define IDC_DATASOURCE 1018\r
+#define DRV_OPTIMIZER 1019\r
+#define DS_CONNSETTINGS 1020\r
+#define IDC_DRIVER 1021\r
+#define DRV_CONNSETTINGS 1031\r
+#define DRV_UNIQUEINDEX 1032\r
+#define DRV_UNKNOWN_MAX 1035\r
+#define DRV_UNKNOWN_DONTKNOW 1036\r
+#define DRV_READONLY 1037\r
+#define IDC_DESCTEXT 1039\r
+#define DRV_MSG_LABEL 1040\r
+#define DRV_UNKNOWN_LONGEST 1041\r
+#define DRV_TEXT_LONGVARCHAR 1043\r
+#define DRV_UNKNOWNS_LONGVARCHAR 1044\r
+#define DRV_CACHE_SIZE 1045\r
+#define DRV_VARCHAR_SIZE 1046\r
+#define DRV_LONGVARCHAR_SIZE 1047\r
+#define IDDEFAULTS 1048\r
+#define DRV_USEDECLAREFETCH 1049\r
+#define DRV_BOOLS_CHAR 1050\r
+#define DS_SHOWSYSTEMTABLES 1051\r
+#define DRV_EXTRASYSTABLEPREFIXES 1051\r
+#define DS_ROWVERSIONING 1052\r
+#define DRV_PARSE 1052\r
+#define DRV_CANCELASFREESTMT 1053\r
+#define IDC_OPTIONS 1054\r
+#define DRV_KSQO 1055\r
+#define DS_PG64 1057\r
+#define DS_PG63 1058\r
+#define DRV_OR_DSN 1059\r
#define DRV_DEBUG 1060\r
#define DS_DISALLOWPREMATURE 1061\r
\r
-// Next default values for new objects\r
-// \r
+/* Next default values for new objects\r */
+/*\r */
#ifdef APSTUDIO_INVOKED\r
#ifndef APSTUDIO_READONLY_SYMBOLS\r
-#define _APS_NEXT_RESOURCE_VALUE 105\r
-#define _APS_NEXT_COMMAND_VALUE 40001\r
-#define _APS_NEXT_CONTROL_VALUE 1062\r
-#define _APS_NEXT_SYMED_VALUE 101\r
-#endif\r
-#endif\r
+#define _APS_NEXT_RESOURCE_VALUE 105\r
+#define _APS_NEXT_COMMAND_VALUE 40001\r
+#define _APS_NEXT_CONTROL_VALUE 1062\r
+#define _APS_NEXT_SYMED_VALUE 101\r
+#endif /*\r */
+#endif /*\r */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_RowCount(
- HSTMT hstmt,
- SDWORD FAR *pcrow)
+ HSTMT hstmt,
+ SDWORD FAR * pcrow)
{
static char *func = "PGAPI_RowCount";
StatementClass *stmt = (StatementClass *) hstmt;
QResultClass *res;
char *msg,
*ptr;
- ConnInfo *ci;
+ ConnInfo *ci;
if (!stmt)
{
* This returns the number of columns associated with the database
* attached to "hstmt".
*/
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_NumResultCols(
- HSTMT hstmt,
- SWORD FAR *pccol)
+ HSTMT hstmt,
+ SWORD FAR * pccol)
{
static char *func = "PGAPI_NumResultCols";
StatementClass *stmt = (StatementClass *) hstmt;
QResultClass *result;
char parse_ok;
- ConnInfo *ci;
+ ConnInfo *ci;
if (!stmt)
{
*pccol = QR_NumResultCols(result);
/* updatable cursors */
if (ci->updatable_cursors &&
- stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY)
- {
+ stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY)
*pccol -= 2;
- }
}
return SQL_SUCCESS;
* Return information about the database column the user wants
* information about.
*/
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_DescribeCol(
- HSTMT hstmt,
- UWORD icol,
- UCHAR FAR *szColName,
- SWORD cbColNameMax,
- SWORD FAR *pcbColName,
- SWORD FAR *pfSqlType,
- UDWORD FAR *pcbColDef,
- SWORD FAR *pibScale,
- SWORD FAR *pfNullable)
+ HSTMT hstmt,
+ UWORD icol,
+ UCHAR FAR * szColName,
+ SWORD cbColNameMax,
+ SWORD FAR * pcbColName,
+ SWORD FAR * pfSqlType,
+ UDWORD FAR * pcbColDef,
+ SWORD FAR * pibScale,
+ SWORD FAR * pfNullable)
{
static char *func = "PGAPI_DescribeCol";
QResultClass *res;
char *col_name = NULL;
Int4 fieldtype = 0;
- int precision = 0, scale = 0;
+ int precision = 0,
+ scale = 0;
ConnInfo *ci;
char parse_ok;
char buf[255];
/* Returns result column descriptor information for a result set. */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_ColAttributes(
- HSTMT hstmt,
- UWORD icol,
- UWORD fDescType,
- PTR rgbDesc,
- SWORD cbDescMax,
- SWORD FAR *pcbDesc,
- SDWORD FAR *pfDesc)
+ HSTMT hstmt,
+ UWORD icol,
+ UWORD fDescType,
+ PTR rgbDesc,
+ SWORD cbDescMax,
+ SWORD FAR * pcbDesc,
+ SDWORD FAR * pfDesc)
{
static char *func = "PGAPI_ColAttributes";
StatementClass *stmt = (StatementClass *) hstmt;
/* Returns result data for a single column in the current row. */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_GetData(
- HSTMT hstmt,
- UWORD icol,
- SWORD fCType,
- PTR rgbValue,
- SDWORD cbValueMax,
- SDWORD FAR *pcbValue)
+ HSTMT hstmt,
+ UWORD icol,
+ SWORD fCType,
+ PTR rgbValue,
+ SDWORD cbValueMax,
+ SDWORD FAR * pcbValue)
{
static char *func = "PGAPI_GetData";
QResultClass *res;
void *value = NULL;
int result;
char get_bookmark = FALSE;
- ConnInfo *ci;
+ ConnInfo *ci;
mylog("PGAPI_GetData: enter, stmt=%u\n", stmt);
* Returns data for bound columns in the current row ("hstmt->iCursor"),
* advances the cursor.
*/
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_Fetch(
- HSTMT hstmt)
+ HSTMT hstmt)
{
static char *func = "PGAPI_Fetch";
StatementClass *stmt = (StatementClass *) hstmt;
/* This fetchs a block of data (rowset). */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_ExtendedFetch(
- HSTMT hstmt,
- UWORD fFetchType,
- SDWORD irow,
- UDWORD FAR *pcrow,
- UWORD FAR *rgfRowStatus)
+ HSTMT hstmt,
+ UWORD fFetchType,
+ SDWORD irow,
+ UDWORD FAR * pcrow,
+ UWORD FAR * rgfRowStatus)
{
static char *func = "PGAPI_ExtendedFetch";
StatementClass *stmt = (StatementClass *) hstmt;
RETCODE result;
char truncated,
error;
- ConnInfo *ci;
+ ConnInfo *ci;
mylog("PGAPI_ExtendedFetch: stmt=%u\n", stmt);
/* this should be refined */
else if (result > 10 && result < 20)
*(rgfRowStatus + i) = result - 10;
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+#endif /* DRIVER_CURSOR_IMPLEMENT */
else
*(rgfRowStatus + i) = SQL_ROW_SUCCESS;
}
* the "hstmt".
*/
/* CC: return SQL_NO_DATA_FOUND since we do not support multiple result sets */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_MoreResults(
- HSTMT hstmt)
+ HSTMT hstmt)
{
return SQL_NO_DATA_FOUND;
}
#ifdef DRIVER_CURSOR_IMPLEMENT
/*
- * Stuff for updatable cursors.
+ * Stuff for updatable cursors.
*/
static QResultClass *
-positioned_load(StatementClass *stmt, BOOL latest, int res_cols, UInt4 oid, const char *tidval)
+positioned_load(StatementClass * stmt, BOOL latest, int res_cols, UInt4 oid, const char *tidval)
{
- int i;
- QResultClass *qres;
- char selstr[4096];
+ int i;
+ QResultClass *qres;
+ char selstr[4096];
sprintf(selstr, "select");
for (i = 0; i < res_cols; i++)
{
if (latest)
sprintf(selstr, "%s ctid = currtid2('%s', '%s') and",
- selstr, stmt->ti[0]->name, tidval);
+ selstr, stmt->ti[0]->name, tidval);
else
sprintf(selstr, "%s ctid = '%s' and", selstr, tidval);
}
- sprintf(selstr, "%s oid = %u", selstr, oid),
- mylog("selstr=%s\n", selstr);
+ sprintf(selstr, "%s oid = %u", selstr, oid),
+ mylog("selstr=%s\n", selstr);
qres = CC_send_query(SC_get_conn(stmt), selstr, NULL);
if (qres && QR_aborted(qres))
{
return qres;
}
-RETCODE SQL_API
-SC_pos_reload(StatementClass *stmt, UWORD irow, UWORD *count)
+RETCODE SQL_API
+SC_pos_reload(StatementClass * stmt, UWORD irow, UWORD * count)
{
- int i, res_cols;
- UWORD rcnt, global_ridx;
- UInt4 oid;
- QResultClass *res, *qres;
- RETCODE ret = SQL_ERROR;
- char *tidval, *oidval;
+ int i,
+ res_cols;
+ UWORD rcnt,
+ global_ridx;
+ UInt4 oid;
+ QResultClass *res,
+ *qres;
+ RETCODE ret = SQL_ERROR;
+ char *tidval,
+ *oidval;
mylog("positioned load fi=%x ti=%x\n", stmt->fi, stmt->ti);
rcnt = 0;
if (!(res = stmt->result))
return SQL_ERROR;
if (!stmt->ti)
- parse_statement(stmt); /* not preferable */
+ parse_statement(stmt); /* not preferable */
if (!stmt->ti || stmt->ntab != 1)
{
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
global_ridx = irow + stmt->rowset_start;
res_cols = QR_NumResultCols(res);
if (!(oidval = QR_get_value_backend_row(res, global_ridx, res_cols - 1)))
- {
return SQL_SUCCESS_WITH_INFO;
- }
- sscanf(oidval, "%u", &oid);
+ sscanf(oidval, "%u", &oid);
tidval = QR_get_value_backend_row(res, global_ridx, res_cols - 2);
res_cols -= 2;
if (qres = positioned_load(stmt, TRUE, res_cols, oid, tidval), qres)
{
- TupleField *tupleo, *tuplen;
+ TupleField *tupleo,
+ *tuplen;
rcnt = QR_get_num_tuples(qres);
tupleo = res->backend_tuples + res->num_fields * global_ridx;
return ret;
}
-RETCODE SQL_API
-SC_pos_newload(StatementClass *stmt, UInt4 oid, const char *tidval)
+RETCODE SQL_API
+SC_pos_newload(StatementClass * stmt, UInt4 oid, const char *tidval)
{
- int i;
- QResultClass *res, *qres;
- RETCODE ret = SQL_ERROR;
+ int i;
+ QResultClass *res,
+ *qres;
+ RETCODE ret = SQL_ERROR;
mylog("positioned new fi=%x ti=%x\n", stmt->fi, stmt->ti);
if (!(res = stmt->result))
return SQL_ERROR;
if (!stmt->ti)
- parse_statement(stmt); /* not preferable */
+ parse_statement(stmt); /* not preferable */
if (!stmt->ti || stmt->ntab != 1)
{
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
return SQL_ERROR;
}
if (qres = positioned_load(stmt, TRUE, QR_NumResultCols(res) - 2, oid, tidval), qres)
- {
- TupleField *tupleo, *tuplen;
- int count = QR_get_num_tuples(qres);
+ {
+ TupleField *tupleo,
+ *tuplen;
+ int count = QR_get_num_tuples(qres);
+
QR_set_position(qres, 0);
if (count == 1)
{
tuplen = qres->tupleField;
if (res->fcount >= res->count_allocated)
{
- int tuple_size;
+ int tuple_size;
+
if (!res->count_allocated)
tuple_size = TUPLE_MALLOC_INC;
else
tuple_size = res->count_allocated * 2;
res->backend_tuples = (TupleField *) realloc(
- res->backend_tuples,
- res->num_fields * sizeof(TupleField) * tuple_size);
+ res->backend_tuples,
+ res->num_fields * sizeof(TupleField) * tuple_size);
if (!res->backend_tuples)
{
stmt->errornumber = res->status = PGRES_FATAL_ERROR;
}
res->count_allocated = tuple_size;
}
- tupleo = res->backend_tuples + res->num_fields * res->fcount;
+ tupleo = res->backend_tuples + res->num_fields * res->fcount;
for (i = 0; i < res->num_fields; i++)
{
tupleo[i].len = tuplen[i].len;
ret = SQL_SUCCESS_WITH_INFO;
}
QR_Destructor(qres);
- /*stmt->currTuple = stmt->rowset_start + irow;*/
+ /* stmt->currTuple = stmt->rowset_start + irow; */
}
return ret;
}
-RETCODE SQL_API
-SC_pos_update(StatementClass *stmt,
- UWORD irow)
+RETCODE SQL_API
+SC_pos_update(StatementClass * stmt,
+ UWORD irow)
{
- int i, res_cols, num_cols, upd_cols;
- UWORD global_ridx;
- QResultClass *res;
+ int i,
+ res_cols,
+ num_cols,
+ upd_cols;
+ UWORD global_ridx;
+ QResultClass *res;
BindInfoClass *bindings = stmt->bindings;
- char updstr[4096];
- RETCODE ret;
- char *tidval, *oidval;
+ char updstr[4096];
+ RETCODE ret;
+ char *tidval,
+ *oidval;
mylog("POS UPDATE %d+%d fi=%x ti=%x\n", irow, stmt->result->base, stmt->fi, stmt->ti);
if (!(res = stmt->result))
return SQL_ERROR;
if (!stmt->ti)
- parse_statement(stmt); /* not preferable */
+ parse_statement(stmt); /* not preferable */
if (!stmt->ti || stmt->ntab != 1)
{
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
{
stmt->errormsg = "The row is already deleted";
return SQL_ERROR;
- }
+ }
tidval = QR_get_value_backend_row(res, global_ridx, res_cols - 2);
sprintf(updstr, "update \"%s\" set", stmt->ti[0]->name);
}
if (upd_cols > 0)
{
- HSTMT hstmt;
- int j;
- int res_cols = QR_NumResultCols(res);
- StatementClass *qstmt;
+ HSTMT hstmt;
+ int j;
+ int res_cols = QR_NumResultCols(res);
+ StatementClass *qstmt;
sprintf(updstr, "%s where ctid = '%s' and oid = %s", updstr,
- tidval, oidval);
+ tidval, oidval);
mylog("updstr=%s\n", updstr);
if (PGAPI_AllocStmt(SC_get_conn(stmt), &hstmt) != SQL_SUCCESS)
return SQL_ERROR;
mylog("%d used=%d\n", i, *bindings[i].used);
if (*bindings[i].used != SQL_IGNORE)
{
- PGAPI_BindParameter(hstmt, (SQLUSMALLINT) ++j,
- SQL_PARAM_INPUT, bindings[i].returntype,
- pgtype_to_sqltype(stmt, QR_get_field_type(res, i)),
- QR_get_fieldsize(res, i),
- (SQLSMALLINT) stmt->fi[i]->precision,
- bindings[i].buffer,
- bindings[i].buflen,
- bindings[i].used);
+ PGAPI_BindParameter(hstmt, (SQLUSMALLINT)++ j,
+ SQL_PARAM_INPUT, bindings[i].returntype,
+ pgtype_to_sqltype(stmt, QR_get_field_type(res, i)),
+ QR_get_fieldsize(res, i),
+ (SQLSMALLINT) stmt->fi[i]->precision,
+ bindings[i].buffer,
+ bindings[i].buflen,
+ bindings[i].used);
}
}
}
stmt->errornumber = qstmt->errornumber;
stmt->errormsg = qstmt->errormsg;
}
- else if (ret == SQL_NEED_DATA) /* must be fixed */
+ else if (ret == SQL_NEED_DATA) /* must be fixed */
{
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
stmt->errornumber = STMT_INVALID_CURSOR_STATE_ERROR;
}
if (ret != SQL_ERROR)
{
- int updcnt;
+ int updcnt;
const char *cmdstr = QR_get_command(qstmt->result);
+
if (cmdstr &&
- sscanf(cmdstr, "UPDATE %d", &updcnt) == 1)
- {
+ sscanf(cmdstr, "UPDATE %d", &updcnt) == 1)
+ {
if (updcnt == 1)
SC_pos_reload(stmt, irow, (UWORD *) 0);
else if (updcnt == 0)
else
ret = SQL_ERROR;
stmt->currTuple = stmt->rowset_start + irow;
- }
+ }
else
ret = SQL_ERROR;
if (ret == SQL_ERROR && stmt->errornumber == 0)
ret = SQL_SUCCESS_WITH_INFO;
return ret;
}
-RETCODE SQL_API
-SC_pos_delete(StatementClass *stmt,
- UWORD irow)
+RETCODE SQL_API
+SC_pos_delete(StatementClass * stmt,
+ UWORD irow)
{
- int res_cols;
- UWORD global_ridx;
- QResultClass *res, *qres;
+ int res_cols;
+ UWORD global_ridx;
+ QResultClass *res,
+ *qres;
BindInfoClass *bindings = stmt->bindings;
- char dltstr[4096];
- RETCODE ret;
- char *oidval;
+ char dltstr[4096];
+ RETCODE ret;
+ char *oidval;
mylog("POS DELETE fi=%x ti=%x\n", stmt->fi, stmt->ti);
if (!(res = stmt->result))
return SQL_ERROR;
if (!stmt->ti)
- parse_statement(stmt); /* not preferable */
+ parse_statement(stmt); /* not preferable */
if (!stmt->ti || stmt->ntab != 1)
{
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
{
stmt->errormsg = "The row is already deleted";
return SQL_ERROR;
- }
+ }
sprintf(dltstr, "delete from \"%s\" where ctid = '%s' and oid = %s",
stmt->ti[0]->name,
- QR_get_value_backend_row(stmt->result, global_ridx, res_cols - 2),
- oidval);
+ QR_get_value_backend_row(stmt->result, global_ridx, res_cols - 2),
+ oidval);
mylog("dltstr=%s\n", dltstr);
qres = CC_send_query(SC_get_conn(stmt), dltstr, NULL);
if (qres && QR_command_successful(qres))
{
- int dltcnt;
+ int dltcnt;
const char *cmdstr = QR_get_command(qres);
+
if (cmdstr &&
- sscanf(cmdstr, "DELETE %d", &dltcnt) == 1)
+ sscanf(cmdstr, "DELETE %d", &dltcnt) == 1)
{
if (dltcnt == 1)
SC_pos_reload(stmt, irow, (UWORD *) 0);
QR_Destructor(qres);
return ret;
}
-RETCODE SQL_API
-SC_pos_add(StatementClass *stmt,
- UWORD irow)
+RETCODE SQL_API
+SC_pos_add(StatementClass * stmt,
+ UWORD irow)
{
- int num_cols, add_cols, i;
- HSTMT hstmt;
- QResultClass *res;
+ int num_cols,
+ add_cols,
+ i;
+ HSTMT hstmt;
+ QResultClass *res;
BindInfoClass *bindings = stmt->bindings;
- char addstr[4096];
- RETCODE ret;
+ char addstr[4096];
+ RETCODE ret;
mylog("POS ADD fi=%x ti=%x\n", stmt->fi, stmt->ti);
if (!(res = stmt->result))
return SQL_ERROR;
if (!stmt->ti)
- parse_statement(stmt); /* not preferable */
+ parse_statement(stmt); /* not preferable */
if (!stmt->ti || stmt->ntab != 1)
{
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
sprintf(addstr, "%s, \"%s\"", addstr, stmt->fi[i]->name);
else
sprintf(addstr, "%s\"%s\"", addstr, stmt->fi[i]->name);
- PGAPI_BindParameter(hstmt, (SQLUSMALLINT) ++add_cols,
- SQL_PARAM_INPUT, bindings[i].returntype,
- pgtype_to_sqltype(stmt, QR_get_field_type(res, i)),
- QR_get_fieldsize(res, i),
- (SQLSMALLINT) stmt->fi[i]->precision,
- bindings[i].buffer,
- bindings[i].buflen,
- bindings[i].used);
+ PGAPI_BindParameter(hstmt, (SQLUSMALLINT)++ add_cols,
+ SQL_PARAM_INPUT, bindings[i].returntype,
+ pgtype_to_sqltype(stmt, QR_get_field_type(res, i)),
+ QR_get_fieldsize(res, i),
+ (SQLSMALLINT) stmt->fi[i]->precision,
+ bindings[i].buffer,
+ bindings[i].buflen,
+ bindings[i].used);
}
}
else
}
if (add_cols > 0)
{
- StatementClass *qstmt = (StatementClass *) hstmt;
+ StatementClass *qstmt = (StatementClass *) hstmt;
sprintf(addstr, "%s) values (", addstr);
for (i = 0; i < add_cols; i++)
strcat(addstr, ")");
mylog("addstr=%s\n", addstr);
ret = PGAPI_ExecDirect(hstmt, addstr, strlen(addstr));
- if (ret == SQL_NEED_DATA) /* must be fixed */
+ if (ret == SQL_NEED_DATA) /* must be fixed */
{
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
stmt->errornumber = STMT_INVALID_CURSOR_STATE_ERROR;
}
if (ret == SQL_ERROR)
{
- stmt->errornumber = qstmt->errornumber;
- stmt->errormsg = qstmt->errormsg;
+ stmt->errornumber = qstmt->errornumber;
+ stmt->errormsg = qstmt->errormsg;
}
else
{
- int addcnt;
- UInt4 oid;
+ int addcnt;
+ UInt4 oid;
const char *cmdstr = QR_get_command(qstmt->result);
+
if (cmdstr &&
- sscanf(cmdstr, "INSERT %u %d", &oid, &addcnt) == 2 &&
- addcnt == 1)
+ sscanf(cmdstr, "INSERT %u %d", &oid, &addcnt) == 2 &&
+ addcnt == 1)
{
SC_pos_newload(stmt, oid, NULL);
- if (stmt->bookmark.buffer)
- {
- char buf[32];
-
- sprintf(buf, "%ld", res->fcount);
- copy_and_convert_field(stmt, 0, buf,
- SQL_C_ULONG, stmt->bookmark.buffer,
- 0, stmt->bookmark.used);
- }
+ if (stmt->bookmark.buffer)
+ {
+ char buf[32];
+
+ sprintf(buf, "%ld", res->fcount);
+ copy_and_convert_field(stmt, 0, buf,
+ SQL_C_ULONG, stmt->bookmark.buffer,
+ 0, stmt->bookmark.used);
+ }
}
else
{
PGAPI_FreeStmt(hstmt, SQL_DROP);
return ret;
}
+
/*
- * Stuff for updatable cursors end.
+ * Stuff for updatable cursors end.
*/
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+#endif /* DRIVER_CURSOR_IMPLEMENT */
/*
* This positions the cursor within a rowset, that was positioned using SQLExtendedFetch.
* This will be useful (so far) only when using SQLGetData after SQLExtendedFetch.
*/
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_SetPos(
- HSTMT hstmt,
- UWORD irow,
- UWORD fOption,
- UWORD fLock)
+ HSTMT hstmt,
+ UWORD irow,
+ UWORD fOption,
+ UWORD fLock)
{
static char *func = "PGAPI_SetPos";
StatementClass *stmt = (StatementClass *) hstmt;
if (stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY)
;
else
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+#endif /* DRIVER_CURSOR_IMPLEMENT */
if (fOption != SQL_POSITION && fOption != SQL_REFRESH)
{
stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
case SQL_ADD:
return SC_pos_add(stmt, irow);
}
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+#endif /* DRIVER_CURSOR_IMPLEMENT */
/* Reset for SQLGetData */
for (i = 0; i < num_cols; i++)
bindings[i].data_left = -1;
if (fOption == SQL_REFRESH)
{
/* save the last_fetch_count */
- int last_fetch = stmt->last_fetch_count;
- int bind_save = stmt->bind_row;
+ int last_fetch = stmt->last_fetch_count;
+ int bind_save = stmt->bind_row;
#ifdef DRIVER_CURSOR_IMPLEMENT
if (stmt->options.cursor_type == SQL_CURSOR_KEYSET_DRIVEN)
- SC_pos_reload(stmt, irow, (UWORD *) 0);
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+ SC_pos_reload(stmt, irow, (UWORD *) 0);
+#endif /* DRIVER_CURSOR_IMPLEMENT */
stmt->currTuple = stmt->rowset_start + irow - 1;
stmt->bind_row = irow;
SC_fetch(stmt);
/* Sets options that control the behavior of cursors. */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_SetScrollOptions(
- HSTMT hstmt,
- UWORD fConcurrency,
- SDWORD crowKeyset,
- UWORD crowRowset)
+ HSTMT hstmt,
+ UWORD fConcurrency,
+ SDWORD crowKeyset,
+ UWORD crowRowset)
{
static char *func = "PGAPI_SetScrollOptions";
StatementClass *stmt = (StatementClass *) hstmt;
+
mylog("PGAPI_SetScrollOptions fConcurrency=%d crowKeyset=%d crowRowset=%d\n",
- fConcurrency, crowKeyset, crowRowset);
+ fConcurrency, crowKeyset, crowRowset);
stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
stmt->errormsg = "SetScroll option not implemeted";
/* Set the cursor name on a statement handle */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_SetCursorName(
- HSTMT hstmt,
- UCHAR FAR *szCursor,
- SWORD cbCursor)
+ HSTMT hstmt,
+ UCHAR FAR * szCursor,
+ SWORD cbCursor)
{
static char *func = "PGAPI_SetCursorName";
StatementClass *stmt = (StatementClass *) hstmt;
/* Return the cursor name for a statement handle */
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_GetCursorName(
- HSTMT hstmt,
- UCHAR FAR *szCursor,
- SWORD cbCursorMax,
- SWORD FAR *pcbCursor)
+ HSTMT hstmt,
+ UCHAR FAR * szCursor,
+ SWORD cbCursorMax,
+ SWORD FAR * pcbCursor)
{
static char *func = "PGAPI_GetCursorName";
StatementClass *stmt = (StatementClass *) hstmt;
#define INTFUNC __stdcall
-extern HINSTANCE NEAR s_hModule;/* Saved module handle. */
+extern HINSTANCE NEAR s_hModule; /* Saved module handle. */
/* Constants */
#define MIN(x,y) ((x) < (y) ? (x) : (y))
BOOL fNewDSN; /* New data source flag */
BOOL fDefault; /* Default data source flag */
-} SETUPDLG, FAR *LPSETUPDLG;
+} SETUPDLG, FAR * LPSETUPDLG;
LPARAM lParam)
{
LPSETUPDLG lpsetupdlg;
- ConnInfo *ci;
+ ConnInfo *ci;
+
switch (wMsg)
{
- /* Initialize the dialog */
+ /* Initialize the dialog */
case WM_INITDIALOG:
lpsetupdlg = (LPSETUPDLG) lParam;
ci = &lpsetupdlg->ci;
ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL), SW_HIDE);
SetWindowLong(hdlg, DWL_USER, lParam);
- CenterDialog(hdlg); /* Center dialog */
+ CenterDialog(hdlg); /* Center dialog */
/*
- * NOTE: Values supplied in the attribute string will
- * always
+ * NOTE: Values supplied in the attribute string will always
*/
/* override settings in ODBC.INI */
}
else
SendDlgItemMessage(hdlg, IDC_DSNAME,
- EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), 0L);
+ EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), 0L);
SendDlgItemMessage(hdlg, IDC_DESC,
- EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), 0L);
- return TRUE; /* Focus was not set */
+ EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), 0L);
+ return TRUE; /* Focus was not set */
/* Process buttons */
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
-
/*
* Ensure the OK button is enabled only when a data
* source name
/* Retrieve dialog values */
if (!lpsetupdlg->fDefault)
GetDlgItemText(hdlg, IDC_DSNAME,
- lpsetupdlg->ci.dsn,
- sizeof(lpsetupdlg->ci.dsn));
+ lpsetupdlg->ci.dsn,
+ sizeof(lpsetupdlg->ci.dsn));
/* Get Dialog Values */
GetDlgStuff(hdlg, &lpsetupdlg->ci);
case IDC_DRIVER:
lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWL_USER);
DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV),
- hdlg, driver_optionsProc, (LPARAM) &lpsetupdlg->ci);
+ hdlg, driver_optionsProc, (LPARAM) & lpsetupdlg->ci);
return TRUE;
case IDC_DATASOURCE:
lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWL_USER);
DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DS),
- hdlg, ds_optionsProc, (LPARAM) &lpsetupdlg->ci);
+ hdlg, ds_optionsProc, (LPARAM) & lpsetupdlg->ci);
return TRUE;
}
for (lpsz = lpszAttributes; *lpsz; lpsz++)
{
-
/*
* Extract key name (e.g., DSN), it must be terminated by an
* equals
void
-SOCK_clear_error(SocketClass *self)
+SOCK_clear_error(SocketClass * self)
{
self->errornumber = 0;
self->errormsg = NULL;
SocketClass *
-SOCK_Constructor(const ConnectionClass *conn)
+SOCK_Constructor(const ConnectionClass * conn)
{
SocketClass *rv;
void
-SOCK_Destructor(SocketClass *self)
+SOCK_Destructor(SocketClass * self)
{
-mylog("SOCK_Destructor\n");
+ mylog("SOCK_Destructor\n");
if (self->socket != -1)
{
SOCK_put_char(self, 'X');
char
-SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname)
+SOCK_connect_to(SocketClass * self, unsigned short port, char *hostname)
{
struct hostent *host;
struct sockaddr_in sadr;
void
-SOCK_get_n_char(SocketClass *self, char *buffer, int len)
+SOCK_get_n_char(SocketClass * self, char *buffer, int len)
{
int lf;
void
-SOCK_put_n_char(SocketClass *self, char *buffer, int len)
+SOCK_put_n_char(SocketClass * self, char *buffer, int len)
{
int lf;
* returns TRUE if truncation occurs.
*/
BOOL
-SOCK_get_string(SocketClass *self, char *buffer, int bufsize)
+SOCK_get_string(SocketClass * self, char *buffer, int bufsize)
{
register int lf = 0;
void
-SOCK_put_string(SocketClass *self, char *string)
+SOCK_put_string(SocketClass * self, char *string)
{
register int lf;
int len;
int
-SOCK_get_int(SocketClass *self, short len)
+SOCK_get_int(SocketClass * self, short len)
{
switch (len)
{
- case 2:
+ case 2:
{
unsigned short buf;
void
-SOCK_put_int(SocketClass *self, int value, short len)
+SOCK_put_int(SocketClass * self, int value, short len)
{
unsigned int rv;
void
-SOCK_flush_output(SocketClass *self)
+SOCK_flush_output(SocketClass * self)
{
int written;
unsigned char
-SOCK_get_next_byte(SocketClass *self)
+SOCK_get_next_byte(SocketClass * self)
{
if (self->buffer_read_in >= self->buffer_filled_in)
{
-
/*
* there are no more bytes left in the buffer so reload the buffer
*/
void
-SOCK_put_next_byte(SocketClass *self, unsigned char next_byte)
+SOCK_put_next_byte(SocketClass * self, unsigned char next_byte)
{
int bytes_sent;
#ifndef _IN_ADDR_T
#define _IN_ADDR_T
typedef unsigned int in_addr_t;
-
#endif
#define INADDR_NONE ((in_addr_t)-1)
#endif
/* Socket prototypes */
-SocketClass *SOCK_Constructor(const ConnectionClass *conn);
-void SOCK_Destructor(SocketClass *self);
-char SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname);
-void SOCK_get_n_char(SocketClass *self, char *buffer, int len);
-void SOCK_put_n_char(SocketClass *self, char *buffer, int len);
-BOOL SOCK_get_string(SocketClass *self, char *buffer, int bufsize);
-void SOCK_put_string(SocketClass *self, char *string);
-int SOCK_get_int(SocketClass *self, short len);
-void SOCK_put_int(SocketClass *self, int value, short len);
-void SOCK_flush_output(SocketClass *self);
-unsigned char SOCK_get_next_byte(SocketClass *self);
-void SOCK_put_next_byte(SocketClass *self, unsigned char next_byte);
-void SOCK_clear_error(SocketClass *self);
-
+SocketClass *SOCK_Constructor(const ConnectionClass * conn);
+void SOCK_Destructor(SocketClass * self);
+char SOCK_connect_to(SocketClass * self, unsigned short port, char *hostname);
+void SOCK_get_n_char(SocketClass * self, char *buffer, int len);
+void SOCK_put_n_char(SocketClass * self, char *buffer, int len);
+BOOL SOCK_get_string(SocketClass * self, char *buffer, int bufsize);
+void SOCK_put_string(SocketClass * self, char *string);
+int SOCK_get_int(SocketClass * self, short len);
+void SOCK_put_int(SocketClass * self, int value, short len);
+void SOCK_flush_output(SocketClass * self);
+unsigned char SOCK_get_next_byte(SocketClass * self);
+void SOCK_put_next_byte(SocketClass * self, unsigned char next_byte);
+void SOCK_clear_error(SocketClass * self);
#endif
};
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_AllocStmt(HDBC hdbc,
- HSTMT FAR *phstmt)
+ HSTMT FAR * phstmt)
{
static char *func = "PGAPI_AllocStmt";
ConnectionClass *conn = (ConnectionClass *) hdbc;
}
-RETCODE SQL_API
+RETCODE SQL_API
PGAPI_FreeStmt(HSTMT hstmt,
- UWORD fOption)
+ UWORD fOption)
{
static char *func = "PGAPI_FreeStmt";
StatementClass *stmt = (StatementClass *) hstmt;
SC_unbind_cols(stmt);
else if (fOption == SQL_CLOSE)
{
-
/*
* this should discard all the results, but leave the statement
* itself in place (it can be executed again)
* StatementClass implementation
*/
void
-InitializeStatementOptions(StatementOptions *opt)
+InitializeStatementOptions(StatementOptions * opt)
{
opt->maxRows = 0; /* driver returns all rows */
opt->maxLength = 0; /* driver returns all data for char/binary */
char
-SC_Destructor(StatementClass *self)
+SC_Destructor(StatementClass * self)
{
mylog("SC_Destructor: self=%u, self->result=%u, self->hdbc=%u\n", self, self->result, self->hdbc);
SC_clear_error(self);
* data-at-execution parameters that was allocated in SQLPutData.
*/
void
-SC_free_params(StatementClass *self, char option)
+SC_free_params(StatementClass * self, char option)
{
int i;
* from SQLFreeStmt(SQL_CLOSE)
*/
char
-SC_recycle_statement(StatementClass *self)
+SC_recycle_statement(StatementClass * self)
{
ConnectionClass *conn;
conn = SC_get_conn(self);
if (!CC_is_in_autocommit(conn) && CC_is_in_trans(conn))
{
- if (SC_is_pre_executable(self) && !conn->connInfo.disallow_premature)
+ if (SC_is_pre_executable(self) && !conn->connInfo.disallow_premature)
CC_abort(conn);
}
break;
* Reset only parameters that have anything to do with results
*/
self->status = STMT_READY;
- self->manual_result = FALSE;/* very important */
+ self->manual_result = FALSE; /* very important */
self->currTuple = -1;
self->rowset_start = -1;
/* Pre-execute a statement (SQLPrepare/SQLDescribeCol) */
void
-SC_pre_execute(StatementClass *self)
+SC_pre_execute(StatementClass * self)
{
mylog("SC_pre_execute: status = %d\n", self->status);
/* This is only called from SQLFreeStmt(SQL_UNBIND) */
char
-SC_unbind_cols(StatementClass *self)
+SC_unbind_cols(StatementClass * self)
{
Int2 lf;
void
-SC_clear_error(StatementClass *self)
+SC_clear_error(StatementClass * self)
{
if (self->errormsg_malloced && self->errormsg)
free(self->errormsg);
* of the result, statement, connection, and socket messages.
*/
char *
-SC_create_errormsg(StatementClass *self)
+SC_create_errormsg(StatementClass * self)
{
QResultClass *res = self->result;
ConnectionClass *conn = self->hdbc;
char
-SC_get_error(StatementClass *self, int *number, char **message)
+SC_get_error(StatementClass * self, int *number, char **message)
{
char rv;
* someday, such as mapping a key to a 32 bit value
*/
unsigned long
-SC_get_bookmark(StatementClass *self)
+SC_get_bookmark(StatementClass * self)
{
return (self->currTuple + 1);
}
RETCODE
-SC_fetch(StatementClass *self)
+SC_fetch(StatementClass * self)
{
static char *func = "SC_fetch";
QResultClass *res = self->result;
int retval,
result;
+
#ifdef DRIVER_CURSOR_IMPLEMENT
- int updret;
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+ int updret;
+#endif /* DRIVER_CURSOR_IMPLEMENT */
Int2 num_cols,
lf;
Oid type;
char *value;
ColumnInfoClass *coli;
+
/* TupleField *tupleField; */
- ConnInfo *ci = &(SC_get_conn(self)->connInfo);
+ ConnInfo *ci = &(SC_get_conn(self)->connInfo);
self->last_fetch_count = 0;
coli = QR_get_fields(res); /* the column info */
if (self->currTuple >= QR_get_num_tuples(res) - 1 ||
(self->options.maxRows > 0 && self->currTuple == self->options.maxRows - 1))
{
-
/*
* if at the end of the tuples, return "no data found" and set
* the cursor past the end of the result set
return SQL_NO_DATA_FOUND;
}
else if (retval > 0)
- (self->currTuple)++;/* all is well */
+ (self->currTuple)++; /* all is well */
else
{
mylog("SC_fetch: error\n");
updret = SQL_ROW_DELETED;
num_cols -= 2;
}
-#endif /* DRIVER_CURSOR_IMPLEMENT */
- if (self->options.retrieve_data == SQL_RD_OFF) /* data isn't required */
+#endif /* DRIVER_CURSOR_IMPLEMENT */
+ if (self->options.retrieve_data == SQL_RD_OFF) /* data isn't required */
#ifdef DRIVER_CURSOR_IMPLEMENT
return updret ? updret + 10 : SQL_SUCCESS;
#else
- return SQL_SUCCESS;
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+ return SQL_SUCCESS;
+#endif /* DRIVER_CURSOR_IMPLEMENT */
for (lf = 0; lf < num_cols; lf++)
{
mylog("fetch: cols=%d, lf=%d, self = %u, self->bindings = %u, buffer[] = %u\n", num_cols, lf, self, self->bindings, self->bindings[lf].buffer);
/* this column has a binding */
/* type = QR_get_field_type(res, lf); */
- type = CI_get_oid(coli, lf); /* speed things up */
+ type = CI_get_oid(coli, lf); /* speed things up */
mylog("type = %d\n", type);
case COPY_RESULT_TRUNCATED:
self->errornumber = STMT_TRUNCATED;
self->errormsg = "Fetched item was truncated.";
- qlog("The %dth item was truncated\n", lf + 1);
+ qlog("The %dth item was truncated\n", lf + 1);
qlog("The buffer size = %d", self->bindings[lf].buflen);
qlog(" and the value is '%s'\n", value);
result = SQL_SUCCESS_WITH_INFO;
#ifdef DRIVER_CURSOR_IMPLEMENT
if (updret)
result = updret + 10;
-#endif /* DRIVER_CURSOR_IMPLEMENT */
+#endif /* DRIVER_CURSOR_IMPLEMENT */
return result;
}
RETCODE
-SC_execute(StatementClass *self)
+SC_execute(StatementClass * self)
{
static char *func = "SC_execute";
ConnectionClass *conn;
Int2 oldstatus,
numcols;
QueryInfo qi;
- ConnInfo *ci;
+ ConnInfo *ci;
conn = SC_get_conn(self);
* OTHER.
*/
if (!self->internal && !CC_is_in_trans(conn) &&
- (SC_is_fetchcursor(self) ||
- (!CC_is_in_autocommit(conn) && self->statement_type != STMT_TYPE_OTHER)))
+ (SC_is_fetchcursor(self) ||
+ (!CC_is_in_autocommit(conn) && self->statement_type != STMT_TYPE_OTHER)))
{
mylog(" about to begin a transaction on statement = %u\n", self);
res = CC_send_query(conn, "BEGIN", NULL);
}
if (self->statement_type == STMT_TYPE_PROCCALL &&
- (self->errornumber == STMT_OK ||
- self->errornumber == STMT_INFO_ONLY) &&
- self->parameters &&
- self->parameters[0].buffer &&
- self->parameters[0].paramType == SQL_PARAM_OUTPUT)
- { /* get the return value of the procedure call */
- RETCODE ret;
- HSTMT hstmt = (HSTMT) self;
+ (self->errornumber == STMT_OK ||
+ self->errornumber == STMT_INFO_ONLY) &&
+ self->parameters &&
+ self->parameters[0].buffer &&
+ self->parameters[0].paramType == SQL_PARAM_OUTPUT)
+ { /* get the return value of the procedure
+ * call */
+ RETCODE ret;
+ HSTMT hstmt = (HSTMT) self;
+
ret = SC_fetch(hstmt);
if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)
- {
+ {
ret = PGAPI_GetData(hstmt, 1, self->parameters[0].CType, self->parameters[0].buffer, self->parameters[0].buflen, self->parameters[0].used);
- if (ret != SQL_SUCCESS)
+ if (ret != SQL_SUCCESS)
{
self->errornumber = STMT_EXEC_ERROR;
self->errormsg = "GetData to Procedure return failed.";
void
-SC_log_error(char *func, char *desc, StatementClass *self)
+SC_log_error(char *func, char *desc, StatementClass * self)
{
#ifdef PRN_NULLCHECK
#define nullcheck(a) (a ? a : "(NULL)")
typedef enum
{
- STMT_ALLOCATED, /* The statement handle is allocated, but
+ STMT_ALLOCATED, /* The statement handle is allocated, but
* not used so far */
- STMT_READY, /* the statement is waiting to be executed */
- STMT_PREMATURE, /* ODBC states that it is legal to call
+ STMT_READY, /* the statement is waiting to be executed */
+ STMT_PREMATURE, /* ODBC states that it is legal to call
* e.g. SQLDescribeCol before a call to
* SQLExecute, but after SQLPrepare. To
* get all the necessary information in
* query _before_ the actual call to
* SQLExecute, so that statement is
* considered to be "premature". */
- STMT_FINISHED, /* statement execution has finished */
- STMT_EXECUTING /* statement execution is still going on */
-} STMT_Status;
+ STMT_FINISHED, /* statement execution has finished */
+ STMT_EXECUTING /* statement execution is still going on */
+} STMT_Status;
#define STMT_ROW_VERSION_CHANGED (-4)
#define STMT_POS_BEFORE_RECORDSET (-3)
/* statement types */
enum
{
- STMT_TYPE_UNKNOWN = -2,
- STMT_TYPE_OTHER = -1,
- STMT_TYPE_SELECT = 0,
- STMT_TYPE_INSERT,
- STMT_TYPE_UPDATE,
- STMT_TYPE_DELETE,
- STMT_TYPE_CREATE,
- STMT_TYPE_ALTER,
- STMT_TYPE_DROP,
- STMT_TYPE_GRANT,
- STMT_TYPE_REVOKE,
- STMT_TYPE_PROCCALL
+ STMT_TYPE_UNKNOWN = -2,
+ STMT_TYPE_OTHER = -1,
+ STMT_TYPE_SELECT = 0,
+ STMT_TYPE_INSERT,
+ STMT_TYPE_UPDATE,
+ STMT_TYPE_DELETE,
+ STMT_TYPE_CREATE,
+ STMT_TYPE_ALTER,
+ STMT_TYPE_DROP,
+ STMT_TYPE_GRANT,
+ STMT_TYPE_REVOKE,
+ STMT_TYPE_PROCCALL
};
#define STMT_UPDATE(stmt) (stmt->statement_type > STMT_TYPE_SELECT)
/* Parsing status */
enum
{
- STMT_PARSE_NONE = 0,
- STMT_PARSE_COMPLETE,
- STMT_PARSE_INCOMPLETE,
- STMT_PARSE_FATAL,
+ STMT_PARSE_NONE = 0,
+ STMT_PARSE_COMPLETE,
+ STMT_PARSE_INCOMPLETE,
+ STMT_PARSE_FATAL,
};
/* Result style */
enum
{
- STMT_FETCH_NONE = 0,
- STMT_FETCH_NORMAL,
- STMT_FETCH_EXTENDED,
+ STMT_FETCH_NONE = 0,
+ STMT_FETCH_NORMAL,
+ STMT_FETCH_EXTENDED,
};
typedef struct
COL_INFO *col_info; /* cached SQLColumns info for this table */
char name[MAX_TABLE_LEN + 1];
char alias[MAX_TABLE_LEN + 1];
-} TABLE_INFO;
+} TABLE_INFO;
typedef struct
{
char dot[MAX_TABLE_LEN + 1];
char name[MAX_COLUMN_LEN + 1];
char alias[MAX_COLUMN_LEN + 1];
-} FIELD_INFO;
+} FIELD_INFO;
/******** Statement Handle ***********/
char cursor_name[MAX_CURSOR_LEN + 1];
- char *stmt_with_params; /* statement after
- * parameter
- * substitution */
- int stmt_size_limit;
+ char *stmt_with_params; /* statement after parameter
+ * substitution */
+ int stmt_size_limit;
char pre_executing; /* This statement is prematurely executing */
- char inaccurate_result; /* Current status is PREMATURE but
+ char inaccurate_result; /* Current status is PREMATURE but
* result is inaccurate */
- char errormsg_malloced; /* Current error message is malloed (not in a static variable) ? */
+ char errormsg_malloced; /* Current error message is
+ * malloed (not in a static
+ * variable) ? */
char miscinfo;
};
/* misc info */
#define SC_set_pre_executable(a) (a->miscinfo |= 1L)
-#define SC_no_pre_executable(a) (a->miscinfo &= ~1L)
-#define SC_is_pre_executable(a) ((a->miscinfo & 1L) != 0)
+#define SC_no_pre_executable(a) (a->miscinfo &= ~1L)
+#define SC_is_pre_executable(a) ((a->miscinfo & 1L) != 0)
#define SC_set_fetchcursor(a) (a->miscinfo |= 2L)
#define SC_no_fetchcursor(a) (a->miscinfo &= ~2L)
#define SC_is_fetchcursor(a) ((a->miscinfo & 2L) != 0)
/* Statement prototypes */
StatementClass *SC_Constructor(void);
-void InitializeStatementOptions(StatementOptions *opt);
-char SC_Destructor(StatementClass *self);
+void InitializeStatementOptions(StatementOptions * opt);
+char SC_Destructor(StatementClass * self);
int statement_type(char *statement);
-char parse_statement(StatementClass *stmt);
-void SC_pre_execute(StatementClass *self);
-char SC_unbind_cols(StatementClass *self);
-char SC_recycle_statement(StatementClass *self);
-
-void SC_clear_error(StatementClass *self);
-char SC_get_error(StatementClass *self, int *number, char **message);
-char *SC_create_errormsg(StatementClass *self);
-RETCODE SC_execute(StatementClass *self);
-RETCODE SC_fetch(StatementClass *self);
-void SC_free_params(StatementClass *self, char option);
-void SC_log_error(char *func, char *desc, StatementClass *self);
-unsigned long SC_get_bookmark(StatementClass *self);
-
+char parse_statement(StatementClass * stmt);
+void SC_pre_execute(StatementClass * self);
+char SC_unbind_cols(StatementClass * self);
+char SC_recycle_statement(StatementClass * self);
+
+void SC_clear_error(StatementClass * self);
+char SC_get_error(StatementClass * self, int *number, char **message);
+char *SC_create_errormsg(StatementClass * self);
+RETCODE SC_execute(StatementClass * self);
+RETCODE SC_fetch(StatementClass * self);
+void SC_free_params(StatementClass * self, char option);
+void SC_log_error(char *func, char *desc, StatementClass * self);
+unsigned long SC_get_bookmark(StatementClass * self);
#endif
void
-set_tuplefield_null(TupleField *tuple_field)
+set_tuplefield_null(TupleField * tuple_field)
{
tuple_field->len = 0;
tuple_field->value = NULL; /* strdup(""); */
void
-set_tuplefield_string(TupleField *tuple_field, char *string)
+set_tuplefield_string(TupleField * tuple_field, char *string)
{
tuple_field->len = strlen(string);
tuple_field->value = malloc(strlen(string) + 1);
void
-set_tuplefield_int2(TupleField *tuple_field, Int2 value)
+set_tuplefield_int2(TupleField * tuple_field, Int2 value)
{
char buffer[10];
void
-set_tuplefield_int4(TupleField *tuple_field, Int4 value)
+set_tuplefield_int4(TupleField * tuple_field, Int4 value)
{
char buffer[15];
#define set_nullfield_int2(FLD, VAL) ((VAL) != -1 ? set_tuplefield_int2(FLD, (VAL)) : set_tuplefield_null(FLD))
#define set_nullfield_int4(FLD, VAL) ((VAL) != -1 ? set_tuplefield_int4(FLD, (VAL)) : set_tuplefield_null(FLD))
-void set_tuplefield_null(TupleField *tuple_field);
-void set_tuplefield_string(TupleField *tuple_field, char *string);
-void set_tuplefield_int2(TupleField *tuple_field, Int2 value);
-void set_tuplefield_int4(TupleField *tuple_field, Int4 value);
-
+void set_tuplefield_null(TupleField * tuple_field);
+void set_tuplefield_string(TupleField * tuple_field, char *string);
+void set_tuplefield_int2(TupleField * tuple_field, Int2 value);
+void set_tuplefield_int4(TupleField * tuple_field, Int4 value);
#endif
void
-TL_Destructor(TupleListClass *self)
+TL_Destructor(TupleListClass * self)
{
int lf;
TupleNode *node,
void *
-TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno)
+TL_get_fieldval(TupleListClass * self, Int4 tupleno, Int2 fieldno)
{
Int4 lf;
Int4 delta,
}
else if (start_is_closer)
{
-
/*
* the shortest way is to start the search from the head of the
* list
char
-TL_add_tuple(TupleListClass *self, TupleNode *new_field)
+TL_add_tuple(TupleListClass * self, TupleNode * new_field)
{
-
/*
* we append the tuple at the end of the doubly linked list of the
* tuples we have already read in
}
else
{
-
/*
* there is already an element in the list, so add the new one at
* the end of the list
/* Create a TupleList. Each tuple consits of fieldcnt columns */
TupleListClass *TL_Constructor(UInt4 fieldcnt);
-void TL_Destructor(TupleListClass *self);
-void *TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno);
-char TL_add_tuple(TupleListClass *self, TupleNode *new_field);
-
+void TL_Destructor(TupleListClass * self);
+void *TL_get_fieldval(TupleListClass * self, Int4 tupleno, Int2 fieldno);
+char TL_add_tuple(TupleListClass * self, TupleNode * new_field);
#endif
static
#else
extern void newCONSTSUB _((HV * stash, char *name, SV * sv));
-
#endif
#if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
PL_curstash = old_curstash;
PL_curcop->cop_line = oldline;
}
-
#endif
-
#endif /* newCONSTSUB */
-
#endif /* _P_P_PORTABILITY_H_ */
static PyObject *pg_default_host; /* default database host */
static PyObject *pg_default_base; /* default database name */
-static PyObject *pg_default_opt;/* default connection options */
-static PyObject *pg_default_tty;/* default debug tty */
+static PyObject *pg_default_opt; /* default connection options */
+static PyObject *pg_default_tty; /* default debug tty */
static PyObject *pg_default_port; /* default connection port */
static PyObject *pg_default_user; /* default username */
static PyObject *pg_default_passwd; /* default password */
-
#endif /* DEFAULT_VARS */
DL_EXPORT(void) init_pg(void);
-int *get_type_array(PGresult *result, int nfields);
+int *get_type_array(PGresult *result, int nfields);
/* --------------------------------------------------------------------- */
/* OBJECTS DECLARATION */
typedef struct
{
- PyObject_HEAD
+ PyObject_HEAD
int valid; /* validity flag */
PGconn *cnx; /* PostGres connection handle */
PGresult *last_result; /* last result content */
typedef struct
{
- PyObject_HEAD
+ PyObject_HEAD
PGresult *last_result; /* last result content */
int result_type; /* type of previous result */
long current_pos; /* current position in last result */
typedef struct
{
- PyObject_HEAD
+ PyObject_HEAD
int valid; /* validity flag */
pgobject *pgcnx; /* parent connection object */
PGresult *last_result; /* last result content */
typedef struct
{
- PyObject_HEAD
- pgobject * pgcnx; /* parent connection object */
+ PyObject_HEAD
+ pgobject * pgcnx; /* parent connection object */
Oid lo_oid; /* large object oid */
int lo_fd; /* large object fd */
} pglargeobject;
return 1;
}
-
#endif /* LARGE_OBJECTS */
/* checks source object validity */
0, /* tp_as_mapping */
0, /* tp_hash */
};
-
#endif /* LARGE_OBJECTS */
break;
case 3:
- {
- int mult = 1;
-
- if (*s == '$') /* there's talk of getting rid of
- * it */
- s++;
-
- if (*s == '-' || *s == '(')
{
- s++;
- mult = -1;
+ int mult = 1;
+
+ if (*s == '$') /* there's talk of getting
+ * rid of it */
+ s++;
+
+ if (*s == '-' || *s == '(')
+ {
+ s++;
+ mult = -1;
+ }
+
+ /* get rid of the '$' and commas */
+ if (*s == '$') /* Just in case we exposed
+ * one */
+ s++;
+
+ for (k = 0; *s; s++)
+ if (*s != ',')
+ cashbuf[k++] = *s;
+
+ cashbuf[k] = 0;
+ val = PyFloat_FromDouble(strtod(cashbuf, NULL) * mult);
+ break;
}
- /* get rid of the '$' and commas */
- if (*s == '$') /* Just in case we exposed one */
- s++;
-
- for (k = 0; *s; s++)
- if (*s != ',')
- cashbuf[k++] = *s;
-
- cashbuf[k] = 0;
- val = PyFloat_FromDouble(strtod(cashbuf, NULL) * mult);
- break;
- }
-
default:
val = PyString_FromString(s);
break;
break;
case 3:
- {
- int mult = 1;
-
- if (*s == '$') /* there's talk of getting rid of
- * it */
- s++;
-
- if (*s == '-' || *s == '(')
{
- s++;
- mult = -1;
+ int mult = 1;
+
+ if (*s == '$') /* there's talk of getting
+ * rid of it */
+ s++;
+
+ if (*s == '-' || *s == '(')
+ {
+ s++;
+ mult = -1;
+ }
+
+ /* get rid of the '$' and commas */
+ if (*s == '$') /* Just in case we exposed
+ * one */
+ s++;
+
+ for (k = 0; *s; s++)
+ if (*s != ',')
+ cashbuf[k++] = *s;
+
+ cashbuf[k] = 0;
+ val = PyFloat_FromDouble(strtod(cashbuf, NULL) * mult);
+ break;
}
- /* get rid of the '$' and commas */
- if (*s == '$') /* Just in case we exposed one */
- s++;
-
- for (k = 0; *s; s++)
- if (*s != ',')
- cashbuf[k++] = *s;
-
- cashbuf[k] = 0;
- val = PyFloat_FromDouble(strtod(cashbuf, NULL) * mult);
- break;
- }
-
default:
val = PyString_FromString(s);
break;
Py_INCREF(Py_None);
return Py_None;
}
-
#endif /* DIRECT_ACCESS */
static PyObject *
pg_getattr(pgobject * self, char *name)
{
-
/*
* Although we could check individually, there are only a few
* attributes that don't require a live connection and unless someone
return old;
}
-
#endif /* DEFAULT_VARS */
/* List of functions defined in the module */
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.24 2001/10/19 22:43:49 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.25 2001/10/25 05:50:17 momjian Exp $
*
**********************************************************************/
PUSHMARK(SP);
XPUSHs(sv_2mortal(newSVpv(s, 0)));
PUTBACK;
- count = perl_call_pv( (trusted?"mksafefunc":"mkunsafefunc"),
- G_SCALAR | G_EVAL | G_KEEPERR);
+ count = perl_call_pv((trusted ? "mksafefunc" : "mkunsafefunc"),
+ G_SCALAR | G_EVAL | G_KEEPERR);
SPAGAIN;
if (SvTRUE(ERRSV))
{
char *file = __FILE__;
- newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
+ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
newXS("SPI::bootstrap", boot_SPI, file);
}
if (!is_trigger)
{
typeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(procStruct->prorettype),
+ ObjectIdGetDatum(procStruct->prorettype),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
{
for (i = 0; i < prodesc->nargs; i++)
{
typeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(procStruct->proargtypes[i]),
+ ObjectIdGetDatum(procStruct->proargtypes[i]),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
{
************************************************************/
outputstr = DatumGetCString(OidFunctionCall3(typoutput,
attr,
- ObjectIdGetDatum(typelem),
- Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
+ ObjectIdGetDatum(typelem),
+ Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
sv_catpvf(output, "'%s' => '%s',", attname, outputstr);
pfree(outputstr);
}
static
#else
extern void newCONSTSUB _((HV * stash, char *name, SV * sv));
-
#endif
#if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
PL_curstash = old_curstash;
PL_curcop->cop_line = oldline;
}
-
#endif
-
#endif /* newCONSTSUB */
-
#endif /* _P_P_PORTABILITY_H_ */
* procedural language
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.36 2001/10/09 15:59:56 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.37 2001/10/25 05:50:20 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
if (typeStruct->typrelid != InvalidOid)
{
-
/*
* For tuple type parameters, we set up a record of
* that type
}
else
{
-
/*
* Normal parameters get a var node
*/
case PLPGSQL_NSTYPE_REC:
{
-
/*
* First word is a record name, so second word must be a
* field in this record.
case PLPGSQL_NSTYPE_ROW:
{
-
/*
* First word is a row name, so second word must be a
* field in this row.
{
case PLPGSQL_NSTYPE_REC:
{
-
/*
* This word is a record name, so third word must be a
* field in this record.
case PLPGSQL_NSTYPE_ROW:
{
-
/*
* This word is a row name, so third word must be a field
* in this row.
for (i = 0; i < row->nfields; i++)
{
-
/*
* Get the attribute and it's type
*/
* Create the internal variable
*
* We know if the table definitions contain a default value or if the
- * field is declared in the table as NOT NULL. But it's possible to
- * create a table field as NOT NULL without a default value and that
- * would lead to problems later when initializing the variables due to
- * entering a block at execution time. Thus we ignore this information
- * for now.
+ * field is declared in the table as NOT NULL. But it's possible
+ * to create a table field as NOT NULL without a default value and
+ * that would lead to problems later when initializing the
+ * variables due to entering a block at execution time. Thus we
+ * ignore this information for now.
*/
var = malloc(sizeof(PLpgSQL_var));
memset(var, 0, sizeof(PLpgSQL_var));
PLpgSQL_type *
plpgsql_parse_datatype(char *string)
{
- Oid type_id;
- int32 typmod;
+ Oid type_id;
+ int32 typmod;
HeapTuple typeTup;
Form_pg_type typeStruct;
PLpgSQL_type *typ;
* procedural language
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.47 2001/08/02 21:31:23 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.48 2001/10/25 05:50:20 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
static int exec_stmt_select(PLpgSQL_execstate * estate,
PLpgSQL_stmt_select * stmt);
static int exec_stmt_open(PLpgSQL_execstate * estate,
- PLpgSQL_stmt_open * stmt);
+ PLpgSQL_stmt_open * stmt);
static int exec_stmt_fetch(PLpgSQL_execstate * estate,
- PLpgSQL_stmt_fetch * stmt);
+ PLpgSQL_stmt_fetch * stmt);
static int exec_stmt_close(PLpgSQL_execstate * estate,
- PLpgSQL_stmt_close * stmt);
+ PLpgSQL_stmt_close * stmt);
static int exec_stmt_exit(PLpgSQL_execstate * estate,
PLpgSQL_stmt_exit * stmt);
static int exec_stmt_return(PLpgSQL_execstate * estate,
PLpgSQL_stmt_dynfors * stmt);
static void plpgsql_estate_setup(PLpgSQL_execstate * estate,
- PLpgSQL_function * func);
+ PLpgSQL_function * func);
static void exec_eval_cleanup(PLpgSQL_execstate * estate);
static void exec_prepare_plan(PLpgSQL_execstate * estate,
if (var->freeval)
{
- pfree((void *)(var->value));
+ pfree((void *) (var->value));
var->freeval = false;
}
static int
exec_stmt_assign(PLpgSQL_execstate * estate, PLpgSQL_stmt_assign * stmt)
{
- PLpgSQL_expr *expr = stmt->expr;
+ PLpgSQL_expr *expr = stmt->expr;
if (stmt->varno >= 0)
exec_assign_expr(estate, estate->datums[stmt->varno], expr);
else
{
/*
- * PERFORM: evaluate query and discard result. This cannot share
- * code with the assignment case since we do not wish to constraint
- * the discarded result to be only one row/column.
+ * PERFORM: evaluate query and discard result. This cannot share
+ * code with the assignment case since we do not wish to
+ * constraint the discarded result to be only one row/column.
*/
int rc;
exec_set_found(estate, false);
for (;;)
{
-
/*
* Check bounds
*/
}
/*
- * Open the implicit cursor for the statement and fetch
- * the initial 10 rows.
+ * Open the implicit cursor for the statement and fetch the initial 10
+ * rows.
*/
exec_run_select(estate, stmt->query, 0, &portal);
estate->rettupdesc = SPI_copytupledesc(estate->eval_tuptable->tupdesc);
estate->retisnull = false;
}
+
/*
* Okay to clean up here, since we already copied result tuple
* to upper executor.
for (cp = stmt->message; *cp; cp++)
{
-
/*
* Occurences of a single % are replaced by the next arguments
* external representation. Double %'s are left as is so elog()
Oid *argtypes;
/*
- * We need a temporary argtypes array to load with data.
- * (The finished plan structure will contain a copy of it.)
+ * We need a temporary argtypes array to load with data. (The finished
+ * plan structure will contain a copy of it.)
*
* +1 is just to avoid palloc(0) error.
*/
expr->query);
}
- /* Release any result tuples from SPI_execp (probably shouldn't be any) */
+ /*
+ * Release any result tuples from SPI_execp (probably shouldn't be
+ * any)
+ */
SPI_freetuptable(SPI_tuptable);
/* Save result info for GET DIAGNOSTICS */
HeapTuple typetup;
Form_pg_type typeStruct;
FmgrInfo finfo_output;
- void *plan;
+ void *plan;
Portal portal;
/*
portal = SPI_cursor_open(NULL, plan, NULL, NULL);
if (portal == NULL)
elog(ERROR, "failed to open implicit cursor for dynamic query \"%s\"",
- querystr);
+ querystr);
pfree(querystr);
SPI_freeplan(plan);
exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt)
{
PLpgSQL_var *curvar = NULL;
- char *curname = NULL;
+ char *curname = NULL;
PLpgSQL_expr *query = NULL;
Portal portal;
* done downstairs.
* ----------
*/
- query = stmt->query;
+ query = stmt->query;
if (query->plan == NULL)
exec_prepare_plan(estate, query);
}
HeapTuple typetup;
Form_pg_type typeStruct;
FmgrInfo finfo_output;
- void *curplan = NULL;
+ void *curplan = NULL;
/* ----------
* We evaluate the string expression after the
fmgr_info(typeStruct->typoutput, &finfo_output);
querystr = DatumGetCString(FunctionCall3(&finfo_output,
queryD,
- ObjectIdGetDatum(typeStruct->typelem),
+ ObjectIdGetDatum(typeStruct->typelem),
Int32GetDatum(-1)));
ReleaseSysCache(typetup);
* ----------
*/
if (curvar->freeval)
- pfree((void *)(curvar->value));
+ pfree((void *) (curvar->value));
curvar->value = DirectFunctionCall1(textin, CStringGetDatum(portal->name));
curvar->isnull = false;
* internal row.
* ----------
*/
- PLpgSQL_stmt_select set_args;
+ PLpgSQL_stmt_select set_args;
memset(&set_args, 0, sizeof(set_args));
- set_args.cmd_type = PLPGSQL_STMT_SELECT;
- set_args.lineno = stmt->lineno;
- set_args.row = (PLpgSQL_row *)
- (estate->datums[curvar->cursor_explicit_argrow]);
- set_args.query = stmt->argquery;
+ set_args.cmd_type = PLPGSQL_STMT_SELECT;
+ set_args.lineno = stmt->lineno;
+ set_args.row = (PLpgSQL_row *)
+ (estate->datums[curvar->cursor_explicit_argrow]);
+ set_args.query = stmt->argquery;
if (exec_stmt_select(estate, &set_args) != PLPGSQL_RC_OK)
elog(ERROR, "open cursor failed during argument processing");
}
- query = curvar->cursor_explicit_expr;
+ query = curvar->cursor_explicit_expr;
if (query->plan == NULL)
exec_prepare_plan(estate, query);
}
* ----------
*/
if (curvar->freeval)
- pfree((void *)(curvar->value));
+ pfree((void *) (curvar->value));
curvar->value = DirectFunctionCall1(textin, CStringGetDatum(portal->name));
curvar->isnull = false;
PLpgSQL_row *row = NULL;
SPITupleTable *tuptab;
Portal portal;
- char *curname;
+ char *curname;
int n;
/* ----------
{
PLpgSQL_var *curvar = NULL;
Portal portal;
- char *curname;
+ char *curname;
/* ----------
* Get the portal of the cursor by name
if (var->freeval)
{
- pfree((void *)(var->value));
+ pfree((void *) (var->value));
var->freeval = false;
}
elog(ERROR, "NULL assignment to variable '%s' declared NOT NULL", var->refname);
/*
- * If type is by-reference, make sure we have a freshly palloc'd
- * copy; the originally passed value may not live as long as the
- * variable! But we don't need to re-copy if exec_cast_value
- * performed a conversion; its output must already be palloc'd.
+ * If type is by-reference, make sure we have a freshly
+ * palloc'd copy; the originally passed value may not live as
+ * long as the variable! But we don't need to re-copy if
+ * exec_cast_value performed a conversion; its output must
+ * already be palloc'd.
*/
if (!var->datatype->typbyval && !*isNull)
{
if (newvalue == value)
{
- int len;
+ int len;
if (var->datatype->typlen < 0)
len = VARSIZE(newvalue);
else
len = var->datatype->typlen;
var->value = (Datum) palloc(len);
- memcpy((void *)(var->value), (void *)newvalue, len);
+ memcpy((void *) (var->value), (void *) newvalue, len);
}
else
var->value = newvalue;
natts = rec->tupdesc->natts;
/*
- * Set up values/datums arrays for heap_formtuple. For all the
- * attributes except the one we want to replace, use the value
- * that's in the old tuple.
+ * Set up values/datums arrays for heap_formtuple. For all
+ * the attributes except the one we want to replace, use the
+ * value that's in the old tuple.
*/
values = palloc(sizeof(Datum) * natts);
nulls = palloc(natts);
nulls[fno] = ' ';
/*
- * Avoid leaking the result of exec_cast_value, if it performed
- * a conversion to a pass-by-ref type.
+ * Avoid leaking the result of exec_cast_value, if it
+ * performed a conversion to a pass-by-ref type.
*/
if (!typeStruct->typbyval && !attisnull && values[fno] != value)
mustfree = DatumGetPointer(values[fno]);
elog(ERROR, "query \"%s\" returned more than one row", expr->query);
if (estate->eval_tuptable->tupdesc->natts != 1)
elog(ERROR, "query \"%s\" returned %d columns", expr->query,
- estate->eval_tuptable->tupdesc->natts);
+ estate->eval_tuptable->tupdesc->natts);
/*
* Return the result and its type
*portalP = SPI_cursor_open(NULL, expr->plan, values, nulls);
if (*portalP == NULL)
elog(ERROR, "failed to open implicit cursor for \"%s\"",
- expr->query);
+ expr->query);
pfree(values);
pfree(nulls);
return SPI_OK_CURSOR;
*
* NOTE: we pass the SPI plan's context as the query-lifetime context for
* function cache nodes and suchlike allocations. This is appropriate
- * because that's where the expression tree itself is, and the function
- * cache nodes must live as long as it does.
+ * because that's where the expression tree itself is, and the
+ * function cache nodes must live as long as it does.
*/
econtext = MakeExprContext(NULL, spi_plan->plancxt);
/*
* Param list can live in econtext's temporary memory context.
*/
- paramLI = (ParamListInfo)
+ paramLI = (ParamListInfo)
MemoryContextAlloc(econtext->ecxt_per_tuple_memory,
- (expr->nparams + 1) * sizeof(ParamListInfoData));
+ (expr->nparams + 1) * sizeof(ParamListInfoData));
econtext->ecxt_param_list_info = paramLI;
/*
SPI_pop();
/*
- * Note: if pass-by-reference, the result is in the econtext's temporary
- * memory context. It will be freed when exec_eval_cleanup is done.
+ * Note: if pass-by-reference, the result is in the econtext's
+ * temporary memory context. It will be freed when exec_eval_cleanup
+ * is done.
*/
Assert(estate->eval_econtext == NULL);
estate->eval_econtext = econtext;
* attributes of the tuple to the variables the row points to.
*
* NOTE: this code used to demand row->nfields == tup->t_data->t_natts,
- * but that's wrong. The tuple might have more fields than we expected
- * if it's from an inheritance-child table of the current table, or it
- * might have fewer if the table has had columns added by ALTER TABLE.
- * Ignore extra columns and assume NULL for missing columns, the same
- * as heap_getattr would do.
+ * but that's wrong. The tuple might have more fields than we
+ * expected if it's from an inheritance-child table of the current
+ * table, or it might have fewer if the table has had columns added by
+ * ALTER TABLE. Ignore extra columns and assume NULL for missing
+ * columns, the same as heap_getattr would do.
*/
if (row != NULL)
{
{
switch (nodeTag(node))
{
- case T_Expr:
+ case T_Expr:
{
Expr *expr = (Expr *) node;
List *l;
* procedural language
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.9 2001/10/09 15:59:56 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.10 2001/10/25 05:50:20 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
static PLpgSQL_function *compiled_functions = NULL;
-static bool func_up_to_date(PLpgSQL_function *func);
+static bool func_up_to_date(PLpgSQL_function * func);
/* ----------
if (func != NULL)
{
Assert(func->fn_oid == funcOid);
+
/*
* But is the function still up to date?
*/
- if (! func_up_to_date(func))
+ if (!func_up_to_date(func))
func = NULL;
}
* function's pg_proc entry without changing its OID.
*/
static bool
-func_up_to_date(PLpgSQL_function *func)
+func_up_to_date(PLpgSQL_function * func)
{
HeapTuple procTup;
bool result;
* procedural language
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.19 2001/10/09 15:59:56 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.20 2001/10/25 05:50:20 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
*/
enum
{
- PLPGSQL_NSTYPE_LABEL,
- PLPGSQL_NSTYPE_VAR,
- PLPGSQL_NSTYPE_ROW,
- PLPGSQL_NSTYPE_REC,
- PLPGSQL_NSTYPE_RECFIELD
+ PLPGSQL_NSTYPE_LABEL,
+ PLPGSQL_NSTYPE_VAR,
+ PLPGSQL_NSTYPE_ROW,
+ PLPGSQL_NSTYPE_REC,
+ PLPGSQL_NSTYPE_RECFIELD
};
/* ----------
*/
enum
{
- PLPGSQL_DTYPE_VAR,
- PLPGSQL_DTYPE_ROW,
- PLPGSQL_DTYPE_REC,
- PLPGSQL_DTYPE_RECFIELD,
- PLPGSQL_DTYPE_EXPR,
- PLPGSQL_DTYPE_TRIGARG
+ PLPGSQL_DTYPE_VAR,
+ PLPGSQL_DTYPE_ROW,
+ PLPGSQL_DTYPE_REC,
+ PLPGSQL_DTYPE_RECFIELD,
+ PLPGSQL_DTYPE_EXPR,
+ PLPGSQL_DTYPE_TRIGARG
};
/* ----------
*/
enum
{
- PLPGSQL_STMT_BLOCK,
- PLPGSQL_STMT_ASSIGN,
- PLPGSQL_STMT_IF,
- PLPGSQL_STMT_LOOP,
- PLPGSQL_STMT_WHILE,
- PLPGSQL_STMT_FORI,
- PLPGSQL_STMT_FORS,
- PLPGSQL_STMT_SELECT,
- PLPGSQL_STMT_EXIT,
- PLPGSQL_STMT_RETURN,
- PLPGSQL_STMT_RAISE,
- PLPGSQL_STMT_EXECSQL,
- PLPGSQL_STMT_DYNEXECUTE,
- PLPGSQL_STMT_DYNFORS,
- PLPGSQL_STMT_GETDIAG,
- PLPGSQL_STMT_OPEN,
- PLPGSQL_STMT_FETCH,
- PLPGSQL_STMT_CLOSE
+ PLPGSQL_STMT_BLOCK,
+ PLPGSQL_STMT_ASSIGN,
+ PLPGSQL_STMT_IF,
+ PLPGSQL_STMT_LOOP,
+ PLPGSQL_STMT_WHILE,
+ PLPGSQL_STMT_FORI,
+ PLPGSQL_STMT_FORS,
+ PLPGSQL_STMT_SELECT,
+ PLPGSQL_STMT_EXIT,
+ PLPGSQL_STMT_RETURN,
+ PLPGSQL_STMT_RAISE,
+ PLPGSQL_STMT_EXECSQL,
+ PLPGSQL_STMT_DYNEXECUTE,
+ PLPGSQL_STMT_DYNFORS,
+ PLPGSQL_STMT_GETDIAG,
+ PLPGSQL_STMT_OPEN,
+ PLPGSQL_STMT_FETCH,
+ PLPGSQL_STMT_CLOSE
};
*/
enum
{
- PLPGSQL_RC_OK,
- PLPGSQL_RC_EXIT,
- PLPGSQL_RC_RETURN
+ PLPGSQL_RC_OK,
+ PLPGSQL_RC_EXIT,
+ PLPGSQL_RC_RETURN
};
/* ----------
*/
enum
{
- PLPGSQL_GETDIAG_ROW_COUNT,
- PLPGSQL_GETDIAG_RESULT_OID
+ PLPGSQL_GETDIAG_ROW_COUNT,
+ PLPGSQL_GETDIAG_RESULT_OID
};
int cmd_type;
int lineno;
int curvar;
- PLpgSQL_row *returntype;
+ PLpgSQL_row *returntype;
PLpgSQL_expr *argquery;
PLpgSQL_expr *query;
PLpgSQL_expr *dynquery;
PLpgSQL_datum **datums;
PLpgSQL_stmt_block *action;
- struct PLpgSQL_function *next; /* for chaining list of functions */
+ struct PLpgSQL_function *next; /* for chaining list of functions */
} PLpgSQL_function;
/* linkage to the real yytext and yylineno variables */
extern char *plpgsql_base_yytext;
+
#define plpgsql_yytext plpgsql_base_yytext
extern int plpgsql_base_yylineno;
+
#define plpgsql_yylineno plpgsql_base_yylineno
extern PLpgSQL_function *plpgsql_curr_compile;
extern int plpgsql_yylex(void);
extern void plpgsql_push_back_token(int token);
extern void plpgsql_setinput(char *s, int functype);
-
#endif /* PLPGSQL_H */
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.9 2001/10/22 19:32:27 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.10 2001/10/25 05:50:20 momjian Exp $
*
*********************************************************************
*/
typedef PyObject *(*PLyDatumToObFunc) (const char *);
-typedef struct PLyDatumToOb {
- PLyDatumToObFunc func;
- FmgrInfo typfunc;
- Oid typelem;
- bool typbyval;
-} PLyDatumToOb;
+typedef struct PLyDatumToOb
+{
+ PLyDatumToObFunc func;
+ FmgrInfo typfunc;
+ Oid typelem;
+ bool typbyval;
+} PLyDatumToOb;
-typedef struct PLyTupleToOb {
- PLyDatumToOb *atts;
- int natts;
-} PLyTupleToOb;
+typedef struct PLyTupleToOb
+{
+ PLyDatumToOb *atts;
+ int natts;
+} PLyTupleToOb;
-typedef union PLyTypeInput {
- PLyDatumToOb d;
- PLyTupleToOb r;
-} PLyTypeInput;
+typedef union PLyTypeInput
+{
+ PLyDatumToOb d;
+ PLyTupleToOb r;
+} PLyTypeInput;
/* convert PyObject to a Postgresql Datum or tuple.
* output from Python
*/
-typedef struct PLyObToDatum {
- FmgrInfo typfunc;
- Oid typelem;
- bool typbyval;
-} PLyObToDatum;
-
-typedef struct PLyObToTuple {
- PLyObToDatum *atts;
- int natts;
-} PLyObToTuple;
-
-typedef union PLyTypeOutput {
- PLyObToDatum d;
- PLyObToTuple r;
-} PLyTypeOutput;
+typedef struct PLyObToDatum
+{
+ FmgrInfo typfunc;
+ Oid typelem;
+ bool typbyval;
+} PLyObToDatum;
+
+typedef struct PLyObToTuple
+{
+ PLyObToDatum *atts;
+ int natts;
+} PLyObToTuple;
+
+typedef union PLyTypeOutput
+{
+ PLyObToDatum d;
+ PLyObToTuple r;
+} PLyTypeOutput;
/* all we need to move Postgresql data to Python objects,
* and vis versa
*/
-typedef struct PLyTypeInfo {
- PLyTypeInput in;
- PLyTypeOutput out;
- int is_rel;
-} PLyTypeInfo;
+typedef struct PLyTypeInfo
+{
+ PLyTypeInput in;
+ PLyTypeOutput out;
+ int is_rel;
+} PLyTypeInfo;
/* cached procedure data
*/
-typedef struct PLyProcedure {
- char *proname;
- TransactionId fn_xmin;
- CommandId fn_cmin;
- PLyTypeInfo result; /* also used to store info for trigger tuple type */
- PLyTypeInfo args[FUNC_MAX_ARGS];
- int nargs;
- PyObject *interp; /* restricted interpreter instance */
- PyObject *reval; /* interpreter return */
- PyObject *code; /* compiled procedure code */
- PyObject *statics; /* data saved across calls, local scope */
- PyObject *globals; /* data saved across calls, global score */
- PyObject *me; /* PyCObject containing pointer to this PLyProcedure */
-} PLyProcedure;
-
-
-/* Python objects.
+typedef struct PLyProcedure
+{
+ char *proname;
+ TransactionId fn_xmin;
+ CommandId fn_cmin;
+ PLyTypeInfo result; /* also used to store info for trigger
+ * tuple type */
+ PLyTypeInfo args[FUNC_MAX_ARGS];
+ int nargs;
+ PyObject *interp; /* restricted interpreter instance */
+ PyObject *reval; /* interpreter return */
+ PyObject *code; /* compiled procedure code */
+ PyObject *statics; /* data saved across calls, local scope */
+ PyObject *globals; /* data saved across calls, global score */
+ PyObject *me; /* PyCObject containing pointer to this
+ * PLyProcedure */
+} PLyProcedure;
+
+
+/* Python objects.
*/
-typedef struct PLyPlanObject {
- PyObject_HEAD;
- void *plan; /* return of an SPI_saveplan */
- int nargs;
- Oid *types;
- Datum *values;
- PLyTypeInfo *args;
-} PLyPlanObject;
-
-typedef struct PLyResultObject {
- PyObject_HEAD;
- /* HeapTuple *tuples; */
- PyObject *nrows; /* number of rows returned by query */
- PyObject *rows; /* data rows, or None if no data returned */
- PyObject *status; /* query status, SPI_OK_*, or SPI_ERR_* */
-} PLyResultObject;
+typedef struct PLyPlanObject
+{
+ PyObject_HEAD;
+ void *plan; /* return of an SPI_saveplan */
+ int nargs;
+ Oid *types;
+ Datum *values;
+ PLyTypeInfo *args;
+} PLyPlanObject;
+
+typedef struct PLyResultObject
+{
+ PyObject_HEAD;
+ /* HeapTuple *tuples; */
+ PyObject *nrows; /* number of rows returned by query */
+ PyObject *rows; /* data rows, or None if no data returned */
+ PyObject *status; /* query status, SPI_OK_*, or SPI_ERR_* */
+} PLyResultObject;
/* function declarations
/* the only exported function, with the magic telling Postgresql
* what function call interface it implements.
*/
-Datum plpython_call_handler(PG_FUNCTION_ARGS);
+Datum plpython_call_handler(PG_FUNCTION_ARGS);
+
PG_FUNCTION_INFO_V1(plpython_call_handler);
/* most of the remaining of the declarations, all static
/* error handler. collects the current Python exception, if any,
* and appends it to the error and sends it to elog
*/
-static void PLy_elog(int, const char *, ...);
+static void PLy_elog(int, const char *,...);
/* call PyErr_SetString with a vprint interface
*/
-static void PLy_exception_set(PyObject *, const char *, ...)
- __attribute__ ((format (printf, 2, 3)));
+static void
+PLy_exception_set(PyObject *, const char *,...)
+__attribute__((format(printf, 2, 3)));
/* some utility functions
*/
static PyObject *PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure *);
static PyObject *PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *,
- HeapTuple *);
+ HeapTuple *);
static HeapTuple PLy_modify_tuple(PLyProcedure *, PyObject *,
- TriggerData *, HeapTuple);
+ TriggerData *, HeapTuple);
static PyObject *PLy_procedure_call(PLyProcedure *, char *, PyObject *);
static PLyProcedure *PLy_procedure_get(FunctionCallInfo fcinfo, bool);
static PLyProcedure *PLy_procedure_create(FunctionCallInfo fcinfo,
- bool is_trigger,
- HeapTuple procTup, char *key);
+ bool is_trigger,
+ HeapTuple procTup, char *key);
static void PLy_procedure_compile(PLyProcedure *, const char *);
static char *PLy_procedure_munge_source(const char *, const char *);
/* global data
*/
-static int PLy_first_call = 1;
+static int PLy_first_call = 1;
static volatile int PLy_call_level = 0;
/* this gets modified in plpython_call_handler and PLy_elog.
static PyObject *PLy_importable_modules = NULL;
static PyObject *PLy_procedure_cache = NULL;
-char *PLy_importable_modules_list[] = {
- "array",
- "bisect",
- "calendar",
- "cmath",
- "errno",
- "marshal",
- "math",
- "md5",
- "mpz",
- "operator",
- "pickle",
- "random",
- "re",
- "sha",
- "string",
- "StringIO",
- "time",
- "whrandom",
- "zlib"
+char *PLy_importable_modules_list[] = {
+ "array",
+ "bisect",
+ "calendar",
+ "cmath",
+ "errno",
+ "marshal",
+ "math",
+ "md5",
+ "mpz",
+ "operator",
+ "pickle",
+ "random",
+ "re",
+ "sha",
+ "string",
+ "StringIO",
+ "time",
+ "whrandom",
+ "zlib"
};
/* Python exceptions
*/
-PyObject *PLy_exc_error = NULL;
-PyObject *PLy_exc_fatal = NULL;
-PyObject *PLy_exc_spi_error = NULL;
+PyObject *PLy_exc_error = NULL;
+PyObject *PLy_exc_fatal = NULL;
+PyObject *PLy_exc_spi_error = NULL;
/* some globals for the python module
*/
static char PLy_plan_doc[] = {
- "Store a PostgreSQL plan"
+ "Store a PostgreSQL plan"
};
static char PLy_result_doc[] = {
- "Results of a PostgreSQL query"
+ "Results of a PostgreSQL query"
};
Datum
plpython_call_handler(PG_FUNCTION_ARGS)
{
- DECLARE_EXC();
- Datum retval;
- bool is_trigger;
- PLyProcedure *volatile proc = NULL;
+ DECLARE_EXC();
+ Datum retval;
+ bool is_trigger;
+ PLyProcedure *volatile proc = NULL;
- enter();
+ enter();
- if (PLy_first_call)
- PLy_init_all();
+ if (PLy_first_call)
+ PLy_init_all();
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "plpython: Unable to connect to SPI manager");
+ if (SPI_connect() != SPI_OK_CONNECT)
+ elog(ERROR, "plpython: Unable to connect to SPI manager");
- CALL_LEVEL_INC();
- is_trigger = CALLED_AS_TRIGGER(fcinfo);
+ CALL_LEVEL_INC();
+ is_trigger = CALLED_AS_TRIGGER(fcinfo);
- SAVE_EXC();
- if (TRAP_EXC())
- {
- RESTORE_EXC();
- CALL_LEVEL_DEC();
- if (PLy_call_level == 0)
+ SAVE_EXC();
+ if (TRAP_EXC())
{
- PLy_restart_in_progress = 0;
- PyErr_Clear();
+ RESTORE_EXC();
+ CALL_LEVEL_DEC();
+ if (PLy_call_level == 0)
+ {
+ PLy_restart_in_progress = 0;
+ PyErr_Clear();
+ }
+ else
+ PLy_restart_in_progress += 1;
+ if (proc)
+ Py_DECREF(proc->me);
+ RERAISE_EXC();
}
- else
- PLy_restart_in_progress += 1;
- if (proc)
- { Py_DECREF(proc->me); }
- RERAISE_EXC();
- }
- /*elog(NOTICE, "PLy_restart_in_progress is %d", PLy_restart_in_progress);*/
+ /*
+ * elog(NOTICE, "PLy_restart_in_progress is %d",
+ * PLy_restart_in_progress);
+ */
+
+ proc = PLy_procedure_get(fcinfo, is_trigger);
- proc = PLy_procedure_get(fcinfo, is_trigger);
+ if (is_trigger)
+ {
+ HeapTuple trv = PLy_trigger_handler(fcinfo, proc);
+
+ retval = PointerGetDatum(trv);
+ }
+ else
+ retval = PLy_function_handler(fcinfo, proc);
- if (is_trigger)
- {
- HeapTuple trv = PLy_trigger_handler(fcinfo, proc);
- retval = PointerGetDatum(trv);
- }
- else
- retval = PLy_function_handler(fcinfo, proc);
+ CALL_LEVEL_DEC();
+ RESTORE_EXC();
- CALL_LEVEL_DEC();
- RESTORE_EXC();
-
- Py_DECREF(proc->me);
- refc(proc->me);
+ Py_DECREF(proc->me);
+ refc(proc->me);
- return retval;
+ return retval;
}
/* trigger and function sub handlers
* to take no arguments and return an argument of type opaque.
*/
HeapTuple
-PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure *proc)
+PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
{
- DECLARE_EXC();
- HeapTuple rv = NULL;
- PyObject * volatile plargs = NULL;
- PyObject * volatile plrv = NULL;
+ DECLARE_EXC();
+ HeapTuple rv = NULL;
+ PyObject *volatile plargs = NULL;
+ PyObject *volatile plrv = NULL;
- enter();
+ enter();
- SAVE_EXC();
- if (TRAP_EXC())
- {
- RESTORE_EXC();
+ SAVE_EXC();
+ if (TRAP_EXC())
+ {
+ RESTORE_EXC();
- Py_XDECREF(plargs);
- Py_XDECREF(plrv);
+ Py_XDECREF(plargs);
+ Py_XDECREF(plrv);
- RERAISE_EXC();
- }
+ RERAISE_EXC();
+ }
- plargs = PLy_trigger_build_args(fcinfo, proc, &rv);
- plrv = PLy_procedure_call(proc, "TD", plargs);
+ plargs = PLy_trigger_build_args(fcinfo, proc, &rv);
+ plrv = PLy_procedure_call(proc, "TD", plargs);
- /* Disconnect from SPI manager
- */
- if (SPI_finish() != SPI_OK_FINISH)
- elog(ERROR, "plpython: SPI_finish failed");
+ /*
+ * Disconnect from SPI manager
+ */
+ if (SPI_finish() != SPI_OK_FINISH)
+ elog(ERROR, "plpython: SPI_finish failed");
- if (plrv == NULL)
- elog(FATAL, "Aiieee, PLy_procedure_call returned NULL");
+ if (plrv == NULL)
+ elog(FATAL, "Aiieee, PLy_procedure_call returned NULL");
- if (PLy_restart_in_progress)
- elog(FATAL, "Aiieee, restart in progress not expected");
+ if (PLy_restart_in_progress)
+ elog(FATAL, "Aiieee, restart in progress not expected");
- /* return of None means we're happy with the tuple
- */
- if (plrv != Py_None)
- {
- char *srv;
+ /*
+ * return of None means we're happy with the tuple
+ */
+ if (plrv != Py_None)
+ {
+ char *srv;
- if (!PyString_Check(plrv))
- elog(ERROR, "plpython: Expected trigger to return None or a String");
+ if (!PyString_Check(plrv))
+ elog(ERROR, "plpython: Expected trigger to return None or a String");
- srv = PyString_AsString(plrv);
- if (strcasecmp(srv, "SKIP") == 0)
- rv = NULL;
- else if (strcasecmp(srv, "MODIFY") == 0)
- {
- TriggerData *tdata = (TriggerData *) fcinfo->context;
+ srv = PyString_AsString(plrv);
+ if (strcasecmp(srv, "SKIP") == 0)
+ rv = NULL;
+ else if (strcasecmp(srv, "MODIFY") == 0)
+ {
+ TriggerData *tdata = (TriggerData *) fcinfo->context;
- if ((TRIGGER_FIRED_BY_INSERT(tdata->tg_event)) ||
- (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event)))
- {
- rv = PLy_modify_tuple(proc, plargs, tdata, rv);
- }
- else
- elog(NOTICE,"plpython: Ignoring modified tuple in DELETE trigger");
- }
- else if (strcasecmp(srv, "OK"))
- {
- /* hmmm, perhaps they only read the pltcl page, not a surprising
- * thing since i've written no documentation, so accept a
- * belated OK
- */
- elog(ERROR, "plpython: Expected return to be 'SKIP' or 'MODIFY'");
+ if ((TRIGGER_FIRED_BY_INSERT(tdata->tg_event)) ||
+ (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event)))
+ rv = PLy_modify_tuple(proc, plargs, tdata, rv);
+ else
+ elog(NOTICE, "plpython: Ignoring modified tuple in DELETE trigger");
+ }
+ else if (strcasecmp(srv, "OK"))
+ {
+ /*
+ * hmmm, perhaps they only read the pltcl page, not a
+ * surprising thing since i've written no documentation, so
+ * accept a belated OK
+ */
+ elog(ERROR, "plpython: Expected return to be 'SKIP' or 'MODIFY'");
+ }
}
- }
- Py_DECREF(plargs);
- Py_DECREF(plrv);
+ Py_DECREF(plargs);
+ Py_DECREF(plrv);
- RESTORE_EXC();
+ RESTORE_EXC();
- return rv;
+ return rv;
}
HeapTuple
-PLy_modify_tuple(PLyProcedure *proc, PyObject *pltd, TriggerData *tdata,
- HeapTuple otup)
-{
- DECLARE_EXC();
- PyObject * volatile plntup;
- PyObject * volatile plkeys;
- PyObject * volatile platt;
- PyObject * volatile plval;
- PyObject * volatile plstr;
- HeapTuple rtup;
- int natts, i, j, attn, atti;
- int * volatile modattrs;
- Datum * volatile modvalues;
- char *volatile modnulls;
- TupleDesc tupdesc;
-
- plntup = plkeys = platt = plval = plstr = NULL;
- modattrs = NULL;
- modvalues = NULL;
- modnulls = NULL;
-
- enter();
-
- SAVE_EXC();
- if (TRAP_EXC())
- {
- RESTORE_EXC();
-
- Py_XDECREF(plntup);
- Py_XDECREF(plkeys);
- Py_XDECREF(platt);
- Py_XDECREF(plval);
- Py_XDECREF(plstr);
-
- if (modnulls)
- pfree(modnulls);
- if (modvalues)
- pfree(modvalues);
- if (modattrs)
+PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata,
+ HeapTuple otup)
+{
+ DECLARE_EXC();
+ PyObject *volatile plntup;
+ PyObject *volatile plkeys;
+ PyObject *volatile platt;
+ PyObject *volatile plval;
+ PyObject *volatile plstr;
+ HeapTuple rtup;
+ int natts,
+ i,
+ j,
+ attn,
+ atti;
+ int *volatile modattrs;
+ Datum *volatile modvalues;
+ char *volatile modnulls;
+ TupleDesc tupdesc;
+
+ plntup = plkeys = platt = plval = plstr = NULL;
+ modattrs = NULL;
+ modvalues = NULL;
+ modnulls = NULL;
+
+ enter();
+
+ SAVE_EXC();
+ if (TRAP_EXC())
+ {
+ RESTORE_EXC();
+
+ Py_XDECREF(plntup);
+ Py_XDECREF(plkeys);
+ Py_XDECREF(platt);
+ Py_XDECREF(plval);
+ Py_XDECREF(plstr);
+
+ if (modnulls)
+ pfree(modnulls);
+ if (modvalues)
+ pfree(modvalues);
+ if (modattrs)
+ pfree(modattrs);
+
+ RERAISE_EXC();
+ }
+
+ if ((plntup = PyDict_GetItemString(pltd, "new")) == NULL)
+ elog(ERROR, "plpython: TD[\"new\"] deleted, unable to modify tuple");
+ if (!PyDict_Check(plntup))
+ elog(ERROR, "plpython: TD[\"new\"] is not a dictionary object");
+ Py_INCREF(plntup);
+
+ plkeys = PyDict_Keys(plntup);
+ natts = PyList_Size(plkeys);
+
+ if (natts != proc->result.out.r.natts)
+ elog(ERROR, "plpython: TD[\"new\"] has an incorrect number of keys.");
+
+ modattrs = palloc(natts * sizeof(int));
+ modvalues = palloc(natts * sizeof(Datum));
+ for (i = 0; i < natts; i++)
+ {
+ modattrs[i] = i + 1;
+ modvalues[i] = (Datum) NULL;
+ }
+ modnulls = palloc(natts + 1);
+ memset(modnulls, 'n', natts);
+ modnulls[natts] = '\0';
+
+ tupdesc = tdata->tg_relation->rd_att;
+
+ for (j = 0; j < natts; j++)
+ {
+ char *src;
+
+ platt = PyList_GetItem(plkeys, j);
+ if (!PyString_Check(platt))
+ elog(ERROR, "plpython: attribute is not a string");
+ attn = modattrs[j] = SPI_fnumber(tupdesc, PyString_AsString(platt));
+
+ if (attn == SPI_ERROR_NOATTRIBUTE)
+ elog(ERROR, "plpython: invalid attribute `%s' in tuple.",
+ PyString_AsString(platt));
+ atti = attn - 1;
+
+ plval = PyDict_GetItem(plntup, platt);
+ if (plval == NULL)
+ elog(FATAL, "plpython: interpreter is probably corrupted");
+
+ Py_INCREF(plval);
+
+ if (plval != Py_None)
+ {
+ plstr = PyObject_Str(plval);
+ src = PyString_AsString(plstr);
+
+ modvalues[j] = FunctionCall3(&proc->result.out.r.atts[atti].typfunc,
+ CStringGetDatum(src),
+ ObjectIdGetDatum(proc->result.out.r.atts[atti].typelem),
+ Int32GetDatum(tupdesc->attrs[j]->atttypmod));
+ modnulls[j] = ' ';
+
+ Py_DECREF(plstr);
+ plstr = NULL;
+ }
+ Py_DECREF(plval);
+ plval = NULL;
+
+ }
+ rtup = SPI_modifytuple(tdata->tg_relation, otup, natts, modattrs,
+ modvalues, modnulls);
+
+ /*
+ * FIXME -- these leak if not explicity pfree'd by other elog calls,
+ * no?
+ */
pfree(modattrs);
+ pfree(modvalues);
+ pfree(modnulls);
+
+ if (rtup == NULL)
+ elog(ERROR, "plpython: SPI_modifytuple failed -- error %d", SPI_result);
+
+ Py_DECREF(plntup);
+ Py_DECREF(plkeys);
+
+ RESTORE_EXC();
- RERAISE_EXC();
- }
-
- if ((plntup = PyDict_GetItemString(pltd, "new")) == NULL)
- elog(ERROR, "plpython: TD[\"new\"] deleted, unable to modify tuple");
- if (!PyDict_Check(plntup))
- elog(ERROR, "plpython: TD[\"new\"] is not a dictionary object");
- Py_INCREF(plntup);
-
- plkeys = PyDict_Keys(plntup);
- natts = PyList_Size(plkeys);
-
- if (natts != proc->result.out.r.natts)
- elog(ERROR, "plpython: TD[\"new\"] has an incorrect number of keys.");
-
- modattrs = palloc(natts * sizeof(int));
- modvalues = palloc(natts * sizeof(Datum));
- for (i = 0; i < natts; i++)
- {
- modattrs[i] = i + 1;
- modvalues[i] = (Datum) NULL;
- }
- modnulls = palloc(natts + 1);
- memset(modnulls, 'n', natts);
- modnulls[natts] = '\0';
-
- tupdesc = tdata->tg_relation->rd_att;
-
- for (j = 0; j < natts; j++)
- {
- char *src;
-
- platt = PyList_GetItem(plkeys, j);
- if (!PyString_Check(platt))
- elog(ERROR, "plpython: attribute is not a string");
- attn = modattrs[j] = SPI_fnumber(tupdesc, PyString_AsString(platt));
-
- if (attn == SPI_ERROR_NOATTRIBUTE)
- elog(ERROR, "plpython: invalid attribute `%s' in tuple.",
- PyString_AsString(platt));
- atti = attn - 1;
-
- plval = PyDict_GetItem(plntup, platt);
- if (plval == NULL)
- elog(FATAL, "plpython: interpreter is probably corrupted");
-
- Py_INCREF(plval);
-
- if (plval != Py_None)
- {
- plstr = PyObject_Str(plval);
- src = PyString_AsString(plstr);
-
- modvalues[j] = FunctionCall3(&proc->result.out.r.atts[atti].typfunc,
- CStringGetDatum(src),
- ObjectIdGetDatum(proc->result.out.r.atts[atti].typelem),
- Int32GetDatum(tupdesc->attrs[j]->atttypmod));
- modnulls[j] = ' ';
-
- Py_DECREF(plstr);
- plstr = NULL;
- }
- Py_DECREF(plval);
- plval = NULL;
-
- }
- rtup = SPI_modifytuple(tdata->tg_relation, otup, natts, modattrs,
- modvalues, modnulls);
-
- /* FIXME -- these leak if not explicity pfree'd by other elog calls, no?
- */
- pfree(modattrs);
- pfree(modvalues);
- pfree(modnulls);
-
- if (rtup == NULL)
- elog(ERROR, "plpython: SPI_modifytuple failed -- error %d", SPI_result);
-
- Py_DECREF(plntup);
- Py_DECREF(plkeys);
-
- RESTORE_EXC();
-
- return rtup;
+ return rtup;
}
PyObject *
-PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *rv)
-{
- DECLARE_EXC();
- TriggerData *tdata;
- PyObject *pltname, *pltevent, *pltwhen, *pltlevel, *pltrelid;
- PyObject *pltargs, *pytnew, *pytold;
- PyObject * volatile pltdata = NULL;
- char *stroid;
-
- enter();
-
- SAVE_EXC();
- if (TRAP_EXC())
- {
- RESTORE_EXC();
-
- Py_XDECREF(pltdata);
-
- RERAISE_EXC();
- }
-
- tdata = (TriggerData *) fcinfo->context;
-
- pltdata = PyDict_New();
- if (!pltdata)
- PLy_elog(ERROR, "Unable to build arguments for trigger procedure");
-
- pltname = PyString_FromString(tdata->tg_trigger->tgname);
- PyDict_SetItemString(pltdata, "name", pltname);
- Py_DECREF(pltname);
-
- stroid = DatumGetCString(DirectFunctionCall1(oidout,
- ObjectIdGetDatum(tdata->tg_relation->rd_id)));
- pltrelid = PyString_FromString(stroid);
- PyDict_SetItemString(pltdata, "relid", pltrelid);
- Py_DECREF(pltrelid);
- pfree(stroid);
-
-
-
- if (TRIGGER_FIRED_BEFORE(tdata->tg_event))
- pltwhen = PyString_FromString("BEFORE");
- else if (TRIGGER_FIRED_AFTER(tdata->tg_event))
- pltwhen = PyString_FromString("AFTER");
- else
- pltwhen = PyString_FromString("UNKNOWN");
- PyDict_SetItemString(pltdata, "when", pltwhen);
- Py_DECREF(pltwhen);
-
- if (TRIGGER_FIRED_FOR_ROW(tdata->tg_event))
- pltlevel = PyString_FromString("ROW");
- else if (TRIGGER_FIRED_FOR_STATEMENT(tdata->tg_event))
- pltlevel = PyString_FromString("STATEMENT");
- else
- pltlevel = PyString_FromString("UNKNOWN");
- PyDict_SetItemString(pltdata, "level", pltlevel);
- Py_DECREF(pltlevel);
-
- if (TRIGGER_FIRED_BY_INSERT(tdata->tg_event))
- {
- pltevent = PyString_FromString("INSERT");
- PyDict_SetItemString(pltdata, "old", Py_None);
- pytnew = PLyDict_FromTuple(&(proc->result), tdata->tg_trigtuple,
- tdata->tg_relation->rd_att);
- PyDict_SetItemString(pltdata, "new", pytnew);
- Py_DECREF(pytnew);
- *rv = tdata->tg_trigtuple;
- }
- else if (TRIGGER_FIRED_BY_DELETE(tdata->tg_event))
- {
- pltevent = PyString_FromString("DELETE");
- PyDict_SetItemString(pltdata, "new", Py_None);
- pytold = PLyDict_FromTuple(&(proc->result), tdata->tg_trigtuple,
- tdata->tg_relation->rd_att);
- PyDict_SetItemString(pltdata, "old", pytold);
- Py_DECREF(pytold);
- *rv = tdata->tg_trigtuple;
- }
- else if (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event))
- {
- pltevent = PyString_FromString("UPDATE");
- pytnew = PLyDict_FromTuple(&(proc->result), tdata->tg_newtuple,
- tdata->tg_relation->rd_att);
- PyDict_SetItemString(pltdata, "new", pytnew);
- Py_DECREF(pytnew);
- pytold = PLyDict_FromTuple(&(proc->result), tdata->tg_trigtuple,
- tdata->tg_relation->rd_att);
- PyDict_SetItemString(pltdata, "old", pytold);
- Py_DECREF(pytold);
- *rv = tdata->tg_newtuple;
- }
- else
- {
- pltevent = PyString_FromString("UNKNOWN");
- PyDict_SetItemString(pltdata, "old", Py_None);
- PyDict_SetItemString(pltdata, "new", Py_None);
- *rv = tdata->tg_trigtuple;
- }
- PyDict_SetItemString(pltdata, "event", pltevent);
- Py_DECREF(pltevent);
-
- if (tdata->tg_trigger->tgnargs)
- {
- /* all strings...
- */
- int i;
- PyObject *pltarg;
-
- pltargs = PyList_New(tdata->tg_trigger->tgnargs);
- for (i = 0; i < tdata->tg_trigger->tgnargs; i++)
- {
- pltarg = PyString_FromString(tdata->tg_trigger->tgargs[i]);
- /* stolen, don't Py_DECREF
- */
- PyList_SetItem(pltargs, i, pltarg);
- }
- }
- else
- {
- Py_INCREF(Py_None);
- pltargs = Py_None;
- }
- PyDict_SetItemString(pltdata, "args", pltargs);
- Py_DECREF(pltargs);
-
- RESTORE_EXC();
-
- return pltdata;
+PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple *rv)
+{
+ DECLARE_EXC();
+ TriggerData *tdata;
+ PyObject *pltname,
+ *pltevent,
+ *pltwhen,
+ *pltlevel,
+ *pltrelid;
+ PyObject *pltargs,
+ *pytnew,
+ *pytold;
+ PyObject *volatile pltdata = NULL;
+ char *stroid;
+
+ enter();
+
+ SAVE_EXC();
+ if (TRAP_EXC())
+ {
+ RESTORE_EXC();
+
+ Py_XDECREF(pltdata);
+
+ RERAISE_EXC();
+ }
+
+ tdata = (TriggerData *) fcinfo->context;
+
+ pltdata = PyDict_New();
+ if (!pltdata)
+ PLy_elog(ERROR, "Unable to build arguments for trigger procedure");
+
+ pltname = PyString_FromString(tdata->tg_trigger->tgname);
+ PyDict_SetItemString(pltdata, "name", pltname);
+ Py_DECREF(pltname);
+
+ stroid = DatumGetCString(DirectFunctionCall1(oidout,
+ ObjectIdGetDatum(tdata->tg_relation->rd_id)));
+ pltrelid = PyString_FromString(stroid);
+ PyDict_SetItemString(pltdata, "relid", pltrelid);
+ Py_DECREF(pltrelid);
+ pfree(stroid);
+
+
+
+ if (TRIGGER_FIRED_BEFORE(tdata->tg_event))
+ pltwhen = PyString_FromString("BEFORE");
+ else if (TRIGGER_FIRED_AFTER(tdata->tg_event))
+ pltwhen = PyString_FromString("AFTER");
+ else
+ pltwhen = PyString_FromString("UNKNOWN");
+ PyDict_SetItemString(pltdata, "when", pltwhen);
+ Py_DECREF(pltwhen);
+
+ if (TRIGGER_FIRED_FOR_ROW(tdata->tg_event))
+ pltlevel = PyString_FromString("ROW");
+ else if (TRIGGER_FIRED_FOR_STATEMENT(tdata->tg_event))
+ pltlevel = PyString_FromString("STATEMENT");
+ else
+ pltlevel = PyString_FromString("UNKNOWN");
+ PyDict_SetItemString(pltdata, "level", pltlevel);
+ Py_DECREF(pltlevel);
+
+ if (TRIGGER_FIRED_BY_INSERT(tdata->tg_event))
+ {
+ pltevent = PyString_FromString("INSERT");
+ PyDict_SetItemString(pltdata, "old", Py_None);
+ pytnew = PLyDict_FromTuple(&(proc->result), tdata->tg_trigtuple,
+ tdata->tg_relation->rd_att);
+ PyDict_SetItemString(pltdata, "new", pytnew);
+ Py_DECREF(pytnew);
+ *rv = tdata->tg_trigtuple;
+ }
+ else if (TRIGGER_FIRED_BY_DELETE(tdata->tg_event))
+ {
+ pltevent = PyString_FromString("DELETE");
+ PyDict_SetItemString(pltdata, "new", Py_None);
+ pytold = PLyDict_FromTuple(&(proc->result), tdata->tg_trigtuple,
+ tdata->tg_relation->rd_att);
+ PyDict_SetItemString(pltdata, "old", pytold);
+ Py_DECREF(pytold);
+ *rv = tdata->tg_trigtuple;
+ }
+ else if (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event))
+ {
+ pltevent = PyString_FromString("UPDATE");
+ pytnew = PLyDict_FromTuple(&(proc->result), tdata->tg_newtuple,
+ tdata->tg_relation->rd_att);
+ PyDict_SetItemString(pltdata, "new", pytnew);
+ Py_DECREF(pytnew);
+ pytold = PLyDict_FromTuple(&(proc->result), tdata->tg_trigtuple,
+ tdata->tg_relation->rd_att);
+ PyDict_SetItemString(pltdata, "old", pytold);
+ Py_DECREF(pytold);
+ *rv = tdata->tg_newtuple;
+ }
+ else
+ {
+ pltevent = PyString_FromString("UNKNOWN");
+ PyDict_SetItemString(pltdata, "old", Py_None);
+ PyDict_SetItemString(pltdata, "new", Py_None);
+ *rv = tdata->tg_trigtuple;
+ }
+ PyDict_SetItemString(pltdata, "event", pltevent);
+ Py_DECREF(pltevent);
+
+ if (tdata->tg_trigger->tgnargs)
+ {
+ /*
+ * all strings...
+ */
+ int i;
+ PyObject *pltarg;
+
+ pltargs = PyList_New(tdata->tg_trigger->tgnargs);
+ for (i = 0; i < tdata->tg_trigger->tgnargs; i++)
+ {
+ pltarg = PyString_FromString(tdata->tg_trigger->tgargs[i]);
+
+ /*
+ * stolen, don't Py_DECREF
+ */
+ PyList_SetItem(pltargs, i, pltarg);
+ }
+ }
+ else
+ {
+ Py_INCREF(Py_None);
+ pltargs = Py_None;
+ }
+ PyDict_SetItemString(pltdata, "args", pltargs);
+ Py_DECREF(pltargs);
+
+ RESTORE_EXC();
+
+ return pltdata;
}
/* function handler and friends
*/
Datum
-PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure *proc)
-{
- DECLARE_EXC();
- Datum rv;
- PyObject * volatile plargs = NULL;
- PyObject * volatile plrv = NULL;
- PyObject * volatile plrv_so = NULL;
- char *plrv_sc;
-
- enter();
-
- /*
- * setup to catch elog in while building function arguments,
- * and DECREF the plargs if the function call fails
- */
- SAVE_EXC();
- if (TRAP_EXC())
- {
- RESTORE_EXC();
-
- Py_XDECREF(plargs);
- Py_XDECREF(plrv);
- Py_XDECREF(plrv_so);
-
- RERAISE_EXC();
- }
-
- plargs = PLy_function_build_args(fcinfo, proc);
- plrv = PLy_procedure_call(proc, "args", plargs);
-
- /* Disconnect from SPI manager and then create the return
- * values datum (if the input function does a palloc for it
- * this must not be allocated in the SPI memory context
- * because SPI_finish would free it).
- */
- if (SPI_finish() != SPI_OK_FINISH)
- elog(ERROR, "plpython: SPI_finish failed");
-
- if (plrv == NULL)
- {
- elog(FATAL, "Aiieee, PLy_procedure_call returned NULL");
-#if 0
- if (!PLy_restart_in_progress)
- PLy_elog(ERROR, "plpython: Function \"%s\" failed.", proc->proname);
+PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
+{
+ DECLARE_EXC();
+ Datum rv;
+ PyObject *volatile plargs = NULL;
+ PyObject *volatile plrv = NULL;
+ PyObject *volatile plrv_so = NULL;
+ char *plrv_sc;
+
+ enter();
+
+ /*
+ * setup to catch elog in while building function arguments, and
+ * DECREF the plargs if the function call fails
+ */
+ SAVE_EXC();
+ if (TRAP_EXC())
+ {
+ RESTORE_EXC();
+
+ Py_XDECREF(plargs);
+ Py_XDECREF(plrv);
+ Py_XDECREF(plrv_so);
+
+ RERAISE_EXC();
+ }
+
+ plargs = PLy_function_build_args(fcinfo, proc);
+ plrv = PLy_procedure_call(proc, "args", plargs);
+
+ /*
+ * Disconnect from SPI manager and then create the return values datum
+ * (if the input function does a palloc for it this must not be
+ * allocated in the SPI memory context because SPI_finish would free
+ * it).
+ */
+ if (SPI_finish() != SPI_OK_FINISH)
+ elog(ERROR, "plpython: SPI_finish failed");
- /* FIXME is this dead code? i'm pretty sure it is for unnested
- * calls, but not for nested calls
- */
- RAISE_EXC(1);
+ if (plrv == NULL)
+ {
+ elog(FATAL, "Aiieee, PLy_procedure_call returned NULL");
+#if 0
+ if (!PLy_restart_in_progress)
+ PLy_elog(ERROR, "plpython: Function \"%s\" failed.", proc->proname);
+
+ /*
+ * FIXME is this dead code? i'm pretty sure it is for unnested
+ * calls, but not for nested calls
+ */
+ RAISE_EXC(1);
#endif
- }
-
- /* convert the python PyObject to a postgresql Datum
- * FIXME returning a NULL, ie PG_RETURN_NULL() blows the backend
- * to small messy bits... it this a bug or expected? so just
- * call with the string value of None for now
- */
-
- if (plrv == Py_None)
- {
- fcinfo->isnull = true;
- rv = (Datum) NULL;
- }
- else
- {
- fcinfo->isnull = false;
- plrv_so = PyObject_Str(plrv);
- plrv_sc = PyString_AsString(plrv_so);
- rv = FunctionCall3(&proc->result.out.d.typfunc,
- PointerGetDatum(plrv_sc),
- ObjectIdGetDatum(proc->result.out.d.typelem),
- Int32GetDatum(-1));
- }
-
- RESTORE_EXC();
-
- Py_XDECREF(plargs);
- Py_DECREF(plrv);
- Py_XDECREF(plrv_so);
-
- return rv;
-}
+ }
-PyObject *
-PLy_procedure_call(PLyProcedure *proc, char *kargs, PyObject *vargs)
-{
- PyObject *rv;
-
- enter();
+ /*
+ * convert the python PyObject to a postgresql Datum FIXME returning a
+ * NULL, ie PG_RETURN_NULL() blows the backend to small messy bits...
+ * it this a bug or expected? so just call with the string value of
+ * None for now
+ */
+
+ if (plrv == Py_None)
+ {
+ fcinfo->isnull = true;
+ rv = (Datum) NULL;
+ }
+ else
+ {
+ fcinfo->isnull = false;
+ plrv_so = PyObject_Str(plrv);
+ plrv_sc = PyString_AsString(plrv_so);
+ rv = FunctionCall3(&proc->result.out.d.typfunc,
+ PointerGetDatum(plrv_sc),
+ ObjectIdGetDatum(proc->result.out.d.typelem),
+ Int32GetDatum(-1));
+ }
- PyDict_SetItemString(proc->globals, kargs, vargs);
- rv = PyObject_CallFunction(proc->reval, "O", proc->code);
+ RESTORE_EXC();
- if ((rv == NULL) || (PyErr_Occurred()))
- {
- Py_XDECREF(rv);
- if (!PLy_restart_in_progress)
- PLy_elog(ERROR, "Call of function `%s' failed.", proc->proname);
- RAISE_EXC(1);
- }
+ Py_XDECREF(plargs);
+ Py_DECREF(plrv);
+ Py_XDECREF(plrv_so);
- return rv;
+ return rv;
}
PyObject *
-PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc)
+PLy_procedure_call(PLyProcedure * proc, char *kargs, PyObject * vargs)
{
- DECLARE_EXC();
- PyObject * volatile arg = NULL;
- PyObject * volatile args = NULL;
- int i;
+ PyObject *rv;
- enter();
+ enter();
- /* FIXME -- if the setjmp setup is expensive, add the arg and
- * args field to the procedure struct and cleanup at the
- * start of the next call
- */
- SAVE_EXC();
- if (TRAP_EXC())
- {
- RESTORE_EXC();
- Py_XDECREF(arg);
- Py_XDECREF(args);
+ PyDict_SetItemString(proc->globals, kargs, vargs);
+ rv = PyObject_CallFunction(proc->reval, "O", proc->code);
- RERAISE_EXC();
- }
-
- args = PyList_New(proc->nargs);
- for (i = 0; i < proc->nargs; i++)
- {
- if (proc->args[i].is_rel == 1)
+ if ((rv == NULL) || (PyErr_Occurred()))
{
- TupleTableSlot *slot = (TupleTableSlot *) fcinfo->arg[i];
- arg = PLyDict_FromTuple(&(proc->args[i]), slot->val,
- slot->ttc_tupleDescriptor);
+ Py_XDECREF(rv);
+ if (!PLy_restart_in_progress)
+ PLy_elog(ERROR, "Call of function `%s' failed.", proc->proname);
+ RAISE_EXC(1);
}
- else
+
+ return rv;
+}
+
+PyObject *
+PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc)
+{
+ DECLARE_EXC();
+ PyObject *volatile arg = NULL;
+ PyObject *volatile args = NULL;
+ int i;
+
+ enter();
+
+ /*
+ * FIXME -- if the setjmp setup is expensive, add the arg and args
+ * field to the procedure struct and cleanup at the start of the next
+ * call
+ */
+ SAVE_EXC();
+ if (TRAP_EXC())
{
- if (!fcinfo->argnull[i])
- {
- char *ct;
- Datum dt;
+ RESTORE_EXC();
+ Py_XDECREF(arg);
+ Py_XDECREF(args);
- dt = FunctionCall3(&(proc->args[i].in.d.typfunc),
- fcinfo->arg[i],
- ObjectIdGetDatum(proc->args[i].in.d.typelem),
- Int32GetDatum(-1));
- ct = DatumGetCString(dt);
- arg = (proc->args[i].in.d.func)(ct);
- pfree(ct);
- }
- else
- arg = NULL;
+ RERAISE_EXC();
}
- if (arg == NULL)
+ args = PyList_New(proc->nargs);
+ for (i = 0; i < proc->nargs; i++)
{
- Py_INCREF(Py_None);
- arg = Py_None;
- }
+ if (proc->args[i].is_rel == 1)
+ {
+ TupleTableSlot *slot = (TupleTableSlot *) fcinfo->arg[i];
- /* FIXME -- error check this
- */
- PyList_SetItem(args, i, arg);
- }
+ arg = PLyDict_FromTuple(&(proc->args[i]), slot->val,
+ slot->ttc_tupleDescriptor);
+ }
+ else
+ {
+ if (!fcinfo->argnull[i])
+ {
+ char *ct;
+ Datum dt;
+
+ dt = FunctionCall3(&(proc->args[i].in.d.typfunc),
+ fcinfo->arg[i],
+ ObjectIdGetDatum(proc->args[i].in.d.typelem),
+ Int32GetDatum(-1));
+ ct = DatumGetCString(dt);
+ arg = (proc->args[i].in.d.func) (ct);
+ pfree(ct);
+ }
+ else
+ arg = NULL;
+ }
- RESTORE_EXC();
+ if (arg == NULL)
+ {
+ Py_INCREF(Py_None);
+ arg = Py_None;
+ }
- return args;
+ /*
+ * FIXME -- error check this
+ */
+ PyList_SetItem(args, i, arg);
+ }
+
+ RESTORE_EXC();
+
+ return args;
}
static PLyProcedure *
PLy_procedure_get(FunctionCallInfo fcinfo, bool is_trigger)
{
- Oid fn_oid;
- HeapTuple procTup;
- char key[128];
- PyObject *plproc;
- PLyProcedure *proc = NULL;
- int rv;
-
- enter();
-
- fn_oid = fcinfo->flinfo->fn_oid;
- procTup = SearchSysCache(PROCOID,
- ObjectIdGetDatum(fn_oid),
- 0, 0, 0);
- if (!HeapTupleIsValid(procTup))
- elog(ERROR, "plpython: cache lookup for procedure %u failed", fn_oid);
-
- rv = snprintf(key, sizeof(key), "%u%s",
- fn_oid,
- is_trigger ? "_trigger" : "");
- if ((rv >= sizeof(key)) || (rv < 0))
- elog(FATAL, "plpython: Buffer overrun in %s:%d", __FILE__, __LINE__);
-
- plproc = PyDict_GetItemString(PLy_procedure_cache, key);
-
- if (plproc != NULL)
- {
- Py_INCREF(plproc);
- if (!PyCObject_Check(plproc))
- elog(FATAL, "plpython: Expected a PyCObject, didn't get one");
-
- mark();
-
- proc = PyCObject_AsVoidPtr(plproc);
- if (proc->me != plproc)
- elog(FATAL, "plpython: Aiieee, proc->me != plproc");
- /* did we find an up-to-date cache entry? */
- if (proc->fn_xmin != procTup->t_data->t_xmin ||
- proc->fn_cmin != procTup->t_data->t_cmin)
- {
- Py_DECREF(plproc);
- proc = NULL;
- }
- }
-
- if (proc == NULL)
- proc = PLy_procedure_create(fcinfo, is_trigger, procTup, key);
-
- ReleaseSysCache(procTup);
-
- return proc;
+ Oid fn_oid;
+ HeapTuple procTup;
+ char key[128];
+ PyObject *plproc;
+ PLyProcedure *proc = NULL;
+ int rv;
+
+ enter();
+
+ fn_oid = fcinfo->flinfo->fn_oid;
+ procTup = SearchSysCache(PROCOID,
+ ObjectIdGetDatum(fn_oid),
+ 0, 0, 0);
+ if (!HeapTupleIsValid(procTup))
+ elog(ERROR, "plpython: cache lookup for procedure %u failed", fn_oid);
+
+ rv = snprintf(key, sizeof(key), "%u%s",
+ fn_oid,
+ is_trigger ? "_trigger" : "");
+ if ((rv >= sizeof(key)) || (rv < 0))
+ elog(FATAL, "plpython: Buffer overrun in %s:%d", __FILE__, __LINE__);
+
+ plproc = PyDict_GetItemString(PLy_procedure_cache, key);
+
+ if (plproc != NULL)
+ {
+ Py_INCREF(plproc);
+ if (!PyCObject_Check(plproc))
+ elog(FATAL, "plpython: Expected a PyCObject, didn't get one");
+
+ mark();
+
+ proc = PyCObject_AsVoidPtr(plproc);
+ if (proc->me != plproc)
+ elog(FATAL, "plpython: Aiieee, proc->me != plproc");
+ /* did we find an up-to-date cache entry? */
+ if (proc->fn_xmin != procTup->t_data->t_xmin ||
+ proc->fn_cmin != procTup->t_data->t_cmin)
+ {
+ Py_DECREF(plproc);
+ proc = NULL;
+ }
+ }
+
+ if (proc == NULL)
+ proc = PLy_procedure_create(fcinfo, is_trigger, procTup, key);
+
+ ReleaseSysCache(procTup);
+
+ return proc;
}
static PLyProcedure *
PLy_procedure_create(FunctionCallInfo fcinfo, bool is_trigger,
HeapTuple procTup, char *key)
{
- char procName[256];
- DECLARE_EXC();
- Form_pg_proc procStruct;
- PLyProcedure *volatile proc;
- char *volatile procSource = NULL;
- Datum procDatum;
- int i, rv;
-
- enter();
-
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
-
- rv = snprintf(procName, sizeof(procName),
- "__plpython_procedure_%s_%u%s",
- NameStr(procStruct->proname),
- fcinfo->flinfo->fn_oid,
- is_trigger ? "_trigger" : "");
- if ((rv >= sizeof(procName)) || (rv < 0))
- elog(FATAL, "plpython: Procedure name would overrun buffer");
-
- proc = PLy_malloc(sizeof(PLyProcedure));
- proc->proname = PLy_malloc(strlen(procName) + 1);
- strcpy(proc->proname, procName);
- proc->fn_xmin = procTup->t_data->t_xmin;
- proc->fn_cmin = procTup->t_data->t_cmin;
- PLy_typeinfo_init(&proc->result);
- for (i = 0; i < FUNC_MAX_ARGS; i++)
- PLy_typeinfo_init(&proc->args[i]);
- proc->nargs = 0;
- proc->code = proc->interp = proc->reval = proc->statics = NULL;
- proc->globals = proc->me = NULL;
-
- SAVE_EXC();
- if (TRAP_EXC())
- {
- RESTORE_EXC();
- PLy_procedure_delete(proc);
- if (procSource)
+ char procName[256];
+
+ DECLARE_EXC();
+ Form_pg_proc procStruct;
+ PLyProcedure *volatile proc;
+ char *volatile procSource = NULL;
+ Datum procDatum;
+ int i,
+ rv;
+
+ enter();
+
+ procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+
+ rv = snprintf(procName, sizeof(procName),
+ "__plpython_procedure_%s_%u%s",
+ NameStr(procStruct->proname),
+ fcinfo->flinfo->fn_oid,
+ is_trigger ? "_trigger" : "");
+ if ((rv >= sizeof(procName)) || (rv < 0))
+ elog(FATAL, "plpython: Procedure name would overrun buffer");
+
+ proc = PLy_malloc(sizeof(PLyProcedure));
+ proc->proname = PLy_malloc(strlen(procName) + 1);
+ strcpy(proc->proname, procName);
+ proc->fn_xmin = procTup->t_data->t_xmin;
+ proc->fn_cmin = procTup->t_data->t_cmin;
+ PLy_typeinfo_init(&proc->result);
+ for (i = 0; i < FUNC_MAX_ARGS; i++)
+ PLy_typeinfo_init(&proc->args[i]);
+ proc->nargs = 0;
+ proc->code = proc->interp = proc->reval = proc->statics = NULL;
+ proc->globals = proc->me = NULL;
+
+ SAVE_EXC();
+ if (TRAP_EXC())
+ {
+ RESTORE_EXC();
+ PLy_procedure_delete(proc);
+ if (procSource)
+ pfree(procSource);
+ RERAISE_EXC();
+ }
+
+ /*
+ * get information required for output conversion of the return value,
+ * but only if this isn't a trigger.
+ */
+ if (!is_trigger)
+ {
+ HeapTuple rvTypeTup;
+ Form_pg_type rvTypeStruct;
+ Datum rvDatum;
+
+ rvDatum = ObjectIdGetDatum(procStruct->prorettype);
+ rvTypeTup = SearchSysCache(TYPEOID, rvDatum, 0, 0, 0);
+ if (!HeapTupleIsValid(rvTypeTup))
+ elog(ERROR, "plpython: cache lookup for type \"%u\" failed",
+ procStruct->prorettype);
+
+ rvTypeStruct = (Form_pg_type) GETSTRUCT(rvTypeTup);
+ if (rvTypeStruct->typrelid == InvalidOid)
+ PLy_output_datum_func(&proc->result, rvTypeStruct);
+ else
+ elog(ERROR, "plpython: tuple return types not supported, yet");
+
+ ReleaseSysCache(rvTypeTup);
+ }
+ else
+ {
+ /*
+ * input/output conversion for trigger tuples. use the result
+ * TypeInfo variable to store the tuple conversion info.
+ */
+ TriggerData *tdata = (TriggerData *) fcinfo->context;
+
+ PLy_input_tuple_funcs(&(proc->result), tdata->tg_relation->rd_att);
+ PLy_output_tuple_funcs(&(proc->result), tdata->tg_relation->rd_att);
+ }
+
+ /*
+ * now get information required for input conversion of the procedures
+ * arguments.
+ */
+ proc->nargs = fcinfo->nargs;
+ for (i = 0; i < fcinfo->nargs; i++)
+ {
+ HeapTuple argTypeTup;
+ Form_pg_type argTypeStruct;
+ Datum argDatum;
+
+ argDatum = ObjectIdGetDatum(procStruct->proargtypes[i]);
+ argTypeTup = SearchSysCache(TYPEOID, argDatum, 0, 0, 0);
+ if (!HeapTupleIsValid(argTypeTup))
+ elog(ERROR, "plpython: cache lookup for type \"%u\" failed",
+ procStruct->proargtypes[i]);
+ argTypeStruct = (Form_pg_type) GETSTRUCT(argTypeTup);
+
+ if (argTypeStruct->typrelid == InvalidOid)
+ PLy_input_datum_func(&(proc->args[i]), argTypeStruct);
+ else
+ {
+ TupleTableSlot *slot = (TupleTableSlot *) fcinfo->arg[i];
+
+ PLy_input_tuple_funcs(&(proc->args[i]),
+ slot->ttc_tupleDescriptor);
+ }
+
+ ReleaseSysCache(argTypeTup);
+ }
+
+
+ /*
+ * get the text of the function.
+ */
+ procDatum = DirectFunctionCall1(textout,
+ PointerGetDatum(&procStruct->prosrc));
+ procSource = DatumGetCString(procDatum);
+
+ PLy_procedure_compile(proc, procSource);
+
pfree(procSource);
- RERAISE_EXC();
- }
-
- /* get information required for output conversion of the return
- * value, but only if this isn't a trigger.
- */
- if (!is_trigger)
- {
- HeapTuple rvTypeTup;
- Form_pg_type rvTypeStruct;
- Datum rvDatum;
-
- rvDatum = ObjectIdGetDatum(procStruct->prorettype);
- rvTypeTup = SearchSysCache(TYPEOID, rvDatum, 0, 0, 0);
- if (!HeapTupleIsValid(rvTypeTup))
- elog(ERROR, "plpython: cache lookup for type \"%u\" failed",
- procStruct->prorettype);
-
- rvTypeStruct = (Form_pg_type) GETSTRUCT(rvTypeTup);
- if (rvTypeStruct->typrelid == InvalidOid)
- PLy_output_datum_func(&proc->result, rvTypeStruct);
- else
- elog(ERROR, "plpython: tuple return types not supported, yet");
-
- ReleaseSysCache(rvTypeTup);
- }
- else
- {
- /* input/output conversion for trigger tuples. use the
- * result TypeInfo variable to store the tuple conversion
- * info.
- */
- TriggerData *tdata = (TriggerData *) fcinfo->context;
- PLy_input_tuple_funcs(&(proc->result), tdata->tg_relation->rd_att);
- PLy_output_tuple_funcs(&(proc->result), tdata->tg_relation->rd_att);
- }
-
- /* now get information required for input conversion of the
- * procedures arguments.
- */
- proc->nargs = fcinfo->nargs;
- for (i = 0; i < fcinfo->nargs; i++)
- {
- HeapTuple argTypeTup;
- Form_pg_type argTypeStruct;
- Datum argDatum;
-
- argDatum = ObjectIdGetDatum(procStruct->proargtypes[i]);
- argTypeTup = SearchSysCache(TYPEOID, argDatum, 0, 0, 0);
- if (!HeapTupleIsValid(argTypeTup))
- elog(ERROR, "plpython: cache lookup for type \"%u\" failed",
- procStruct->proargtypes[i]);
- argTypeStruct = (Form_pg_type) GETSTRUCT(argTypeTup);
-
- if (argTypeStruct->typrelid == InvalidOid)
- PLy_input_datum_func(&(proc->args[i]), argTypeStruct);
- else
- {
- TupleTableSlot *slot = (TupleTableSlot *) fcinfo->arg[i];
- PLy_input_tuple_funcs(&(proc->args[i]),
- slot->ttc_tupleDescriptor);
- }
-
- ReleaseSysCache(argTypeTup);
- }
-
-
- /* get the text of the function.
- */
- procDatum = DirectFunctionCall1(textout,
- PointerGetDatum(&procStruct->prosrc));
- procSource = DatumGetCString(procDatum);
-
- PLy_procedure_compile(proc, procSource);
-
- pfree(procSource);
-
- proc->me = PyCObject_FromVoidPtr(proc, NULL);
- PyDict_SetItemString(PLy_procedure_cache, key, proc->me);
-
- RESTORE_EXC();
-
- return proc;
+
+ proc->me = PyCObject_FromVoidPtr(proc, NULL);
+ PyDict_SetItemString(PLy_procedure_cache, key, proc->me);
+
+ RESTORE_EXC();
+
+ return proc;
}
void
-PLy_procedure_compile(PLyProcedure *proc, const char *src)
-{
- PyObject *module, *crv = NULL;
- char *msrc;
-
- enter();
-
- /* get an instance of rexec.RExec for the function
- */
- proc->interp = PyObject_CallMethod(PLy_interp_safe, "RExec", NULL);
- if ((proc->interp == NULL) || (PyErr_Occurred ()))
- PLy_elog(ERROR, "Unable to create rexec.RExec instance");
-
- /* tweak the list of permitted modules
- */
- PyObject_SetAttrString(proc->interp, "ok_builtin_modules",
- PLy_importable_modules);
-
- proc->reval = PyObject_GetAttrString(proc->interp, "r_eval");
- if ((proc->reval == NULL) || (PyErr_Occurred ()))
- PLy_elog(ERROR, "Unable to get method `r_eval' from rexec.RExec");
-
- /* add a __main__ module to the function's interpreter
- */
- module = PyObject_CallMethod (proc->interp, "add_module", "s", "__main__");
- if ((module == NULL) || (PyErr_Occurred ()))
- PLy_elog(ERROR, "Unable to get module `__main__' from rexec.RExec");
-
- /* add plpy module to the interpreters main dictionary
- */
- proc->globals = PyModule_GetDict (module);
- if ((proc->globals == NULL) || (PyErr_Occurred ()))
- PLy_elog(ERROR, "Unable to get `__main__.__dict__' from rexec.RExec");
-
- /* why the hell won't r_import or r_exec('import plpy') work?
- */
- module = PyDict_GetItemString(PLy_interp_globals, "plpy");
- if ((module == NULL) || (PyErr_Occurred()))
- PLy_elog(ERROR, "Unable to get `plpy'");
- Py_INCREF(module);
- PyDict_SetItemString(proc->globals, "plpy", module);
-
- /* SD is private preserved data between calls
- * GD is global data shared by all functions
- */
- proc->statics = PyDict_New();
- PyDict_SetItemString(proc->globals, "SD", proc->statics);
- PyDict_SetItemString(proc->globals, "GD", PLy_interp_safe_globals);
-
- /* insert the function code into the interpreter
- */
- msrc = PLy_procedure_munge_source(proc->proname, src);
- crv = PyObject_CallMethod(proc->interp, "r_exec", "s", msrc);
- free(msrc);
-
- if ((crv != NULL) && (!PyErr_Occurred ()))
- {
- int clen;
- char call[256];
-
- Py_DECREF(crv);
-
- /* compile a call to the function
- */
- clen = snprintf(call, sizeof(call), "%s()", proc->proname);
- if ((clen < 0) || (clen >= sizeof(call)))
- elog(ERROR, "plpython: string would overflow buffer.");
- proc->code = Py_CompileString(call, "", Py_eval_input);
- if ((proc->code != NULL) && (!PyErr_Occurred ()))
- return;
- }
- else
- Py_XDECREF(crv);
-
- PLy_elog(ERROR, "Unable to compile function %s", proc->proname);
+PLy_procedure_compile(PLyProcedure * proc, const char *src)
+{
+ PyObject *module,
+ *crv = NULL;
+ char *msrc;
+
+ enter();
+
+ /*
+ * get an instance of rexec.RExec for the function
+ */
+ proc->interp = PyObject_CallMethod(PLy_interp_safe, "RExec", NULL);
+ if ((proc->interp == NULL) || (PyErr_Occurred()))
+ PLy_elog(ERROR, "Unable to create rexec.RExec instance");
+
+ /*
+ * tweak the list of permitted modules
+ */
+ PyObject_SetAttrString(proc->interp, "ok_builtin_modules",
+ PLy_importable_modules);
+
+ proc->reval = PyObject_GetAttrString(proc->interp, "r_eval");
+ if ((proc->reval == NULL) || (PyErr_Occurred()))
+ PLy_elog(ERROR, "Unable to get method `r_eval' from rexec.RExec");
+
+ /*
+ * add a __main__ module to the function's interpreter
+ */
+ module = PyObject_CallMethod(proc->interp, "add_module", "s", "__main__");
+ if ((module == NULL) || (PyErr_Occurred()))
+ PLy_elog(ERROR, "Unable to get module `__main__' from rexec.RExec");
+
+ /*
+ * add plpy module to the interpreters main dictionary
+ */
+ proc->globals = PyModule_GetDict(module);
+ if ((proc->globals == NULL) || (PyErr_Occurred()))
+ PLy_elog(ERROR, "Unable to get `__main__.__dict__' from rexec.RExec");
+
+ /*
+ * why the hell won't r_import or r_exec('import plpy') work?
+ */
+ module = PyDict_GetItemString(PLy_interp_globals, "plpy");
+ if ((module == NULL) || (PyErr_Occurred()))
+ PLy_elog(ERROR, "Unable to get `plpy'");
+ Py_INCREF(module);
+ PyDict_SetItemString(proc->globals, "plpy", module);
+
+ /*
+ * SD is private preserved data between calls GD is global data shared
+ * by all functions
+ */
+ proc->statics = PyDict_New();
+ PyDict_SetItemString(proc->globals, "SD", proc->statics);
+ PyDict_SetItemString(proc->globals, "GD", PLy_interp_safe_globals);
+
+ /*
+ * insert the function code into the interpreter
+ */
+ msrc = PLy_procedure_munge_source(proc->proname, src);
+ crv = PyObject_CallMethod(proc->interp, "r_exec", "s", msrc);
+ free(msrc);
+
+ if ((crv != NULL) && (!PyErr_Occurred()))
+ {
+ int clen;
+ char call[256];
+
+ Py_DECREF(crv);
+
+ /*
+ * compile a call to the function
+ */
+ clen = snprintf(call, sizeof(call), "%s()", proc->proname);
+ if ((clen < 0) || (clen >= sizeof(call)))
+ elog(ERROR, "plpython: string would overflow buffer.");
+ proc->code = Py_CompileString(call, "", Py_eval_input);
+ if ((proc->code != NULL) && (!PyErr_Occurred()))
+ return;
+ }
+ else
+ Py_XDECREF(crv);
+
+ PLy_elog(ERROR, "Unable to compile function %s", proc->proname);
}
char *
PLy_procedure_munge_source(const char *name, const char *src)
{
- char *mrc, *mp;
- const char *sp;
- size_t mlen, plen;
+ char *mrc,
+ *mp;
+ const char *sp;
+ size_t mlen,
+ plen;
- enter();
+ enter();
- /* room for function source and the def statement
- */
- mlen = (strlen (src) * 2) + strlen(name) + 16;
+ /*
+ * room for function source and the def statement
+ */
+ mlen = (strlen(src) * 2) + strlen(name) + 16;
- mrc = PLy_malloc(mlen);
- plen = snprintf(mrc, mlen, "def %s():\n\t", name);
- if ((plen < 0) || (plen >= mlen))
- elog(FATAL, "Aiieee, impossible buffer overrun (or snprintf failure)");
+ mrc = PLy_malloc(mlen);
+ plen = snprintf(mrc, mlen, "def %s():\n\t", name);
+ if ((plen < 0) || (plen >= mlen))
+ elog(FATAL, "Aiieee, impossible buffer overrun (or snprintf failure)");
- sp = src;
- mp = mrc + plen;
+ sp = src;
+ mp = mrc + plen;
- while (*sp != '\0')
- {
- if (*sp == '\n')
+ while (*sp != '\0')
{
- *mp++ = *sp++;
- *mp++ = '\t';
+ if (*sp == '\n')
+ {
+ *mp++ = *sp++;
+ *mp++ = '\t';
+ }
+ else
+ *mp++ = *sp++;
}
- else
- *mp++ = *sp++;
- }
- *mp++ = '\n';
- *mp++ = '\n';
- *mp = '\0';
+ *mp++ = '\n';
+ *mp++ = '\n';
+ *mp = '\0';
- if (mp > (mrc + mlen))
- elog(FATAL, "plpython: Buffer overrun in PLy_munge_source");
+ if (mp > (mrc + mlen))
+ elog(FATAL, "plpython: Buffer overrun in PLy_munge_source");
- return mrc;
+ return mrc;
}
void
-PLy_procedure_delete(PLyProcedure *proc)
-{
- int i;
-
- enter();
-
- Py_XDECREF(proc->code);
- Py_XDECREF(proc->interp);
- Py_XDECREF(proc->reval);
- Py_XDECREF(proc->statics);
- Py_XDECREF(proc->globals);
- Py_XDECREF(proc->me);
- if (proc->proname)
- PLy_free(proc->proname);
- for (i = 0; i < proc->nargs; i++)
- if (proc->args[i].is_rel == 1)
- {
- if (proc->args[i].in.r.atts)
- PLy_free(proc->args[i].in.r.atts);
- if (proc->args[i].out.r.atts)
- PLy_free(proc->args[i].out.r.atts);
- }
+PLy_procedure_delete(PLyProcedure * proc)
+{
+ int i;
+
+ enter();
+
+ Py_XDECREF(proc->code);
+ Py_XDECREF(proc->interp);
+ Py_XDECREF(proc->reval);
+ Py_XDECREF(proc->statics);
+ Py_XDECREF(proc->globals);
+ Py_XDECREF(proc->me);
+ if (proc->proname)
+ PLy_free(proc->proname);
+ for (i = 0; i < proc->nargs; i++)
+ if (proc->args[i].is_rel == 1)
+ {
+ if (proc->args[i].in.r.atts)
+ PLy_free(proc->args[i].in.r.atts);
+ if (proc->args[i].out.r.atts)
+ PLy_free(proc->args[i].out.r.atts);
+ }
- leave();
+ leave();
}
/* conversion functions. remember output from python is
* input to postgresql, and vis versa.
*/
void
-PLy_input_tuple_funcs(PLyTypeInfo *arg, TupleDesc desc)
+PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
{
- int i;
- Datum datum;
-
- enter ();
+ int i;
+ Datum datum;
- if (arg->is_rel == 0)
- elog(FATAL, "plpython: PLyTypeInfo struct is initialized for a Datum");
+ enter();
- arg->is_rel = 1;
- arg->in.r.natts = desc->natts;
- arg->in.r.atts = malloc(desc->natts * sizeof(PLyDatumToOb));
+ if (arg->is_rel == 0)
+ elog(FATAL, "plpython: PLyTypeInfo struct is initialized for a Datum");
- for (i = 0; i < desc->natts; i++)
- {
- HeapTuple typeTup;
- Form_pg_type typeStruct;
+ arg->is_rel = 1;
+ arg->in.r.natts = desc->natts;
+ arg->in.r.atts = malloc(desc->natts * sizeof(PLyDatumToOb));
- datum = ObjectIdGetDatum(desc->attrs[i]->atttypid);
- typeTup = SearchSysCache(TYPEOID, datum, 0, 0, 0);
- if (!HeapTupleIsValid(typeTup))
+ for (i = 0; i < desc->natts; i++)
{
- char *attname = NameStr(desc->attrs[i]->attname);
- elog(ERROR, "plpython: Cache lookup for attribute `%s' type `%u' failed",
- attname, desc->attrs[i]->atttypid);
- }
+ HeapTuple typeTup;
+ Form_pg_type typeStruct;
+
+ datum = ObjectIdGetDatum(desc->attrs[i]->atttypid);
+ typeTup = SearchSysCache(TYPEOID, datum, 0, 0, 0);
+ if (!HeapTupleIsValid(typeTup))
+ {
+ char *attname = NameStr(desc->attrs[i]->attname);
+
+ elog(ERROR, "plpython: Cache lookup for attribute `%s' type `%u' failed",
+ attname, desc->attrs[i]->atttypid);
+ }
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
- PLy_input_datum_func2(&(arg->in.r.atts[i]), typeStruct);
+ PLy_input_datum_func2(&(arg->in.r.atts[i]), typeStruct);
- ReleaseSysCache(typeTup);
- }
+ ReleaseSysCache(typeTup);
+ }
}
void
-PLy_output_tuple_funcs(PLyTypeInfo *arg, TupleDesc desc)
+PLy_output_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
{
- int i;
- Datum datum;
-
- enter ();
+ int i;
+ Datum datum;
- if (arg->is_rel == 0)
- elog(FATAL, "plpython: PLyTypeInfo struct is initialized for a Datum");
+ enter();
- arg->is_rel = 1;
- arg->out.r.natts = desc->natts;
- arg->out.r.atts = malloc(desc->natts * sizeof(PLyDatumToOb));
+ if (arg->is_rel == 0)
+ elog(FATAL, "plpython: PLyTypeInfo struct is initialized for a Datum");
- for (i = 0; i < desc->natts; i++)
- {
- HeapTuple typeTup;
- Form_pg_type typeStruct;
+ arg->is_rel = 1;
+ arg->out.r.natts = desc->natts;
+ arg->out.r.atts = malloc(desc->natts * sizeof(PLyDatumToOb));
- datum = ObjectIdGetDatum(desc->attrs[i]->atttypid);
- typeTup = SearchSysCache(TYPEOID, datum, 0, 0, 0);
- if (!HeapTupleIsValid(typeTup))
+ for (i = 0; i < desc->natts; i++)
{
- char *attname = NameStr(desc->attrs[i]->attname);
- elog(ERROR, "plpython: Cache lookup for attribute `%s' type `%u' failed",
- attname, desc->attrs[i]->atttypid);
- }
+ HeapTuple typeTup;
+ Form_pg_type typeStruct;
+
+ datum = ObjectIdGetDatum(desc->attrs[i]->atttypid);
+ typeTup = SearchSysCache(TYPEOID, datum, 0, 0, 0);
+ if (!HeapTupleIsValid(typeTup))
+ {
+ char *attname = NameStr(desc->attrs[i]->attname);
+
+ elog(ERROR, "plpython: Cache lookup for attribute `%s' type `%u' failed",
+ attname, desc->attrs[i]->atttypid);
+ }
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
- PLy_output_datum_func2(&(arg->out.r.atts[i]), typeStruct);
+ PLy_output_datum_func2(&(arg->out.r.atts[i]), typeStruct);
- ReleaseSysCache(typeTup);
- }
+ ReleaseSysCache(typeTup);
+ }
}
void
-PLy_output_datum_func(PLyTypeInfo *arg, Form_pg_type typeStruct)
+PLy_output_datum_func(PLyTypeInfo * arg, Form_pg_type typeStruct)
{
- enter();
+ enter();
- if (arg->is_rel == 1)
- elog(FATAL, "plpython: PLyTypeInfo struct is initialized for a Tuple");
- arg->is_rel = 0;
- PLy_output_datum_func2(&(arg->out.d), typeStruct);
+ if (arg->is_rel == 1)
+ elog(FATAL, "plpython: PLyTypeInfo struct is initialized for a Tuple");
+ arg->is_rel = 0;
+ PLy_output_datum_func2(&(arg->out.d), typeStruct);
}
void
-PLy_output_datum_func2(PLyObToDatum *arg, Form_pg_type typeStruct)
+PLy_output_datum_func2(PLyObToDatum * arg, Form_pg_type typeStruct)
{
- enter();
+ enter();
- perm_fmgr_info(typeStruct->typinput, &arg->typfunc);
- arg->typelem = typeStruct->typelem;
- arg->typbyval = typeStruct->typbyval;
+ perm_fmgr_info(typeStruct->typinput, &arg->typfunc);
+ arg->typelem = typeStruct->typelem;
+ arg->typbyval = typeStruct->typbyval;
}
void
-PLy_input_datum_func(PLyTypeInfo *arg, Form_pg_type typeStruct)
+PLy_input_datum_func(PLyTypeInfo * arg, Form_pg_type typeStruct)
{
- enter();
+ enter();
- if (arg->is_rel == 1)
- elog(FATAL, "plpython: PLyTypeInfo struct is initialized for Tuple");
- arg->is_rel = 0;
- PLy_input_datum_func2(&(arg->in.d), typeStruct);
+ if (arg->is_rel == 1)
+ elog(FATAL, "plpython: PLyTypeInfo struct is initialized for Tuple");
+ arg->is_rel = 0;
+ PLy_input_datum_func2(&(arg->in.d), typeStruct);
}
void
-PLy_input_datum_func2(PLyDatumToOb *arg, Form_pg_type typeStruct)
-{
- char *type;
-
- perm_fmgr_info(typeStruct->typoutput, &arg->typfunc);
- arg->typelem = typeStruct->typelem;
- arg->typbyval = typeStruct->typbyval;
-
- /* hmmm, wierd. means this arg will always be converted
- * to a python None
- */
- if (!OidIsValid(typeStruct->typoutput))
- {
- elog(ERROR, "plpython: (FIXME) typeStruct->typoutput is invalid");
-
- arg->func = NULL;
- return;
- }
-
- type = NameStr(typeStruct->typname);
- switch (type[0])
- {
- case 'b':
- {
- if (strcasecmp("bool", type))
- {
- arg->func = PLyBool_FromString;
- return;
- }
- break;
- }
- case 'f':
- {
- if ((strncasecmp("float", type, 5) == 0) &&
- ((type[5] == '8') || (type[5] == '4')))
- {
- arg->func = PLyFloat_FromString;
- return;
- }
- break;
- }
- case 'i':
- {
- if ((strncasecmp("int", type, 3) == 0) &&
- ((type[3] == '4') || (type[3] == '2')) &&
- (type[4] == '\0'))
- {
- arg->func = PLyInt_FromString;
- return;
- }
- else if ( strcasecmp("int8", type) == 0 )
- {
- arg->func = PLyLong_FromString;
- }
- break;
- }
- case 'n':
- {
- if (strcasecmp("numeric", type) == 0)
- {
- arg->func = PLyFloat_FromString;
- return;
- }
- break;
- }
- default:
- break;
- }
- arg->func = PLyString_FromString;
+PLy_input_datum_func2(PLyDatumToOb * arg, Form_pg_type typeStruct)
+{
+ char *type;
+
+ perm_fmgr_info(typeStruct->typoutput, &arg->typfunc);
+ arg->typelem = typeStruct->typelem;
+ arg->typbyval = typeStruct->typbyval;
+
+ /*
+ * hmmm, wierd. means this arg will always be converted to a python
+ * None
+ */
+ if (!OidIsValid(typeStruct->typoutput))
+ {
+ elog(ERROR, "plpython: (FIXME) typeStruct->typoutput is invalid");
+
+ arg->func = NULL;
+ return;
+ }
+
+ type = NameStr(typeStruct->typname);
+ switch (type[0])
+ {
+ case 'b':
+ {
+ if (strcasecmp("bool", type))
+ {
+ arg->func = PLyBool_FromString;
+ return;
+ }
+ break;
+ }
+ case 'f':
+ {
+ if ((strncasecmp("float", type, 5) == 0) &&
+ ((type[5] == '8') || (type[5] == '4')))
+ {
+ arg->func = PLyFloat_FromString;
+ return;
+ }
+ break;
+ }
+ case 'i':
+ {
+ if ((strncasecmp("int", type, 3) == 0) &&
+ ((type[3] == '4') || (type[3] == '2')) &&
+ (type[4] == '\0'))
+ {
+ arg->func = PLyInt_FromString;
+ return;
+ }
+ else if (strcasecmp("int8", type) == 0)
+ arg->func = PLyLong_FromString;
+ break;
+ }
+ case 'n':
+ {
+ if (strcasecmp("numeric", type) == 0)
+ {
+ arg->func = PLyFloat_FromString;
+ return;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ arg->func = PLyString_FromString;
}
void
-PLy_typeinfo_init(PLyTypeInfo *arg)
+PLy_typeinfo_init(PLyTypeInfo * arg)
{
- arg->is_rel = -1;
- arg->in.r.natts = arg->out.r.natts = 0;
- arg->in.r.atts = NULL;
- arg->out.r.atts = NULL;
+ arg->is_rel = -1;
+ arg->in.r.natts = arg->out.r.natts = 0;
+ arg->in.r.atts = NULL;
+ arg->out.r.atts = NULL;
}
void
-PLy_typeinfo_dealloc(PLyTypeInfo *arg)
+PLy_typeinfo_dealloc(PLyTypeInfo * arg)
{
- if (arg->is_rel == 1)
- {
- if (arg->in.r.atts)
- PLy_free(arg->in.r.atts);
- if (arg->out.r.atts)
- PLy_free(arg->out.r.atts);
- }
+ if (arg->is_rel == 1)
+ {
+ if (arg->in.r.atts)
+ PLy_free(arg->in.r.atts);
+ if (arg->out.r.atts)
+ PLy_free(arg->out.r.atts);
+ }
}
/* assumes that a bool is always returned as a 't' or 'f'
PyObject *
PLyBool_FromString(const char *src)
{
- enter();
+ enter();
- if (src[0] == 't')
- return PyInt_FromLong(1);
- return PyInt_FromLong(0);
+ if (src[0] == 't')
+ return PyInt_FromLong(1);
+ return PyInt_FromLong(0);
}
PyObject *
PLyFloat_FromString(const char *src)
{
- double v;
- char *eptr;
+ double v;
+ char *eptr;
+
+ enter();
- enter();
-
- errno = 0;
- v = strtod(src, &eptr);
- if ((*eptr != '\0') || (errno))
- return NULL;
- return PyFloat_FromDouble(v);
+ errno = 0;
+ v = strtod(src, &eptr);
+ if ((*eptr != '\0') || (errno))
+ return NULL;
+ return PyFloat_FromDouble(v);
}
PyObject *
PLyInt_FromString(const char *src)
{
- long v;
- char *eptr;
+ long v;
+ char *eptr;
- enter();
+ enter();
- errno = 0;
- v = strtol(src, &eptr, 0);
- if ((*eptr != '\0') || (errno))
- return NULL;
- return PyInt_FromLong(v);
+ errno = 0;
+ v = strtol(src, &eptr, 0);
+ if ((*eptr != '\0') || (errno))
+ return NULL;
+ return PyInt_FromLong(v);
}
PyObject *
PLyLong_FromString(const char *src)
{
- return PyLong_FromString((char *)src,NULL,0);
+ return PyLong_FromString((char *) src, NULL, 0);
}
PyObject *
PLyString_FromString(const char *src)
{
- return PyString_FromString(src);
+ return PyString_FromString(src);
}
PyObject *
-PLyDict_FromTuple(PLyTypeInfo *info, HeapTuple tuple, TupleDesc desc)
+PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc)
{
- DECLARE_EXC();
- PyObject *volatile dict;
- int i;
+ DECLARE_EXC();
+ PyObject *volatile dict;
+ int i;
- enter();
+ enter();
- if (info->is_rel != 1)
- elog(FATAL, "plpython: PLyTypeInfo structure describes a datum.");
+ if (info->is_rel != 1)
+ elog(FATAL, "plpython: PLyTypeInfo structure describes a datum.");
- dict = PyDict_New();
- if (dict == NULL)
- PLy_elog(ERROR, "Unable to create tuple dictionary.");
+ dict = PyDict_New();
+ if (dict == NULL)
+ PLy_elog(ERROR, "Unable to create tuple dictionary.");
- SAVE_EXC();
- if (TRAP_EXC())
- {
- RESTORE_EXC();
- Py_DECREF(dict);
-
- RERAISE_EXC();
- }
-
- for (i = 0; i < info->in.r.natts; i++)
- {
- char *key, *vsrc;
- Datum vattr, vdat;
- bool is_null;
- PyObject *value;
+ SAVE_EXC();
+ if (TRAP_EXC())
+ {
+ RESTORE_EXC();
+ Py_DECREF(dict);
- key = NameStr(desc->attrs[i]->attname);
- vattr = heap_getattr(tuple, (i + 1), desc, &is_null);
+ RERAISE_EXC();
+ }
- if ((is_null) || (info->in.r.atts[i].func == NULL))
- PyDict_SetItemString(dict, key, Py_None);
- else
+ for (i = 0; i < info->in.r.natts; i++)
{
- vdat = FunctionCall3(&info->in.r.atts[i].typfunc,
- vattr,
- ObjectIdGetDatum(info->in.r.atts[i].typelem),
- Int32GetDatum(desc->attrs[i]->atttypmod));
- vsrc = DatumGetCString(vdat);
-
- /* no exceptions allowed
- */
- value = info->in.r.atts[i].func (vsrc);
- pfree(vsrc);
- PyDict_SetItemString(dict, key, value);
- Py_DECREF(value);
+ char *key,
+ *vsrc;
+ Datum vattr,
+ vdat;
+ bool is_null;
+ PyObject *value;
+
+ key = NameStr(desc->attrs[i]->attname);
+ vattr = heap_getattr(tuple, (i + 1), desc, &is_null);
+
+ if ((is_null) || (info->in.r.atts[i].func == NULL))
+ PyDict_SetItemString(dict, key, Py_None);
+ else
+ {
+ vdat = FunctionCall3(&info->in.r.atts[i].typfunc,
+ vattr,
+ ObjectIdGetDatum(info->in.r.atts[i].typelem),
+ Int32GetDatum(desc->attrs[i]->atttypmod));
+ vsrc = DatumGetCString(vdat);
+
+ /*
+ * no exceptions allowed
+ */
+ value = info->in.r.atts[i].func(vsrc);
+ pfree(vsrc);
+ PyDict_SetItemString(dict, key, value);
+ Py_DECREF(value);
+ }
}
- }
-
- RESTORE_EXC();
- return dict;
+ RESTORE_EXC();
+
+ return dict;
}
/* initialization, some python variables function declared here
static PyObject *PLy_result_fetch(PyObject *, PyObject *);
static PyObject *PLy_result_nrows(PyObject *, PyObject *);
static PyObject *PLy_result_status(PyObject *, PyObject *);
-static int PLy_result_length(PyObject *);
+static int PLy_result_length(PyObject *);
static PyObject *PLy_result_item(PyObject *, int);
static PyObject *PLy_result_slice(PyObject *, int, int);
-static int PLy_result_ass_item(PyObject *, int, PyObject *);
-static int PLy_result_ass_slice(PyObject *, int, int, PyObject *);
+static int PLy_result_ass_item(PyObject *, int, PyObject *);
+static int PLy_result_ass_slice(PyObject *, int, int, PyObject *);
static PyObject *PLy_spi_prepare(PyObject *, PyObject *);
PyTypeObject PLy_PlanType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "PLyPlan", /*tp_name*/
- sizeof(PLyPlanObject), /*tp_size*/
- 0, /*tp_itemsize*/
- /* methods
- */
- (destructor) PLy_plan_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- (getattrfunc)PLy_plan_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- 0, /*tp_xxx4*/
- PLy_plan_doc, /*tp_doc*/
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "PLyPlan", /* tp_name */
+ sizeof(PLyPlanObject), /* tp_size */
+ 0, /* tp_itemsize */
+
+ /*
+ * methods
+ */
+ (destructor) PLy_plan_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ (getattrfunc) PLy_plan_getattr, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ 0, /* tp_xxx4 */
+ PLy_plan_doc, /* tp_doc */
};
PyMethodDef PLy_plan_methods[] = {
- { "status", (PyCFunction) PLy_plan_status, METH_VARARGS, NULL },
- { NULL, NULL, 0, NULL }
+ {"status", (PyCFunction) PLy_plan_status, METH_VARARGS, NULL},
+ {NULL, NULL, 0, NULL}
};
PySequenceMethods PLy_result_as_sequence = {
- (inquiry) PLy_result_length, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) PLy_result_item, /* sq_item */
- (intintargfunc) PLy_result_slice, /* sq_slice */
- (intobjargproc) PLy_result_ass_item, /* sq_ass_item */
- (intintobjargproc) PLy_result_ass_slice, /* sq_ass_slice */
+ (inquiry) PLy_result_length,/* sq_length */
+ (binaryfunc) 0, /* sq_concat */
+ (intargfunc) 0, /* sq_repeat */
+ (intargfunc) PLy_result_item, /* sq_item */
+ (intintargfunc) PLy_result_slice, /* sq_slice */
+ (intobjargproc) PLy_result_ass_item, /* sq_ass_item */
+ (intintobjargproc) PLy_result_ass_slice, /* sq_ass_slice */
};
PyTypeObject PLy_ResultType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "PLyResult", /*tp_name*/
- sizeof(PLyResultObject), /*tp_size*/
- 0, /*tp_itemsize*/
- /* methods
- */
- (destructor) PLy_result_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- (getattrfunc) PLy_result_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- &PLy_result_as_sequence, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- 0, /*tp_xxx4*/
- PLy_result_doc, /*tp_doc*/
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "PLyResult", /* tp_name */
+ sizeof(PLyResultObject), /* tp_size */
+ 0, /* tp_itemsize */
+
+ /*
+ * methods
+ */
+ (destructor) PLy_result_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ (getattrfunc) PLy_result_getattr, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ &PLy_result_as_sequence, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ 0, /* tp_xxx4 */
+ PLy_result_doc, /* tp_doc */
};
PyMethodDef PLy_result_methods[] = {
- { "fetch", (PyCFunction) PLy_result_fetch, METH_VARARGS, NULL,},
- { "nrows", (PyCFunction) PLy_result_nrows, METH_VARARGS, NULL },
- { "status", (PyCFunction) PLy_result_status, METH_VARARGS, NULL },
- { NULL, NULL, 0, NULL }
+ {"fetch", (PyCFunction) PLy_result_fetch, METH_VARARGS, NULL,},
+ {"nrows", (PyCFunction) PLy_result_nrows, METH_VARARGS, NULL},
+ {"status", (PyCFunction) PLy_result_status, METH_VARARGS, NULL},
+ {NULL, NULL, 0, NULL}
};
static PyMethodDef PLy_methods[] = {
- /* logging methods
- */
- { "debug", PLy_debug, METH_VARARGS, NULL },
- { "error", PLy_error, METH_VARARGS, NULL },
- { "fatal", PLy_fatal, METH_VARARGS, NULL },
- { "notice", PLy_notice, METH_VARARGS, NULL },
-
- /* create a stored plan
- */
- { "prepare", PLy_spi_prepare, METH_VARARGS, NULL },
-
- /* execute a plan or query
- */
- { "execute", PLy_spi_execute, METH_VARARGS, NULL },
-
- { NULL, NULL, 0, NULL }
+ /*
+ * logging methods
+ */
+ {"debug", PLy_debug, METH_VARARGS, NULL},
+ {"error", PLy_error, METH_VARARGS, NULL},
+ {"fatal", PLy_fatal, METH_VARARGS, NULL},
+ {"notice", PLy_notice, METH_VARARGS, NULL},
+
+ /*
+ * create a stored plan
+ */
+ {"prepare", PLy_spi_prepare, METH_VARARGS, NULL},
+
+ /*
+ * execute a plan or query
+ */
+ {"execute", PLy_spi_execute, METH_VARARGS, NULL},
+
+ {NULL, NULL, 0, NULL}
};
PyObject *
PLy_plan_new(void)
{
- PLyPlanObject *ob;
-
- enter();
+ PLyPlanObject *ob;
- if ((ob = PyObject_NEW(PLyPlanObject, &PLy_PlanType)) == NULL)
- return NULL;
+ enter();
- ob->plan = NULL;
- ob->nargs = 0;
- ob->types = NULL;
- ob->args = NULL;
+ if ((ob = PyObject_NEW(PLyPlanObject, &PLy_PlanType)) == NULL)
+ return NULL;
- return (PyObject *) ob;
+ ob->plan = NULL;
+ ob->nargs = 0;
+ ob->types = NULL;
+ ob->args = NULL;
+
+ return (PyObject *) ob;
}
void
-PLy_plan_dealloc(PyObject *arg)
+PLy_plan_dealloc(PyObject * arg)
{
- PLyPlanObject *ob = (PLyPlanObject *) arg;
+ PLyPlanObject *ob = (PLyPlanObject *) arg;
- enter();
+ enter();
- if (ob->plan)
- {
- /* free the plan...
- * pfree(ob->plan);
- *
- * FIXME -- leaks saved plan on object destruction. can
- * this be avoided?
- */
- }
- if (ob->types)
- PLy_free(ob->types);
- if (ob->args)
- {
- int i;
+ if (ob->plan)
+ {
+ /*
+ * free the plan... pfree(ob->plan);
+ *
+ * FIXME -- leaks saved plan on object destruction. can this be
+ * avoided?
+ */
+ }
+ if (ob->types)
+ PLy_free(ob->types);
+ if (ob->args)
+ {
+ int i;
- for (i = 0; i < ob->nargs; i++)
- PLy_typeinfo_dealloc(&ob->args[i]);
- PLy_free(ob->args);
- }
+ for (i = 0; i < ob->nargs; i++)
+ PLy_typeinfo_dealloc(&ob->args[i]);
+ PLy_free(ob->args);
+ }
- PyMem_DEL(arg);
+ PyMem_DEL(arg);
- leave();
+ leave();
}
PyObject *
-PLy_plan_getattr(PyObject *self, char *name)
+PLy_plan_getattr(PyObject * self, char *name)
{
- return Py_FindMethod(PLy_plan_methods, self, name);
+ return Py_FindMethod(PLy_plan_methods, self, name);
}
PyObject *
-PLy_plan_status(PyObject *self, PyObject *args)
+PLy_plan_status(PyObject * self, PyObject * args)
{
- if (PyArg_ParseTuple(args, ""))
- {
- Py_INCREF(Py_True);
- return Py_True;
- /* return PyInt_FromLong(self->status); */
- }
- PyErr_SetString(PLy_exc_error, "plan.status() takes no arguments");
- return NULL;
+ if (PyArg_ParseTuple(args, ""))
+ {
+ Py_INCREF(Py_True);
+ return Py_True;
+ /* return PyInt_FromLong(self->status); */
+ }
+ PyErr_SetString(PLy_exc_error, "plan.status() takes no arguments");
+ return NULL;
}
static PyObject *
PLy_result_new(void)
{
- PLyResultObject *ob;
-
- enter();
+ PLyResultObject *ob;
+
+ enter();
- if ((ob = PyObject_NEW(PLyResultObject, &PLy_ResultType)) == NULL)
- return NULL;
+ if ((ob = PyObject_NEW(PLyResultObject, &PLy_ResultType)) == NULL)
+ return NULL;
- /* ob->tuples = NULL; */
+ /* ob->tuples = NULL; */
- Py_INCREF(Py_None);
- ob->status = Py_None;
- ob->nrows = PyInt_FromLong(-1);
- ob->rows = PyList_New(0);
+ Py_INCREF(Py_None);
+ ob->status = Py_None;
+ ob->nrows = PyInt_FromLong(-1);
+ ob->rows = PyList_New(0);
- return (PyObject *) ob;
+ return (PyObject *) ob;
}
static void
-PLy_result_dealloc(PyObject *arg)
+PLy_result_dealloc(PyObject * arg)
{
- PLyResultObject *ob = (PLyResultObject *) arg;
+ PLyResultObject *ob = (PLyResultObject *) arg;
- enter();
+ enter();
- Py_XDECREF(ob->nrows);
- Py_XDECREF(ob->rows);
- Py_XDECREF(ob->status);
+ Py_XDECREF(ob->nrows);
+ Py_XDECREF(ob->rows);
+ Py_XDECREF(ob->status);
- PyMem_DEL(ob);
+ PyMem_DEL(ob);
}
static PyObject *
-PLy_result_getattr(PyObject *self, char *attr)
+PLy_result_getattr(PyObject * self, char *attr)
{
- return NULL;
+ return NULL;
}
static PyObject *
-PLy_result_fetch(PyObject *self, PyObject *args)
+PLy_result_fetch(PyObject * self, PyObject * args)
{
- return NULL;
+ return NULL;
}
static PyObject *
-PLy_result_nrows(PyObject *self, PyObject *args)
+PLy_result_nrows(PyObject * self, PyObject * args)
{
- PLyResultObject *ob = (PLyResultObject *) self;
- Py_INCREF(ob->nrows);
- return ob->nrows;
+ PLyResultObject *ob = (PLyResultObject *) self;
+
+ Py_INCREF(ob->nrows);
+ return ob->nrows;
}
static PyObject *
-PLy_result_status(PyObject *self, PyObject *args)
+PLy_result_status(PyObject * self, PyObject * args)
{
- PLyResultObject *ob = (PLyResultObject *) self;
- Py_INCREF(ob->status);
- return ob->status;
+ PLyResultObject *ob = (PLyResultObject *) self;
+
+ Py_INCREF(ob->status);
+ return ob->status;
}
int
-PLy_result_length(PyObject *arg)
+PLy_result_length(PyObject * arg)
{
- PLyResultObject *ob = (PLyResultObject *) arg;
- return PyList_Size(ob->rows);
+ PLyResultObject *ob = (PLyResultObject *) arg;
+
+ return PyList_Size(ob->rows);
}
PyObject *
-PLy_result_item(PyObject *arg, int idx)
+PLy_result_item(PyObject * arg, int idx)
{
- PyObject *rv;
- PLyResultObject *ob = (PLyResultObject *) arg;
+ PyObject *rv;
+ PLyResultObject *ob = (PLyResultObject *) arg;
- rv = PyList_GetItem(ob->rows, idx);
- if (rv != NULL)
- Py_INCREF(rv);
- return rv;
+ rv = PyList_GetItem(ob->rows, idx);
+ if (rv != NULL)
+ Py_INCREF(rv);
+ return rv;
}
int
-PLy_result_ass_item(PyObject *arg, int idx, PyObject *item)
+PLy_result_ass_item(PyObject * arg, int idx, PyObject * item)
{
- int rv;
- PLyResultObject *ob = (PLyResultObject *) arg;
+ int rv;
+ PLyResultObject *ob = (PLyResultObject *) arg;
- Py_INCREF(item);
- rv = PyList_SetItem(ob->rows, idx, item);
- return rv;
+ Py_INCREF(item);
+ rv = PyList_SetItem(ob->rows, idx, item);
+ return rv;
}
PyObject *
-PLy_result_slice(PyObject *arg, int lidx, int hidx)
+PLy_result_slice(PyObject * arg, int lidx, int hidx)
{
- PyObject *rv;
- PLyResultObject *ob = (PLyResultObject *) arg;
-
- rv = PyList_GetSlice(ob->rows, lidx, hidx);
- if (rv == NULL)
- return NULL;
- Py_INCREF(rv);
- return rv;
+ PyObject *rv;
+ PLyResultObject *ob = (PLyResultObject *) arg;
+
+ rv = PyList_GetSlice(ob->rows, lidx, hidx);
+ if (rv == NULL)
+ return NULL;
+ Py_INCREF(rv);
+ return rv;
}
int
-PLy_result_ass_slice(PyObject *arg, int lidx, int hidx, PyObject *slice)
+PLy_result_ass_slice(PyObject * arg, int lidx, int hidx, PyObject * slice)
{
- int rv;
- PLyResultObject *ob = (PLyResultObject *) arg;
-
- rv = PyList_SetSlice(ob->rows, lidx, hidx, slice);
- return rv;
+ int rv;
+ PLyResultObject *ob = (PLyResultObject *) arg;
+
+ rv = PyList_SetSlice(ob->rows, lidx, hidx, slice);
+ return rv;
}
/* SPI interface
*/
PyObject *
-PLy_spi_prepare(PyObject *self, PyObject *args)
-{
- DECLARE_EXC();
- PLyPlanObject *plan;
- PyObject *list = NULL;
- PyObject * volatile optr = NULL;
- char *query;
-
- enter();
-
- if (!PyArg_ParseTuple(args, "s|O", &query, &list))
- {
- PyErr_SetString(PLy_exc_spi_error,
- "Invalid arguments for plpy.prepare()");
- return NULL;
- }
-
- if ((list) && (!PySequence_Check(list)))
- {
- PyErr_SetString(PLy_exc_spi_error,
- "Second argument in plpy.prepare() must be a sequence");
- return NULL;
- }
-
-
- if ((plan = (PLyPlanObject *) PLy_plan_new()) == NULL)
- return NULL;
-
- SAVE_EXC();
- if (TRAP_EXC())
- {
- RESTORE_EXC();
- Py_DECREF(plan);
- Py_XDECREF(optr);
- if (!PyErr_Occurred ())
- PyErr_SetString(PLy_exc_spi_error,
- "Unknown error in PLy_spi_prepare.");
- return NULL;
- }
-
- if (list != NULL)
- {
- int nargs, i;
-
-
- nargs = PySequence_Length(list);
- if (nargs > 0)
- {
- plan->nargs = nargs;
- plan->types = PLy_malloc(sizeof(Oid) * nargs);
- plan->values = PLy_malloc(sizeof(Datum) * nargs);
- plan->args = PLy_malloc(sizeof(PLyTypeInfo) * nargs);
-
- /* the other loop might throw an exception, if PLyTypeInfo
- * member isn't properly initialized the Py_DECREF(plan)
- * will go boom
- */
- for (i = 0; i < nargs; i++)
- {
- PLy_typeinfo_init(&plan->args[i]);
- plan->values[i] = (Datum) NULL;
- }
-
- for (i = 0; i < nargs; i++)
- {
- char *sptr;
- HeapTuple typeTup;
- Form_pg_type typeStruct;
-
- optr = PySequence_GetItem(list, i);
- if (!PyString_Check(optr))
- {
- PyErr_SetString(PLy_exc_spi_error,
- "Type names must be strings.");
- RAISE_EXC(1);
- }
- sptr = PyString_AsString(optr);
- typeTup = SearchSysCache(TYPENAME, PointerGetDatum(sptr),
- 0, 0, 0);
- if (!HeapTupleIsValid(typeTup))
- {
- PLy_exception_set(PLy_exc_spi_error,
- "Cache lookup for type `%s' failed.",
- sptr);
- RAISE_EXC(1);
- }
+PLy_spi_prepare(PyObject * self, PyObject * args)
+{
+ DECLARE_EXC();
+ PLyPlanObject *plan;
+ PyObject *list = NULL;
+ PyObject *volatile optr = NULL;
+ char *query;
- Py_DECREF(optr);
- optr = NULL; /* this is important */
+ enter();
- plan->types[i] = typeTup->t_data->t_oid;
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
- if (typeStruct->typrelid == InvalidOid)
- PLy_output_datum_func(&plan->args[i], typeStruct);
- else
+ if (!PyArg_ParseTuple(args, "s|O", &query, &list))
+ {
+ PyErr_SetString(PLy_exc_spi_error,
+ "Invalid arguments for plpy.prepare()");
+ return NULL;
+ }
+
+ if ((list) && (!PySequence_Check(list)))
+ {
+ PyErr_SetString(PLy_exc_spi_error,
+ "Second argument in plpy.prepare() must be a sequence");
+ return NULL;
+ }
+
+
+ if ((plan = (PLyPlanObject *) PLy_plan_new()) == NULL)
+ return NULL;
+
+ SAVE_EXC();
+ if (TRAP_EXC())
+ {
+ RESTORE_EXC();
+ Py_DECREF(plan);
+ Py_XDECREF(optr);
+ if (!PyErr_Occurred())
+ PyErr_SetString(PLy_exc_spi_error,
+ "Unknown error in PLy_spi_prepare.");
+ return NULL;
+ }
+
+ if (list != NULL)
+ {
+ int nargs,
+ i;
+
+
+ nargs = PySequence_Length(list);
+ if (nargs > 0)
{
- PyErr_SetString(PLy_exc_spi_error,
- "tuples not handled in plpy.prepare, yet.");
- RAISE_EXC(1);
+ plan->nargs = nargs;
+ plan->types = PLy_malloc(sizeof(Oid) * nargs);
+ plan->values = PLy_malloc(sizeof(Datum) * nargs);
+ plan->args = PLy_malloc(sizeof(PLyTypeInfo) * nargs);
+
+ /*
+ * the other loop might throw an exception, if PLyTypeInfo
+ * member isn't properly initialized the Py_DECREF(plan) will
+ * go boom
+ */
+ for (i = 0; i < nargs; i++)
+ {
+ PLy_typeinfo_init(&plan->args[i]);
+ plan->values[i] = (Datum) NULL;
+ }
+
+ for (i = 0; i < nargs; i++)
+ {
+ char *sptr;
+ HeapTuple typeTup;
+ Form_pg_type typeStruct;
+
+ optr = PySequence_GetItem(list, i);
+ if (!PyString_Check(optr))
+ {
+ PyErr_SetString(PLy_exc_spi_error,
+ "Type names must be strings.");
+ RAISE_EXC(1);
+ }
+ sptr = PyString_AsString(optr);
+ typeTup = SearchSysCache(TYPENAME, PointerGetDatum(sptr),
+ 0, 0, 0);
+ if (!HeapTupleIsValid(typeTup))
+ {
+ PLy_exception_set(PLy_exc_spi_error,
+ "Cache lookup for type `%s' failed.",
+ sptr);
+ RAISE_EXC(1);
+ }
+
+ Py_DECREF(optr);
+ optr = NULL; /* this is important */
+
+ plan->types[i] = typeTup->t_data->t_oid;
+ typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ if (typeStruct->typrelid == InvalidOid)
+ PLy_output_datum_func(&plan->args[i], typeStruct);
+ else
+ {
+ PyErr_SetString(PLy_exc_spi_error,
+ "tuples not handled in plpy.prepare, yet.");
+ RAISE_EXC(1);
+ }
+ ReleaseSysCache(typeTup);
+ }
}
- ReleaseSysCache(typeTup);
- }
}
- }
- plan->plan = SPI_prepare(query, plan->nargs, plan->types);
- if (plan->plan == NULL)
- {
- PLy_exception_set(PLy_exc_spi_error,
- "Unable to prepare plan. SPI_prepare failed -- %s.",
- PLy_spi_error_string(SPI_result));
- RAISE_EXC(1);
- }
+ plan->plan = SPI_prepare(query, plan->nargs, plan->types);
+ if (plan->plan == NULL)
+ {
+ PLy_exception_set(PLy_exc_spi_error,
+ "Unable to prepare plan. SPI_prepare failed -- %s.",
+ PLy_spi_error_string(SPI_result));
+ RAISE_EXC(1);
+ }
- plan->plan = SPI_saveplan(plan->plan);
- if (plan->plan == NULL)
- {
- PLy_exception_set(PLy_exc_spi_error,
- "Unable to save plan. SPI_saveplan failed -- %s.",
- PLy_spi_error_string(SPI_result));
- RAISE_EXC(1);
- }
+ plan->plan = SPI_saveplan(plan->plan);
+ if (plan->plan == NULL)
+ {
+ PLy_exception_set(PLy_exc_spi_error,
+ "Unable to save plan. SPI_saveplan failed -- %s.",
+ PLy_spi_error_string(SPI_result));
+ RAISE_EXC(1);
+ }
- RESTORE_EXC();
+ RESTORE_EXC();
- return (PyObject *) plan;
+ return (PyObject *) plan;
}
/* execute(query="select * from foo", limit=5)
* execute(plan=plan, values=(foo, bar), limit=5)
*/
PyObject *
-PLy_spi_execute(PyObject *self, PyObject *args)
+PLy_spi_execute(PyObject * self, PyObject * args)
{
- char *query;
- PyObject *plan;
- PyObject *list = NULL;
- int limit = 0;
+ char *query;
+ PyObject *plan;
+ PyObject *list = NULL;
+ int limit = 0;
- enter();
+ enter();
#if 0
- /* there should - hahaha - be an python exception set so just
- * return NULL. FIXME -- is this needed?
- */
- if (PLy_restart_in_progress)
- return NULL;
+
+ /*
+ * there should - hahaha - be an python exception set so just return
+ * NULL. FIXME -- is this needed?
+ */
+ if (PLy_restart_in_progress)
+ return NULL;
#endif
- if (PyArg_ParseTuple(args, "s|i", &query, &limit))
- return PLy_spi_execute_query(query, limit);
+ if (PyArg_ParseTuple(args, "s|i", &query, &limit))
+ return PLy_spi_execute_query(query, limit);
- PyErr_Clear();
+ PyErr_Clear();
+
+ if ((PyArg_ParseTuple(args, "O|Oi", &plan, &list, &limit)) &&
+ (is_PLyPlanObject(plan)))
+ {
+ PyObject *rv = PLy_spi_execute_plan(plan, list, limit);
- if ((PyArg_ParseTuple(args, "O|Oi", &plan, &list, &limit)) &&
- (is_PLyPlanObject(plan)))
- {
- PyObject *rv = PLy_spi_execute_plan(plan, list, limit);
- return rv;
- }
+ return rv;
+ }
- PyErr_SetString(PLy_exc_error, "Expected a query or plan.");
- return NULL;
+ PyErr_SetString(PLy_exc_error, "Expected a query or plan.");
+ return NULL;
}
PyObject *
-PLy_spi_execute_plan(PyObject *ob, PyObject *list, int limit)
+PLy_spi_execute_plan(PyObject * ob, PyObject * list, int limit)
{
- DECLARE_EXC();
- volatile int nargs;
- int i, rv;
- PLyPlanObject *plan;
+ DECLARE_EXC();
+ volatile int nargs;
+ int i,
+ rv;
+ PLyPlanObject *plan;
- enter();
+ enter();
- if (list != NULL)
- {
- if ((!PySequence_Check(list)) || (PyString_Check(list)))
+ if (list != NULL)
{
- char *msg = "plpy.execute() takes a sequence as its second argument";
- PyErr_SetString(PLy_exc_spi_error, msg);
- return NULL;
- }
- nargs = PySequence_Length(list);
- }
- else
- nargs = 0;
+ if ((!PySequence_Check(list)) || (PyString_Check(list)))
+ {
+ char *msg = "plpy.execute() takes a sequence as its second argument";
- plan = (PLyPlanObject *) ob;
+ PyErr_SetString(PLy_exc_spi_error, msg);
+ return NULL;
+ }
+ nargs = PySequence_Length(list);
+ }
+ else
+ nargs = 0;
- if (nargs != plan->nargs)
- {
- char *sv;
+ plan = (PLyPlanObject *) ob;
- PyObject *so = PyObject_Str(list);
- sv = PyString_AsString(so);
- PLy_exception_set(PLy_exc_spi_error,
- "Expected sequence of %d arguments, got %d. %s",
- plan->nargs, nargs, sv);
- Py_DECREF(so);
+ if (nargs != plan->nargs)
+ {
+ char *sv;
- return NULL;
- }
+ PyObject *so = PyObject_Str(list);
- SAVE_EXC();
- if (TRAP_EXC())
- {
- RESTORE_EXC();
+ sv = PyString_AsString(so);
+ PLy_exception_set(PLy_exc_spi_error,
+ "Expected sequence of %d arguments, got %d. %s",
+ plan->nargs, nargs, sv);
+ Py_DECREF(so);
- /* cleanup plan->values array
- */
- for (i = 0; i < nargs; i++)
- {
- if (!plan->args[i].out.d.typbyval &&
- (plan->values[i] != (Datum) NULL))
- {
- pfree(DatumGetPointer(plan->values[i]));
- plan->values[i] = (Datum) NULL;
- }
+ return NULL;
}
- if (!PyErr_Occurred())
- PyErr_SetString(PLy_exc_error,
- "Unknown error in PLy_spi_execute_plan");
- return NULL;
- }
-
- if (nargs)
- {
- for (i = 0; i < nargs; i++)
+ SAVE_EXC();
+ if (TRAP_EXC())
{
- PyObject *elem, *so;
- char *sv;
+ RESTORE_EXC();
- elem = PySequence_GetItem(list, i);
- so = PyObject_Str(elem);
- sv = PyString_AsString(so);
+ /*
+ * cleanup plan->values array
+ */
+ for (i = 0; i < nargs; i++)
+ {
+ if (!plan->args[i].out.d.typbyval &&
+ (plan->values[i] != (Datum) NULL))
+ {
+ pfree(DatumGetPointer(plan->values[i]));
+ plan->values[i] = (Datum) NULL;
+ }
+ }
- /* FIXME -- if this can elog, we have leak
- */
- plan->values[i] = FunctionCall3(&(plan->args[i].out.d.typfunc),
- CStringGetDatum(sv),
- ObjectIdGetDatum(plan->args[i].out.d.typelem),
- Int32GetDatum(-1));
+ if (!PyErr_Occurred())
+ PyErr_SetString(PLy_exc_error,
+ "Unknown error in PLy_spi_execute_plan");
+ return NULL;
+ }
- Py_DECREF(so);
- Py_DECREF(elem);
+ if (nargs)
+ {
+ for (i = 0; i < nargs; i++)
+ {
+ PyObject *elem,
+ *so;
+ char *sv;
+
+ elem = PySequence_GetItem(list, i);
+ so = PyObject_Str(elem);
+ sv = PyString_AsString(so);
+
+ /*
+ * FIXME -- if this can elog, we have leak
+ */
+ plan->values[i] = FunctionCall3(&(plan->args[i].out.d.typfunc),
+ CStringGetDatum(sv),
+ ObjectIdGetDatum(plan->args[i].out.d.typelem),
+ Int32GetDatum(-1));
+
+ Py_DECREF(so);
+ Py_DECREF(elem);
+ }
}
- }
- rv = SPI_execp(plan->plan, plan->values, NULL, limit);
- RESTORE_EXC();
+ rv = SPI_execp(plan->plan, plan->values, NULL, limit);
+ RESTORE_EXC();
- for (i = 0; i < nargs; i++)
- {
- if (!plan->args[i].out.d.typbyval &&
- (plan->values[i] != (Datum) NULL))
+ for (i = 0; i < nargs; i++)
{
- pfree(DatumGetPointer(plan->values[i]));
- plan->values[i] = (Datum) NULL;
+ if (!plan->args[i].out.d.typbyval &&
+ (plan->values[i] != (Datum) NULL))
+ {
+ pfree(DatumGetPointer(plan->values[i]));
+ plan->values[i] = (Datum) NULL;
+ }
}
- }
- if (rv < 0)
- {
- PLy_exception_set(PLy_exc_spi_error,
- "Unable to execute plan. SPI_execp failed -- %s",
- PLy_spi_error_string(rv));
- return NULL;
- }
+ if (rv < 0)
+ {
+ PLy_exception_set(PLy_exc_spi_error,
+ "Unable to execute plan. SPI_execp failed -- %s",
+ PLy_spi_error_string(rv));
+ return NULL;
+ }
- return PLy_spi_execute_fetch_result(SPI_tuptable, SPI_processed, rv);
+ return PLy_spi_execute_fetch_result(SPI_tuptable, SPI_processed, rv);
}
PyObject *
PLy_spi_execute_query(char *query, int limit)
{
- DECLARE_EXC();
- int rv;
+ DECLARE_EXC();
+ int rv;
+
+ SAVE_EXC();
+ if (TRAP_EXC())
+ {
+ RESTORE_EXC();
- SAVE_EXC();
- if (TRAP_EXC())
- {
- RESTORE_EXC();
+ if ((!PLy_restart_in_progress) && (!PyErr_Occurred()))
+ PyErr_SetString(PLy_exc_spi_error,
+ "Unknown error in PLy_spi_execute_query.");
+ return NULL;
+ }
- if ((!PLy_restart_in_progress) && (!PyErr_Occurred()))
- PyErr_SetString(PLy_exc_spi_error,
- "Unknown error in PLy_spi_execute_query.");
- return NULL;
- }
-
- rv = SPI_exec(query, limit);
- RESTORE_EXC();
+ rv = SPI_exec(query, limit);
+ RESTORE_EXC();
- if (rv < 0)
- {
- PLy_exception_set(PLy_exc_spi_error,
- "Unable to execute query. SPI_exec failed -- %s",
- PLy_spi_error_string(rv));
- return NULL;
- }
+ if (rv < 0)
+ {
+ PLy_exception_set(PLy_exc_spi_error,
+ "Unable to execute query. SPI_exec failed -- %s",
+ PLy_spi_error_string(rv));
+ return NULL;
+ }
- return PLy_spi_execute_fetch_result(SPI_tuptable, SPI_processed, rv);
+ return PLy_spi_execute_fetch_result(SPI_tuptable, SPI_processed, rv);
}
PyObject *
PLy_spi_execute_fetch_result(SPITupleTable *tuptable, int rows, int status)
{
- PLyResultObject *result;
-
- enter();
-
- result = (PLyResultObject *) PLy_result_new();
- Py_DECREF(result->status);
- result->status = PyInt_FromLong(status);
+ PLyResultObject *result;
- if (status == SPI_OK_UTILITY)
- {
- Py_DECREF(result->nrows);
- result->nrows = PyInt_FromLong(0);
- }
- else if (status != SPI_OK_SELECT)
- {
- Py_DECREF(result->nrows);
- result->nrows = PyInt_FromLong(rows);
- }
- else
- {
- DECLARE_EXC();
- PLyTypeInfo args;
- int i;
+ enter();
- PLy_typeinfo_init(&args);
- Py_DECREF(result->nrows);
- result->nrows = PyInt_FromLong(rows);
+ result = (PLyResultObject *) PLy_result_new();
+ Py_DECREF(result->status);
+ result->status = PyInt_FromLong(status);
- SAVE_EXC();
- if (TRAP_EXC())
+ if (status == SPI_OK_UTILITY)
{
- RESTORE_EXC();
-
- if (!PyErr_Occurred())
- PyErr_SetString(PLy_exc_error,
- "Unknown error in PLy_spi_execute_fetch_result");
- Py_DECREF(result);
- PLy_typeinfo_dealloc(&args);
- return NULL;
+ Py_DECREF(result->nrows);
+ result->nrows = PyInt_FromLong(0);
+ }
+ else if (status != SPI_OK_SELECT)
+ {
+ Py_DECREF(result->nrows);
+ result->nrows = PyInt_FromLong(rows);
}
-
- if (rows)
+ else
{
- Py_DECREF(result->rows);
- result->rows = PyList_New(rows);
+ DECLARE_EXC();
+ PLyTypeInfo args;
+ int i;
+
+ PLy_typeinfo_init(&args);
+ Py_DECREF(result->nrows);
+ result->nrows = PyInt_FromLong(rows);
+
+ SAVE_EXC();
+ if (TRAP_EXC())
+ {
+ RESTORE_EXC();
+
+ if (!PyErr_Occurred())
+ PyErr_SetString(PLy_exc_error,
+ "Unknown error in PLy_spi_execute_fetch_result");
+ Py_DECREF(result);
+ PLy_typeinfo_dealloc(&args);
+ return NULL;
+ }
- PLy_input_tuple_funcs(&args, tuptable->tupdesc);
- for (i = 0; i < rows; i++)
- {
- PyObject *row = PLyDict_FromTuple(&args, tuptable->vals[i],
- tuptable->tupdesc);
- PyList_SetItem(result->rows, i, row);
- }
- PLy_typeinfo_dealloc(&args);
+ if (rows)
+ {
+ Py_DECREF(result->rows);
+ result->rows = PyList_New(rows);
+
+ PLy_input_tuple_funcs(&args, tuptable->tupdesc);
+ for (i = 0; i < rows; i++)
+ {
+ PyObject *row = PLyDict_FromTuple(&args, tuptable->vals[i],
+ tuptable->tupdesc);
+
+ PyList_SetItem(result->rows, i, row);
+ }
+ PLy_typeinfo_dealloc(&args);
+ }
+ RESTORE_EXC();
}
- RESTORE_EXC();
- }
- return (PyObject *) result;
+ return (PyObject *) result;
}
const char *
PLy_spi_error_string(int code)
{
- switch (code)
- {
- case SPI_ERROR_TYPUNKNOWN:
- return "SPI_ERROR_TYPUNKNOWN";
- case SPI_ERROR_NOOUTFUNC:
- return "SPI_ERROR_NOOUTFUNC";
- case SPI_ERROR_NOATTRIBUTE:
- return "SPI_ERROR_NOATTRIBUTE";
- case SPI_ERROR_TRANSACTION:
- return "SPI_ERROR_TRANSACTION";
- case SPI_ERROR_PARAM:
- return "SPI_ERROR_PARAM";
- case SPI_ERROR_ARGUMENT:
- return "SPI_ERROR_ARGUMENT";
- case SPI_ERROR_CURSOR:
- return "SPI_ERROR_CURSOR";
- case SPI_ERROR_UNCONNECTED:
- return "SPI_ERROR_UNCONNECTED";
- case SPI_ERROR_OPUNKNOWN:
- return "SPI_ERROR_OPUNKNOWN";
- case SPI_ERROR_COPY:
- return "SPI_ERROR_COPY";
- case SPI_ERROR_CONNECT:
- return "SPI_ERROR_CONNECT";
- }
- return "Unknown or Invalid code";
+ switch (code)
+ {
+ case SPI_ERROR_TYPUNKNOWN:
+ return "SPI_ERROR_TYPUNKNOWN";
+ case SPI_ERROR_NOOUTFUNC:
+ return "SPI_ERROR_NOOUTFUNC";
+ case SPI_ERROR_NOATTRIBUTE:
+ return "SPI_ERROR_NOATTRIBUTE";
+ case SPI_ERROR_TRANSACTION:
+ return "SPI_ERROR_TRANSACTION";
+ case SPI_ERROR_PARAM:
+ return "SPI_ERROR_PARAM";
+ case SPI_ERROR_ARGUMENT:
+ return "SPI_ERROR_ARGUMENT";
+ case SPI_ERROR_CURSOR:
+ return "SPI_ERROR_CURSOR";
+ case SPI_ERROR_UNCONNECTED:
+ return "SPI_ERROR_UNCONNECTED";
+ case SPI_ERROR_OPUNKNOWN:
+ return "SPI_ERROR_OPUNKNOWN";
+ case SPI_ERROR_COPY:
+ return "SPI_ERROR_COPY";
+ case SPI_ERROR_CONNECT:
+ return "SPI_ERROR_CONNECT";
+ }
+ return "Unknown or Invalid code";
}
/* language handler and interpreter initialization
*/
-void PLy_init_all(void)
+void
+PLy_init_all(void)
{
- static volatile int init_active = 0;
+ static volatile int init_active = 0;
- enter();
+ enter();
- if (init_active)
- elog(FATAL, "plpython: Initialization of language module failed.");
- init_active = 1;
+ if (init_active)
+ elog(FATAL, "plpython: Initialization of language module failed.");
+ init_active = 1;
- Py_Initialize();
- PLy_init_interp();
- PLy_init_plpy();
- PLy_init_safe_interp();
- if (PyErr_Occurred())
- PLy_elog(FATAL, "Untrapped error in initialization.");
- PLy_procedure_cache = PyDict_New();
- if (PLy_procedure_cache == NULL)
- PLy_elog(ERROR, "Unable to create procedure cache.");
+ Py_Initialize();
+ PLy_init_interp();
+ PLy_init_plpy();
+ PLy_init_safe_interp();
+ if (PyErr_Occurred())
+ PLy_elog(FATAL, "Untrapped error in initialization.");
+ PLy_procedure_cache = PyDict_New();
+ if (PLy_procedure_cache == NULL)
+ PLy_elog(ERROR, "Unable to create procedure cache.");
- PLy_first_call = 0;
+ PLy_first_call = 0;
- leave();
+ leave();
}
void
PLy_init_interp(void)
{
- PyObject *mainmod;
+ PyObject *mainmod;
- enter();
+ enter();
- mainmod = PyImport_AddModule("__main__");
- if ((mainmod == NULL) || (PyErr_Occurred()))
- PLy_elog(ERROR, "Unable to import '__main__' module.");
- Py_INCREF(mainmod);
- PLy_interp_globals = PyModule_GetDict(mainmod);
- Py_DECREF(mainmod);
- if ((PLy_interp_globals == NULL) || (PyErr_Occurred()))
- PLy_elog(ERROR, "Unable to initialize globals.");
+ mainmod = PyImport_AddModule("__main__");
+ if ((mainmod == NULL) || (PyErr_Occurred()))
+ PLy_elog(ERROR, "Unable to import '__main__' module.");
+ Py_INCREF(mainmod);
+ PLy_interp_globals = PyModule_GetDict(mainmod);
+ Py_DECREF(mainmod);
+ if ((PLy_interp_globals == NULL) || (PyErr_Occurred()))
+ PLy_elog(ERROR, "Unable to initialize globals.");
}
void
PLy_init_plpy(void)
{
- PyObject *main_mod, *main_dict, *plpy_mod;
- PyObject *plpy, *plpy_dict;
-
- enter();
-
- /* initialize plpy module
- */
- PLy_PlanType.ob_type = PLy_ResultType.ob_type = &PyType_Type;
- plpy = Py_InitModule("plpy", PLy_methods);
- plpy_dict = PyModule_GetDict(plpy);
-
- /* PyDict_SetItemString(plpy, "PlanType", (PyObject *) &PLy_PlanType); */
-
- PLy_exc_error = PyErr_NewException("plpy.Error", NULL, NULL);
- PLy_exc_fatal = PyErr_NewException("plpy.Fatal", NULL, NULL);
- PLy_exc_spi_error = PyErr_NewException("plpy.SPIError", NULL, NULL);
- PyDict_SetItemString(plpy_dict, "Error", PLy_exc_error);
- PyDict_SetItemString(plpy_dict, "Fatal", PLy_exc_fatal);
- PyDict_SetItemString(plpy_dict, "SPIError", PLy_exc_spi_error);
-
- /* initialize main module, and add plpy
- */
- main_mod = PyImport_AddModule("__main__");
- main_dict = PyModule_GetDict(main_mod);
- plpy_mod = PyImport_AddModule("plpy");
- PyDict_SetItemString(main_dict, "plpy", plpy_mod);
- if (PyErr_Occurred ())
- elog(ERROR, "Unable to init plpy.");
+ PyObject *main_mod,
+ *main_dict,
+ *plpy_mod;
+ PyObject *plpy,
+ *plpy_dict;
+
+ enter();
+
+ /*
+ * initialize plpy module
+ */
+ PLy_PlanType.ob_type = PLy_ResultType.ob_type = &PyType_Type;
+ plpy = Py_InitModule("plpy", PLy_methods);
+ plpy_dict = PyModule_GetDict(plpy);
+
+ /* PyDict_SetItemString(plpy, "PlanType", (PyObject *) &PLy_PlanType); */
+
+ PLy_exc_error = PyErr_NewException("plpy.Error", NULL, NULL);
+ PLy_exc_fatal = PyErr_NewException("plpy.Fatal", NULL, NULL);
+ PLy_exc_spi_error = PyErr_NewException("plpy.SPIError", NULL, NULL);
+ PyDict_SetItemString(plpy_dict, "Error", PLy_exc_error);
+ PyDict_SetItemString(plpy_dict, "Fatal", PLy_exc_fatal);
+ PyDict_SetItemString(plpy_dict, "SPIError", PLy_exc_spi_error);
+
+ /*
+ * initialize main module, and add plpy
+ */
+ main_mod = PyImport_AddModule("__main__");
+ main_dict = PyModule_GetDict(main_mod);
+ plpy_mod = PyImport_AddModule("plpy");
+ PyDict_SetItemString(main_dict, "plpy", plpy_mod);
+ if (PyErr_Occurred())
+ elog(ERROR, "Unable to init plpy.");
}
void
PLy_init_safe_interp(void)
{
- PyObject *rmod;
- char *rname = "rexec";
- int i, imax;
+ PyObject *rmod;
+ char *rname = "rexec";
+ int i,
+ imax;
- enter();
+ enter();
- rmod = PyImport_ImportModuleEx(rname, PLy_interp_globals,
- PLy_interp_globals, Py_None);
- if ((rmod == NULL) || (PyErr_Occurred ()))
- PLy_elog(ERROR, "Unable to import %s.", rname);
- PyDict_SetItemString(PLy_interp_globals, rname, rmod);
- PLy_interp_safe = rmod;
+ rmod = PyImport_ImportModuleEx(rname, PLy_interp_globals,
+ PLy_interp_globals, Py_None);
+ if ((rmod == NULL) || (PyErr_Occurred()))
+ PLy_elog(ERROR, "Unable to import %s.", rname);
+ PyDict_SetItemString(PLy_interp_globals, rname, rmod);
+ PLy_interp_safe = rmod;
- imax = sizeof(PLy_importable_modules_list) / sizeof(char *);
- PLy_importable_modules = PyTuple_New(imax);
- for (i = 0; i < imax; i++)
- {
- PyObject *m = PyString_FromString(PLy_importable_modules_list[i]);
- PyTuple_SetItem(PLy_importable_modules, i, m);
- }
+ imax = sizeof(PLy_importable_modules_list) / sizeof(char *);
+ PLy_importable_modules = PyTuple_New(imax);
+ for (i = 0; i < imax; i++)
+ {
+ PyObject *m = PyString_FromString(PLy_importable_modules_list[i]);
+
+ PyTuple_SetItem(PLy_importable_modules, i, m);
+ }
- PLy_interp_safe_globals = PyDict_New();
- if (PLy_interp_safe_globals == NULL)
- PLy_elog(ERROR, "Unable to create shared global dictionary.");
+ PLy_interp_safe_globals = PyDict_New();
+ if (PLy_interp_safe_globals == NULL)
+ PLy_elog(ERROR, "Unable to create shared global dictionary.");
}
static PyObject *PLy_log(int, PyObject *, PyObject *);
PyObject *
-PLy_debug(PyObject *self, PyObject *args)
+PLy_debug(PyObject * self, PyObject * args)
{
- return PLy_log(DEBUG, self, args);
+ return PLy_log(DEBUG, self, args);
}
PyObject *
-PLy_error(PyObject *self, PyObject *args)
+PLy_error(PyObject * self, PyObject * args)
{
- return PLy_log(ERROR, self, args);
+ return PLy_log(ERROR, self, args);
}
PyObject *
-PLy_fatal(PyObject *self, PyObject *args)
+PLy_fatal(PyObject * self, PyObject * args)
{
- return PLy_log(FATAL, self, args);
+ return PLy_log(FATAL, self, args);
}
PyObject *
-PLy_notice(PyObject *self, PyObject *args)
+PLy_notice(PyObject * self, PyObject * args)
{
- return PLy_log(NOTICE, self, args);
+ return PLy_log(NOTICE, self, args);
}
PyObject *
-PLy_log(volatile int level, PyObject *self, PyObject *args)
-{
- DECLARE_EXC();
- PyObject *so;
- char * volatile sv;
-
- enter();
-
- if (args == NULL)
- elog(NOTICE, "plpython, args is NULL in %s", __FUNCTION__);
-
- so = PyObject_Str(args);
- if ((so == NULL) || ((sv = PyString_AsString(so)) == NULL))
- {
- level = ERROR;
- sv = "Unable to parse error message in `plpy.elog'";
- }
-
- /* returning NULL here causes the python interpreter to bail.
- * when control passes back into plpython_*_handler, we
- * check for python exceptions and do the actual elog
- * call. actually PLy_elog.
- */
- if (level == ERROR)
- {
- PyErr_SetString(PLy_exc_error, sv);
- return NULL;
- }
- else if (level >= FATAL)
- {
- PyErr_SetString(PLy_exc_fatal, sv);
- return NULL;
- }
-
- /* ok, this is a NOTICE, or DEBUG message
- *
- * but just in case DON'T long jump out of the interpreter!
- */
- SAVE_EXC();
- if (TRAP_EXC())
- {
- RESTORE_EXC();
-
- Py_XDECREF(so);
-
- /* the real error message should already be written into
- * the postgresql log, no? whatever, this shouldn't happen
- * so die hideously.
- */
- elog(FATAL, "plpython: Aiieee, elog threw an unknown exception!");
- return NULL;
- }
-
- elog(level, sv);
-
- RESTORE_EXC();
-
- Py_XDECREF(so);
- Py_INCREF(Py_None);
-
- /* return a legal object so the interpreter will continue on its
- * merry way
- */
- return Py_None;
+PLy_log(volatile int level, PyObject * self, PyObject * args)
+{
+ DECLARE_EXC();
+ PyObject *so;
+ char *volatile sv;
+
+ enter();
+
+ if (args == NULL)
+ elog(NOTICE, "plpython, args is NULL in %s", __FUNCTION__);
+
+ so = PyObject_Str(args);
+ if ((so == NULL) || ((sv = PyString_AsString(so)) == NULL))
+ {
+ level = ERROR;
+ sv = "Unable to parse error message in `plpy.elog'";
+ }
+
+ /*
+ * returning NULL here causes the python interpreter to bail. when
+ * control passes back into plpython_*_handler, we check for python
+ * exceptions and do the actual elog call. actually PLy_elog.
+ */
+ if (level == ERROR)
+ {
+ PyErr_SetString(PLy_exc_error, sv);
+ return NULL;
+ }
+ else if (level >= FATAL)
+ {
+ PyErr_SetString(PLy_exc_fatal, sv);
+ return NULL;
+ }
+
+ /*
+ * ok, this is a NOTICE, or DEBUG message
+ *
+ * but just in case DON'T long jump out of the interpreter!
+ */
+ SAVE_EXC();
+ if (TRAP_EXC())
+ {
+ RESTORE_EXC();
+
+ Py_XDECREF(so);
+
+ /*
+ * the real error message should already be written into the
+ * postgresql log, no? whatever, this shouldn't happen so die
+ * hideously.
+ */
+ elog(FATAL, "plpython: Aiieee, elog threw an unknown exception!");
+ return NULL;
+ }
+
+ elog(level, sv);
+
+ RESTORE_EXC();
+
+ Py_XDECREF(so);
+ Py_INCREF(Py_None);
+
+ /*
+ * return a legal object so the interpreter will continue on its merry
+ * way
+ */
+ return Py_None;
}
static char *PLy_traceback(int *);
static char *PLy_vprintf(const char *fmt, va_list ap);
-static char *PLy_printf(const char *fmt, ...);
+static char *PLy_printf(const char *fmt,...);
void
-PLy_exception_set(PyObject *exc, const char *fmt, ...)
+PLy_exception_set(PyObject * exc, const char *fmt,...)
{
- char buf[1024];
- va_list ap;
+ char buf[1024];
+ va_list ap;
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
- PyErr_SetString(exc, buf);
+ PyErr_SetString(exc, buf);
}
void
PLy_elog(int elevel, const char *fmt,...)
{
- DECLARE_EXC();
- va_list ap;
- char *xmsg, *emsg;
- int xlevel;
+ DECLARE_EXC();
+ va_list ap;
+ char *xmsg,
+ *emsg;
+ int xlevel;
- enter();
+ enter();
- xmsg = PLy_traceback(&xlevel);
+ xmsg = PLy_traceback(&xlevel);
- va_start(ap, fmt);
- emsg = PLy_vprintf(fmt, ap);
- va_end(ap);
+ va_start(ap, fmt);
+ emsg = PLy_vprintf(fmt, ap);
+ va_end(ap);
- SAVE_EXC();
- if (TRAP_EXC())
- {
- RESTORE_EXC();
- mark();
- /* elog called siglongjmp. cleanup, restore and reraise
- */
- PLy_restart_in_progress += 1;
- PLy_free(emsg);
- PLy_free(xmsg);
- RERAISE_EXC();
- }
+ SAVE_EXC();
+ if (TRAP_EXC())
+ {
+ RESTORE_EXC();
+ mark();
+
+ /*
+ * elog called siglongjmp. cleanup, restore and reraise
+ */
+ PLy_restart_in_progress += 1;
+ PLy_free(emsg);
+ PLy_free(xmsg);
+ RERAISE_EXC();
+ }
- if (xmsg)
- {
- elog(elevel, "plpython: %s\n%s", emsg, xmsg);
- PLy_free(xmsg);
- }
- else
- elog(elevel, "plpython: %s", emsg);
- PLy_free(emsg);
+ if (xmsg)
+ {
+ elog(elevel, "plpython: %s\n%s", emsg, xmsg);
+ PLy_free(xmsg);
+ }
+ else
+ elog(elevel, "plpython: %s", emsg);
+ PLy_free(emsg);
- leave();
+ leave();
- RESTORE_EXC();
+ RESTORE_EXC();
}
char *
PLy_traceback(int *xlevel)
{
- PyObject *e, *v, *tb;
- PyObject *eob, *vob = NULL;
- char *vstr, *estr, *xstr = NULL;
-
- enter();
-
- /* get the current exception
- */
- PyErr_Fetch(&e, &v, &tb);
-
- /* oops, no exception, return
- */
- if (e == NULL)
- {
- *xlevel = NOTICE;
- return NULL;
- }
+ PyObject *e,
+ *v,
+ *tb;
+ PyObject *eob,
+ *vob = NULL;
+ char *vstr,
+ *estr,
+ *xstr = NULL;
+
+ enter();
+
+ /*
+ * get the current exception
+ */
+ PyErr_Fetch(&e, &v, &tb);
+
+ /*
+ * oops, no exception, return
+ */
+ if (e == NULL)
+ {
+ *xlevel = NOTICE;
+ return NULL;
+ }
- PyErr_NormalizeException(&e, &v, &tb);
+ PyErr_NormalizeException(&e, &v, &tb);
- eob = PyObject_Str(e);
- if ((v) && ((vob = PyObject_Str(v)) != NULL))
- vstr = PyString_AsString(vob);
- else
- vstr = "Unknown";
+ eob = PyObject_Str(e);
+ if ((v) && ((vob = PyObject_Str(v)) != NULL))
+ vstr = PyString_AsString(vob);
+ else
+ vstr = "Unknown";
- estr = PyString_AsString(eob);
- xstr = PLy_printf("%s: %s", estr, vstr);
+ estr = PyString_AsString(eob);
+ xstr = PLy_printf("%s: %s", estr, vstr);
- Py_DECREF(eob);
- Py_XDECREF(vob);
+ Py_DECREF(eob);
+ Py_XDECREF(vob);
- /* intuit an appropriate error level for based on the exception type
- */
- if ((PLy_exc_error) && (PyErr_GivenExceptionMatches(e, PLy_exc_error)))
- *xlevel = ERROR;
- else if ((PLy_exc_fatal) && (PyErr_GivenExceptionMatches(e, PLy_exc_fatal)))
- *xlevel = FATAL;
- else
- *xlevel = ERROR;
+ /*
+ * intuit an appropriate error level for based on the exception type
+ */
+ if ((PLy_exc_error) && (PyErr_GivenExceptionMatches(e, PLy_exc_error)))
+ *xlevel = ERROR;
+ else if ((PLy_exc_fatal) && (PyErr_GivenExceptionMatches(e, PLy_exc_fatal)))
+ *xlevel = FATAL;
+ else
+ *xlevel = ERROR;
- leave();
+ leave();
- return xstr;
+ return xstr;
}
char *
-PLy_printf(const char *fmt, ...)
+PLy_printf(const char *fmt,...)
{
- va_list ap;
- char *emsg;
+ va_list ap;
+ char *emsg;
- va_start(ap, fmt);
- emsg = PLy_vprintf(fmt, ap);
- va_end(ap);
- return emsg;
+ va_start(ap, fmt);
+ emsg = PLy_vprintf(fmt, ap);
+ va_end(ap);
+ return emsg;
}
char *
PLy_vprintf(const char *fmt, va_list ap)
{
- size_t blen;
- int bchar, tries = 2;
- char *buf;
-
- blen = strlen(fmt) * 2;
- if (blen < 256)
- blen = 256;
- buf = PLy_malloc(blen * sizeof(char));
-
- while (1)
- {
- bchar = vsnprintf(buf, blen, fmt, ap);
- if ((bchar > 0) && (bchar < blen))
- return buf;
- if (tries-- <= 0)
- break;
- if (blen > 0)
- blen = bchar + 1;
- else
- blen *= 2;
- buf = PLy_realloc(buf, blen);
- }
- PLy_free(buf);
- return NULL;
+ size_t blen;
+ int bchar,
+ tries = 2;
+ char *buf;
+
+ blen = strlen(fmt) * 2;
+ if (blen < 256)
+ blen = 256;
+ buf = PLy_malloc(blen * sizeof(char));
+
+ while (1)
+ {
+ bchar = vsnprintf(buf, blen, fmt, ap);
+ if ((bchar > 0) && (bchar < blen))
+ return buf;
+ if (tries-- <= 0)
+ break;
+ if (blen > 0)
+ blen = bchar + 1;
+ else
+ blen *= 2;
+ buf = PLy_realloc(buf, blen);
+ }
+ PLy_free(buf);
+ return NULL;
}
/* python module code
void *
PLy_malloc(size_t bytes)
{
- void *ptr = malloc(bytes);
- if (ptr == NULL)
- elog(FATAL, "plpython: Memory exhausted.");
- return ptr;
+ void *ptr = malloc(bytes);
+
+ if (ptr == NULL)
+ elog(FATAL, "plpython: Memory exhausted.");
+ return ptr;
}
void *
PLy_realloc(void *optr, size_t bytes)
{
- void *nptr = realloc(optr, bytes);
- if (nptr == NULL)
- elog(FATAL, "plpython: Memory exhausted.");
- return nptr;
+ void *nptr = realloc(optr, bytes);
+
+ if (nptr == NULL)
+ elog(FATAL, "plpython: Memory exhausted.");
+ return nptr;
}
/* define this away
void
PLy_free(void *ptr)
{
- free(ptr);
+ free(ptr);
}
-/* $Header: /cvsroot/pgsql/src/pl/plpython/Attic/plpython.h,v 1.2 2001/05/12 01:30:30 petere Exp $ */
+/* $Header: /cvsroot/pgsql/src/pl/plpython/Attic/plpython.h,v 1.3 2001/10/25 05:50:21 momjian Exp $ */
#ifndef PLPYTHON_H
#define PLPYTHON_H
#define TRAP_N_EXC(N) ((rv_##N = sigsetjmp(Warn_restart, 1)) != 0)
#if !DEBUG_EXC
-# define RESTORE_N_EXC(N) memcpy(&Warn_restart, &(buf_##N), sizeof(sigjmp_buf))
-# define SAVE_N_EXC(N) memcpy(&(buf_##N), &Warn_restart, sizeof(sigjmp_buf))
-# define RERAISE_N_EXC(N) siglongjmp(Warn_restart, rv_##N)
-# define RAISE_EXC(V) siglongjmp(Warn_restart, (V))
+#define RESTORE_N_EXC(N) memcpy(&Warn_restart, &(buf_##N), sizeof(sigjmp_buf))
+#define SAVE_N_EXC(N) memcpy(&(buf_##N), &Warn_restart, sizeof(sigjmp_buf))
+#define RERAISE_N_EXC(N) siglongjmp(Warn_restart, rv_##N)
+#define RAISE_EXC(V) siglongjmp(Warn_restart, (V))
#else
-# define RESTORE_N_EXC(N) do { \
+#define RESTORE_N_EXC(N) do { \
elog(NOTICE, "exception (%d,%d) restore at %s:%d",\
- PLy_call_level, exc_save_calls, __FUNCTION__, (__LINE__));\
+ PLy_call_level, exc_save_calls, __FUNCTION__, (__LINE__));\
exc_save_calls -= 1; \
memcpy(&Warn_restart, &(buf_##N), sizeof(sigjmp_buf)); } while (0)
-# define SAVE_N_EXC(N) do { \
+#define SAVE_N_EXC(N) do { \
exc_save_calls += 1; \
elog(NOTICE, "exception (%d,%d) save at %s:%d", \
- PLy_call_level, exc_save_calls, __FUNCTION__, (__LINE__)); \
+ PLy_call_level, exc_save_calls, __FUNCTION__, (__LINE__)); \
memcpy(&(buf_##N), &Warn_restart, sizeof(sigjmp_buf)); } while (0)
-# define RERAISE_N_EXC(N) do { \
+#define RERAISE_N_EXC(N) do { \
elog(NOTICE, "exception (%d,%d) reraise at %s:%d", \
PLy_call_level, exc_save_calls, __FUNCTION__, (__LINE__)); \
siglongjmp(Warn_restart, rv_##N); } while (0)
#define TRAP_EXC() TRAP_N_EXC(save_restart)
#if DEBUG_LEVEL
-# define CALL_LEVEL_INC() do { PLy_call_level += 1; \
- elog(NOTICE, "Level: %d", PLy_call_level); } while (0)
-# define CALL_LEVEL_DEC() do { elog(NOTICE, "Level: %d", PLy_call_level); \
- PLy_call_level -= 1; } while (0)
+#define CALL_LEVEL_INC() do { PLy_call_level += 1; \
+ elog(NOTICE, "Level: %d", PLy_call_level); } while (0)
+#define CALL_LEVEL_DEC() do { elog(NOTICE, "Level: %d", PLy_call_level); \
+ PLy_call_level -= 1; } while (0)
#else
-# define CALL_LEVEL_INC() do { PLy_call_level += 1; } while (0)
-# define CALL_LEVEL_DEC() do { PLy_call_level -= 1; } while (0)
+#define CALL_LEVEL_INC() do { PLy_call_level += 1; } while (0)
+#define CALL_LEVEL_DEC() do { PLy_call_level -= 1; } while (0)
#endif
/* temporary debugging macros
*/
#if DEBUG_LEVEL
-# define enter() elog(NOTICE, "Enter(%d): %s", func_enter_calls++,__FUNCTION__)
-# define leave() elog(NOTICE, "Leave(%d): %s", func_leave_calls++,__FUNCTION__)
-# define mark() elog(NOTICE, "Mark: %s:%d", __FUNCTION__, __LINE__);
-# define refc(O) elog(NOTICE, "Ref<%p>:<%d>:%s:%d", (O), (((O) == NULL) ? -1 : (O)->ob_refcnt), __FUNCTION__, __LINE__)
+#define enter() elog(NOTICE, "Enter(%d): %s", func_enter_calls++,__FUNCTION__)
+#define leave() elog(NOTICE, "Leave(%d): %s", func_leave_calls++,__FUNCTION__)
+#define mark() elog(NOTICE, "Mark: %s:%d", __FUNCTION__, __LINE__);
+#define refc(O) elog(NOTICE, "Ref<%p>:<%d>:%s:%d", (O), (((O) == NULL) ? -1 : (O)->ob_refcnt), __FUNCTION__, __LINE__)
#else
-# define enter()
-# define leave()
-# define mark()
-# define refc(O)
+#define enter()
+#define leave()
+#define mark()
+#define refc(O)
#endif
-
-#endif /* PLPYTHON_H */
+#endif /* PLPYTHON_H */
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.46 2001/10/19 19:43:19 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.47 2001/10/25 05:50:21 momjian Exp $
*
**********************************************************************/
static pg_enconv *tcl_enconv;
static unsigned char *
-utf_u2e(unsigned char *src) {
- return pg_do_encoding_conversion(src,strlen(src),
- NULL,tcl_enconv->from_unicode);
+utf_u2e(unsigned char *src)
+{
+ return pg_do_encoding_conversion(src, strlen(src),
+ NULL, tcl_enconv->from_unicode);
}
static unsigned char *
-utf_e2u(unsigned char *src) {
- return pg_do_encoding_conversion(src,strlen(src),
- tcl_enconv->to_unicode,NULL);
+utf_e2u(unsigned char *src)
+{
+ return pg_do_encoding_conversion(src, strlen(src),
+ tcl_enconv->to_unicode, NULL);
}
-# define PLTCL_UTF
-# define UTF_BEGIN do { \
+#define PLTCL_UTF
+#define UTF_BEGIN do { \
unsigned char *_pltcl_utf_src; \
unsigned char *_pltcl_utf_dst
-# define UTF_END if (_pltcl_utf_src!=_pltcl_utf_dst) \
+#define UTF_END if (_pltcl_utf_src!=_pltcl_utf_dst) \
pfree(_pltcl_utf_dst); } while (0)
-# define UTF_U2E(x) (_pltcl_utf_dst=utf_u2e(_pltcl_utf_src=(x)))
-# define UTF_E2U(x) (_pltcl_utf_dst=utf_e2u(_pltcl_utf_src=(x)))
-#else /* PLTCL_UTF */
-# define UTF_BEGIN
-# define UTF_END
-# define UTF_U2E(x) (x)
-# define UTF_E2U(x) (x)
-#endif /* PLTCL_UTF */
+#define UTF_U2E(x) (_pltcl_utf_dst=utf_u2e(_pltcl_utf_src=(x)))
+#define UTF_E2U(x) (_pltcl_utf_dst=utf_e2u(_pltcl_utf_src=(x)))
+#else /* PLTCL_UTF */
+#define UTF_BEGIN
+#define UTF_END
+#define UTF_U2E(x) (x)
+#define UTF_E2U(x) (x)
+#endif /* PLTCL_UTF */
/**********************************************************************
* The information we cache about loaded procedures
static void pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
Tcl_DString *retval);
static int pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp,
- int argc, char *argv[]);
+ int argc, char *argv[]);
/*
* This routine is a crock, and so is everyplace that calls it. The problem
* Do unicode conversion initialization
************************************************************/
- tcl_enconv=pg_get_enconv_by_encoding(GetDatabaseEncoding());
+ tcl_enconv = pg_get_enconv_by_encoding(GetDatabaseEncoding());
#endif
/************************************************************
pltcl_SPI_execp, NULL, NULL);
Tcl_CreateCommand(interp, "spi_lastoid",
pltcl_SPI_lastoid, NULL, NULL);
-
+
/************************************************************
* Try to load the unknown procedure from pltcl_modules
************************************************************/
pltcl_restart_in_progress = 0;
UTF_BEGIN;
elog(ERROR, "pltcl: %s\n%s", interp->result,
- UTF_U2E(Tcl_GetVar(interp,"errorInfo",
- TCL_GLOBAL_ONLY)));
+ UTF_U2E(Tcl_GetVar(interp, "errorInfo",
+ TCL_GLOBAL_ONLY)));
UTF_END;
}
if (--pltcl_call_level == 0)
pltcl_restart_in_progress = 0;
UTF_BEGIN;
elog(ERROR, "pltcl: %s\n%s", interp->result,
- UTF_U2E(Tcl_GetVar(interp,"errorInfo",
- TCL_GLOBAL_ONLY)));
+ UTF_U2E(Tcl_GetVar(interp, "errorInfo",
+ TCL_GLOBAL_ONLY)));
UTF_END;
}
if (--pltcl_call_level == 0)
if (!is_trigger)
{
typeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(procStruct->prorettype),
+ ObjectIdGetDatum(procStruct->prorettype),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
{
for (i = 0; i < prodesc->nargs; i++)
{
typeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(procStruct->proargtypes[i]),
+ ObjectIdGetDatum(procStruct->proargtypes[i]),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
{
/**********************************************************************
- * pltcl_SPI_lastoid() - return the last oid. To
- * be used after insert queries
+ * pltcl_SPI_lastoid() - return the last oid. To
+ * be used after insert queries
**********************************************************************/
static int
pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp,
int argc, char *argv[])
{
- char buf[64];
- sprintf(buf,"%u",SPI_lastoid);
+ char buf[64];
+
+ sprintf(buf, "%u", SPI_lastoid);
Tcl_SetResult(interp, buf, TCL_VOLATILE);
return TCL_OK;
}
outputstr = DatumGetCString(OidFunctionCall3(typoutput,
attr,
ObjectIdGetDatum(typelem),
- Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
+ Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
UTF_BEGIN;
Tcl_SetVar2(interp, *arrptr, *nameptr, UTF_E2U(outputstr), 0);
UTF_END;
outputstr = DatumGetCString(OidFunctionCall3(typoutput,
attr,
ObjectIdGetDatum(typelem),
- Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
+ Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
Tcl_DStringAppendElement(retval, attname);
UTF_BEGIN;
Tcl_DStringAppendElement(retval, UTF_E2U(outputstr));
#ifdef DEBUG
FILE *debug;
-
#endif /* DEBUG */
PGconn *conn;
void
describe_char(int c)
{
- unsigned char cp = c,
+ unsigned char cp = c,
up = toupper(c),
lo = tolower(c);
if (col_in_tab == tab_size)
{
-
/*
* Is the next character going to be a tab? Needed
* to do tab replacement in current spot if next
* Input/Output functions
*****************************************************************************/
-Complex *
+Complex *
complex_in(char *str)
{
double x,
* New Operators
*****************************************************************************/
-Complex *
+Complex *
complex_add(Complex * a, Complex * b)
{
Complex *result;
text *
copytext(text *t)
{
-
/*
* VARSIZE is the total size of the struct in bytes.
*/
DECLARE_CYGWIN_DLL(DllMain);
/* save hInstance from DllMain */
HINSTANCE __hDllInstance_base;
-
#endif /* __CYGWIN__ */
struct _reent *_impure_ptr;
}
return TRUE;
}
-
#endif /* CYGWIN_VERSION_DLL_MAJOR < 1001 */
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
-
#endif /* LIBC_SCCS and not lint */
#include
if ((optopt = (int) *place++) == (int) ':' ||
!(oli = strchr(ostr, optopt)))
{
-
/*
* if the user didn't specify '-' as an option, assume it means
* -1.