mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Add VARHDRSZ where needed. Many places just used 4.
This commit is contained in:
parent
1932d92161
commit
a68a132a6c
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.18 1997/09/12 04:07:12 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.19 1997/12/06 22:56:20 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -124,7 +124,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
|
|||||||
{
|
{
|
||||||
outputstr = fmgr(typoutput, attr,
|
outputstr = fmgr(typoutput, attr,
|
||||||
gettypelem(typeinfo->attrs[i]->atttypid));
|
gettypelem(typeinfo->attrs[i]->atttypid));
|
||||||
pq_putint(strlen(outputstr) + 4, 4);
|
pq_putint(strlen(outputstr) + VARHDRSZ, VARHDRSZ);
|
||||||
pq_putnchar(outputstr, strlen(outputstr));
|
pq_putnchar(outputstr, strlen(outputstr));
|
||||||
pfree(outputstr);
|
pfree(outputstr);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.24 1997/11/20 23:20:56 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.25 1997/12/06 22:56:24 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -619,7 +619,7 @@ Async_NotifyFrontEnd()
|
|||||||
if (whereToSendOutput == Remote)
|
if (whereToSendOutput == Remote)
|
||||||
{
|
{
|
||||||
pq_putnchar("A", 1);
|
pq_putnchar("A", 1);
|
||||||
pq_putint(ourpid, 4);
|
pq_putint(ourpid, sizeof(ourpid));
|
||||||
pq_putstr(DatumGetName(d)->data);
|
pq_putstr(DatumGetName(d)->data);
|
||||||
pq_flush();
|
pq_flush();
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ CreateTrigger(CreateTrigStmt * stmt)
|
|||||||
{
|
{
|
||||||
char *ar = (char *) lfirst(le);
|
char *ar = (char *) lfirst(le);
|
||||||
|
|
||||||
len += strlen(ar) + 4;
|
len += strlen(ar) + VARHDRSZ;
|
||||||
for (; *ar; ar++)
|
for (; *ar; ar++)
|
||||||
{
|
{
|
||||||
if (*ar == '\\')
|
if (*ar == '\\')
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.9 1997/11/10 05:15:49 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.10 1997/12/06 22:56:35 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -80,7 +80,7 @@ PQfn(int fnid,
|
|||||||
{
|
{
|
||||||
arg[i] = (char *) args[i].u.ptr;
|
arg[i] = (char *) args[i].u.ptr;
|
||||||
}
|
}
|
||||||
else if (args[i].len > 4)
|
else if (args[i].len > sizeof(int4))
|
||||||
{
|
{
|
||||||
elog(WARN, "arg_length of argument %d too long", i);
|
elog(WARN, "arg_length of argument %d too long", i);
|
||||||
}
|
}
|
||||||
@ -357,7 +357,7 @@ pqtest_PQfn(char *q)
|
|||||||
v = atoi(fields[j]);
|
v = atoi(fields[j]);
|
||||||
if (v != 0 || (v == 0 && fields[j][0] == '0'))
|
if (v != 0 || (v == 0 && fields[j][0] == '0'))
|
||||||
{
|
{
|
||||||
pqargs[k].len = 4;
|
pqargs[k].len = sizeof(int4);
|
||||||
pqargs[k].u.integer = v;
|
pqargs[k].u.integer = v;
|
||||||
printf("pqtest_PQfn: arg %d is int %d\n", k, v); /* debug */
|
printf("pqtest_PQfn: arg %d is int %d\n", k, v); /* debug */
|
||||||
}
|
}
|
||||||
@ -373,7 +373,7 @@ pqtest_PQfn(char *q)
|
|||||||
* call PQfn
|
* call PQfn
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
pqres = PQfn(f, &res, 4, 1, pqargs, i - 1);
|
pqres = PQfn(f, &res, sizeof(int4), 1, pqargs, i - 1);
|
||||||
printf("pqtest_PQfn: pqres is %s\n", pqres); /* debug */
|
printf("pqtest_PQfn: pqres is %s\n", pqres); /* debug */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.77 1997/12/04 23:07:23 thomas Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.78 1997/12/06 22:56:42 momjian Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -2660,7 +2660,7 @@ Character: character '(' Iconst ')'
|
|||||||
* between this and "text" is that we blank-pad and
|
* between this and "text" is that we blank-pad and
|
||||||
* truncate where necessary
|
* truncate where necessary
|
||||||
*/
|
*/
|
||||||
$$->typlen = 4 + $3;
|
$$->typlen = VARHDRSZ + $3;
|
||||||
}
|
}
|
||||||
| character
|
| character
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.14 1997/11/27 03:01:12 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.15 1997/12/06 22:57:02 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -192,9 +192,9 @@ NullCommand(CommandDest dest)
|
|||||||
nPtr = (PQNotifyList *) SLGetSucc(&nPtr->Node))
|
nPtr = (PQNotifyList *) SLGetSucc(&nPtr->Node))
|
||||||
{
|
{
|
||||||
pq_putnchar("A", 1);
|
pq_putnchar("A", 1);
|
||||||
pq_putint(0, 4);
|
pq_putint(0, sizeof(int4));
|
||||||
pq_putstr(nPtr->relname);
|
pq_putstr(nPtr->relname);
|
||||||
pq_putint(nPtr->be_pid, 4);
|
pq_putint(nPtr->be_pid, sizeof(nPtr->be_pid));
|
||||||
PQremoveNotify(nPtr);
|
PQremoveNotify(nPtr);
|
||||||
}
|
}
|
||||||
pq_flush();
|
pq_flush();
|
||||||
@ -283,8 +283,8 @@ BeginCommand(char *pname,
|
|||||||
{
|
{
|
||||||
pq_putstr(attrs[i]->attname.data); /* if 16 char name
|
pq_putstr(attrs[i]->attname.data); /* if 16 char name
|
||||||
* oops.. */
|
* oops.. */
|
||||||
pq_putint((int) attrs[i]->atttypid, 4);
|
pq_putint((int) attrs[i]->atttypid, sizeof(attrs[i]->atttypid));
|
||||||
pq_putint(attrs[i]->attlen, 2);
|
pq_putint(attrs[i]->attlen, sizeof(attrs[i]->attlen));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.7 1997/09/18 20:21:58 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.8 1997/12/06 22:57:03 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* This cruft is the server side of PQfn.
|
* This cruft is the server side of PQfn.
|
||||||
@ -101,7 +101,7 @@ SendFunctionResult(Oid fid, /* function id */
|
|||||||
{ /* by-reference ... */
|
{ /* by-reference ... */
|
||||||
if (retlen < 0)
|
if (retlen < 0)
|
||||||
{ /* ... varlena */
|
{ /* ... varlena */
|
||||||
pq_putint(VARSIZE(retval) - VARHDRSZ, 4);
|
pq_putint(VARSIZE(retval) - VARHDRSZ, VARHDRSZ);
|
||||||
pq_putnchar(VARDATA(retval), VARSIZE(retval) - VARHDRSZ);
|
pq_putnchar(VARDATA(retval), VARSIZE(retval) - VARHDRSZ);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.20 1997/09/18 20:22:10 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.21 1997/12/06 22:57:10 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -649,7 +649,7 @@ array_out(ArrayType *v, Oid element_type)
|
|||||||
|
|
||||||
/* get a wide string to print to */
|
/* get a wide string to print to */
|
||||||
p = array_dims(v, &dummy_bool);
|
p = array_dims(v, &dummy_bool);
|
||||||
nbytes = strlen(ARR_DATA_PTR(v)) + 4 + *(int *) p;
|
nbytes = strlen(ARR_DATA_PTR(v)) + VARHDRSZ + *(int *) p;
|
||||||
|
|
||||||
save_p = (char *) palloc(nbytes);
|
save_p = (char *) palloc(nbytes);
|
||||||
|
|
||||||
@ -787,18 +787,18 @@ array_dims(ArrayType *v, bool *isNull)
|
|||||||
/*
|
/*
|
||||||
* 33 since we assume 15 digits per number + ':' +'[]'
|
* 33 since we assume 15 digits per number + ':' +'[]'
|
||||||
*/
|
*/
|
||||||
save_p = p = (char *) palloc(nbytes + 4);
|
save_p = p = (char *) palloc(nbytes + VARHDRSZ);
|
||||||
MemSet(save_p, 0, nbytes + 4);
|
MemSet(save_p, 0, nbytes + VARHDRSZ);
|
||||||
dimv = ARR_DIMS(v);
|
dimv = ARR_DIMS(v);
|
||||||
lb = ARR_LBOUND(v);
|
lb = ARR_LBOUND(v);
|
||||||
p += 4;
|
p += VARHDRSZ;
|
||||||
for (i = 0; i < ARR_NDIM(v); i++)
|
for (i = 0; i < ARR_NDIM(v); i++)
|
||||||
{
|
{
|
||||||
sprintf(p, "[%d:%d]", lb[i], dimv[i] + lb[i] - 1);
|
sprintf(p, "[%d:%d]", lb[i], dimv[i] + lb[i] - 1);
|
||||||
p += strlen(p);
|
p += strlen(p);
|
||||||
}
|
}
|
||||||
nbytes = strlen(save_p + 4) + 4;
|
nbytes = strlen(save_p + VARHDRSZ) + VARHDRSZ;
|
||||||
memmove(save_p, &nbytes, 4);
|
memmove(save_p, &nbytes, VARHDRSZ);
|
||||||
return (save_p);
|
return (save_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -874,7 +874,7 @@ array_ref(ArrayType *array,
|
|||||||
}
|
}
|
||||||
if (*isNull)
|
if (*isNull)
|
||||||
RETURN_NULL;
|
RETURN_NULL;
|
||||||
if (VARSIZE(v) - 4 < elmlen)
|
if (VARSIZE(v) - VARHDRSZ < elmlen)
|
||||||
RETURN_NULL;
|
RETURN_NULL;
|
||||||
lo_close(fd);
|
lo_close(fd);
|
||||||
retval = (char *) _ArrayCast((char *) VARDATA(v), reftype, elmlen);
|
retval = (char *) _ArrayCast((char *) VARDATA(v), reftype, elmlen);
|
||||||
@ -1000,22 +1000,22 @@ array_clip(ArrayType *array,
|
|||||||
{
|
{
|
||||||
char *buff;
|
char *buff;
|
||||||
|
|
||||||
rsize += 4;
|
rsize += VARHDRSZ;
|
||||||
buff = palloc(rsize);
|
buff = palloc(rsize);
|
||||||
if (buff)
|
if (buff)
|
||||||
isDestLO = false;
|
isDestLO = false;
|
||||||
if (ARR_IS_CHUNKED(array))
|
if (ARR_IS_CHUNKED(array))
|
||||||
{
|
{
|
||||||
_ReadChunkArray(lowerIndx, upperIndx, len, fd, &(buff[4]),
|
_ReadChunkArray(lowerIndx, upperIndx, len, fd, &(buff[VARHDRSZ]),
|
||||||
array, 0, isNull);
|
array, 0, isNull);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_ReadArray(lowerIndx, upperIndx, len, fd, (int) &(buff[4]),
|
_ReadArray(lowerIndx, upperIndx, len, fd, (int) &(buff[VARHDRSZ]),
|
||||||
array,
|
array,
|
||||||
0, isNull);
|
0, isNull);
|
||||||
}
|
}
|
||||||
memmove(buff, &rsize, 4);
|
memmove(buff, &rsize, VARHDRSZ);
|
||||||
#ifdef LOARRAY
|
#ifdef LOARRAY
|
||||||
if (!*isNull)
|
if (!*isNull)
|
||||||
bytes = LOwrite(newfd, (struct varlena *) buff);
|
bytes = LOwrite(newfd, (struct varlena *) buff);
|
||||||
@ -1131,15 +1131,15 @@ array_set(ArrayType *array,
|
|||||||
#endif
|
#endif
|
||||||
if (lo_lseek(fd, offset, SEEK_SET) < 0)
|
if (lo_lseek(fd, offset, SEEK_SET) < 0)
|
||||||
return ((char *) array);
|
return ((char *) array);
|
||||||
v = (struct varlena *) palloc(elmlen + 4);
|
v = (struct varlena *) palloc(elmlen + VARHDRSZ);
|
||||||
VARSIZE(v) = elmlen + 4;
|
VARSIZE(v) = elmlen + VARHDRSZ;
|
||||||
ArrayCastAndSet(dataPtr, (bool) reftype, elmlen, VARDATA(v));
|
ArrayCastAndSet(dataPtr, (bool) reftype, elmlen, VARDATA(v));
|
||||||
#ifdef LOARRAY
|
#ifdef LOARRAY
|
||||||
n = LOwrite(fd, v);
|
n = LOwrite(fd, v);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if (n < VARSIZE(v) - 4) RETURN_NULL;
|
* if (n < VARSIZE(v) - VARHDRSZ) RETURN_NULL;
|
||||||
*/
|
*/
|
||||||
pfree(v);
|
pfree(v);
|
||||||
lo_close(fd);
|
lo_close(fd);
|
||||||
@ -1692,7 +1692,7 @@ _LOtransfer(char **destfd,
|
|||||||
{
|
{
|
||||||
#ifdef LOARRAY
|
#ifdef LOARRAY
|
||||||
v = (struct varlena *) LOread((int) *srcfd, inc);
|
v = (struct varlena *) LOread((int) *srcfd, inc);
|
||||||
if (VARSIZE(v) - 4 < inc)
|
if (VARSIZE(v) - VARHDRSZ < inc)
|
||||||
{
|
{
|
||||||
pfree(v);
|
pfree(v);
|
||||||
return (-1);
|
return (-1);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.10 1997/09/08 21:48:19 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.11 1997/12/06 22:57:12 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -271,7 +271,7 @@ get_next(int d[], int k, int C, int dmax[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOARRAY
|
#ifdef LOARRAY
|
||||||
static char a_chunk[BLCKSZ + 4];/* 4 since a_chunk is in varlena format */
|
static char a_chunk[BLCKSZ + VARHDRSZ];/* VARHDRSZ since a_chunk is in varlena format */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -318,8 +318,8 @@ _ConvertToChunkFile(int n,
|
|||||||
csize *= C[i];
|
csize *= C[i];
|
||||||
}
|
}
|
||||||
csize *= baseSize;
|
csize *= baseSize;
|
||||||
temp = csize + 4;
|
temp = csize + VARHDRSZ;
|
||||||
memmove(a_chunk, &temp, 4);
|
memmove(a_chunk, &temp, VARHDRSZ);
|
||||||
|
|
||||||
mda_get_prod(n, dim, PX);
|
mda_get_prod(n, dim, PX);
|
||||||
mda_get_offset_values(n, dist, PX, C);
|
mda_get_offset_values(n, dist, PX, C);
|
||||||
@ -327,7 +327,7 @@ _ConvertToChunkFile(int n,
|
|||||||
;
|
;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
read_chunk(chunk_no, C, &(a_chunk[4]), srcfd, n, baseSize, PX, dist);
|
read_chunk(chunk_no, C, &(a_chunk[VARHDRSZ]), srcfd, n, baseSize, PX, dist);
|
||||||
write_chunk((struct varlena *) a_chunk, destfd);
|
write_chunk((struct varlena *) a_chunk, destfd);
|
||||||
} while (next_tuple(n, chunk_no, max_chunks) != -1);
|
} while (next_tuple(n, chunk_no, max_chunks) != -1);
|
||||||
}
|
}
|
||||||
@ -417,7 +417,7 @@ seek_and_read(int pos, int size, char buff[], int fp, int from)
|
|||||||
#ifdef LOARRAY
|
#ifdef LOARRAY
|
||||||
v = (struct varlena *) LOread(fp, size);
|
v = (struct varlena *) LOread(fp, size);
|
||||||
#endif
|
#endif
|
||||||
if (VARSIZE(v) - 4 < size)
|
if (VARSIZE(v) - VARHDRSZ < size)
|
||||||
elog(WARN, "File read error");
|
elog(WARN, "File read error");
|
||||||
memmove(buff, VARDATA(v), size);
|
memmove(buff, VARDATA(v), size);
|
||||||
pfree(v);
|
pfree(v);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.11 1997/10/25 01:10:50 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.12 1997/12/06 22:57:14 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -46,7 +46,7 @@
|
|||||||
/*
|
/*
|
||||||
* bpcharin -
|
* bpcharin -
|
||||||
* converts a string of char() type to the internal representation.
|
* converts a string of char() type to the internal representation.
|
||||||
* len is the length specified in () plus 4 bytes. (XXX dummy is here
|
* len is the length specified in () plus VARHDRSZ bytes. (XXX dummy is here
|
||||||
* because we pass typelem as the second argument for array_in.)
|
* because we pass typelem as the second argument for array_in.)
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
@ -54,7 +54,7 @@ bpcharin(char *s, int dummy, int typlen)
|
|||||||
{
|
{
|
||||||
char *result,
|
char *result,
|
||||||
*r;
|
*r;
|
||||||
int len = typlen - 4;
|
int len = typlen - VARHDRSZ;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
@ -67,7 +67,7 @@ bpcharin(char *s, int dummy, int typlen)
|
|||||||
* this is here because some functions can't supply the typlen
|
* this is here because some functions can't supply the typlen
|
||||||
*/
|
*/
|
||||||
len = strlen(s);
|
len = strlen(s);
|
||||||
typlen = len + 4;
|
typlen = len + VARHDRSZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len > 4096)
|
if (len > 4096)
|
||||||
@ -75,7 +75,7 @@ bpcharin(char *s, int dummy, int typlen)
|
|||||||
|
|
||||||
result = (char *) palloc(typlen);
|
result = (char *) palloc(typlen);
|
||||||
*(int32 *) result = typlen;
|
*(int32 *) result = typlen;
|
||||||
r = result + 4;
|
r = result + VARHDRSZ;
|
||||||
for (i = 0; i < len; i++, r++, s++)
|
for (i = 0; i < len; i++, r++, s++)
|
||||||
{
|
{
|
||||||
*r = *s;
|
*r = *s;
|
||||||
@ -104,9 +104,9 @@ bpcharout(char *s)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
len = *(int32 *) s - 4;
|
len = *(int32 *) s - VARHDRSZ;
|
||||||
result = (char *) palloc(len + 1);
|
result = (char *) palloc(len + 1);
|
||||||
StrNCpy(result, s + 4, len+1); /* these are blank-padded */
|
StrNCpy(result, s + VARHDRSZ, len+1); /* these are blank-padded */
|
||||||
}
|
}
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
@ -118,14 +118,14 @@ bpcharout(char *s)
|
|||||||
/*
|
/*
|
||||||
* vcharin -
|
* vcharin -
|
||||||
* converts a string of varchar() type to the internal representation.
|
* converts a string of varchar() type to the internal representation.
|
||||||
* len is the length specified in () plus 4 bytes. (XXX dummy is here
|
* len is the length specified in () plus VARHDRSZ bytes. (XXX dummy is here
|
||||||
* because we pass typelem as the second argument for array_in.)
|
* because we pass typelem as the second argument for array_in.)
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
varcharin(char *s, int dummy, int typlen)
|
varcharin(char *s, int dummy, int typlen)
|
||||||
{
|
{
|
||||||
char *result;
|
char *result;
|
||||||
int len = typlen - 4;
|
int len = typlen - VARHDRSZ;
|
||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return ((char *) NULL);
|
return ((char *) NULL);
|
||||||
@ -137,7 +137,7 @@ varcharin(char *s, int dummy, int typlen)
|
|||||||
* this is here because some functions can't supply the typlen
|
* this is here because some functions can't supply the typlen
|
||||||
*/
|
*/
|
||||||
len = strlen(s);
|
len = strlen(s);
|
||||||
typlen = len + 4;
|
typlen = len + VARHDRSZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len > 4096)
|
if (len > 4096)
|
||||||
@ -145,7 +145,7 @@ varcharin(char *s, int dummy, int typlen)
|
|||||||
|
|
||||||
result = (char *) palloc(typlen);
|
result = (char *) palloc(typlen);
|
||||||
*(int32 *) result = typlen;
|
*(int32 *) result = typlen;
|
||||||
strncpy(result + 4, s, len+1);
|
strncpy(result + VARHDRSZ, s, len+1);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
@ -164,9 +164,9 @@ varcharout(char *s)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
len = *(int32 *) s - 4;
|
len = *(int32 *) s - VARHDRSZ;
|
||||||
result = (char *) palloc(len + 1);
|
result = (char *) palloc(len + 1);
|
||||||
StrNCpy(result, s + 4, len+1);
|
StrNCpy(result, s + VARHDRSZ, len+1);
|
||||||
}
|
}
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
@ -178,11 +178,11 @@ varcharout(char *s)
|
|||||||
static int
|
static int
|
||||||
bcTruelen(char *arg)
|
bcTruelen(char *arg)
|
||||||
{
|
{
|
||||||
char *s = arg + 4;
|
char *s = arg + VARHDRSZ;
|
||||||
int i;
|
int i;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
len = *(int32 *) arg - 4;
|
len = *(int32 *) arg - VARHDRSZ;
|
||||||
for (i = len - 1; i >= 0; i--)
|
for (i = len - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (s[i] != ' ')
|
if (s[i] != ' ')
|
||||||
@ -205,7 +205,7 @@ bpchareq(char *arg1, char *arg2)
|
|||||||
if (len1 != len2)
|
if (len1 != len2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (strncmp(arg1 + 4, arg2 + 4, len1) == 0);
|
return (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, len1) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -222,7 +222,7 @@ bpcharne(char *arg1, char *arg2)
|
|||||||
if (len1 != len2)
|
if (len1 != len2)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return (strncmp(arg1 + 4, arg2 + 4, len1) != 0);
|
return (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, len1) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -237,7 +237,7 @@ bpcharlt(char *arg1, char *arg2)
|
|||||||
len1 = bcTruelen(arg1);
|
len1 = bcTruelen(arg1);
|
||||||
len2 = bcTruelen(arg2);
|
len2 = bcTruelen(arg2);
|
||||||
|
|
||||||
cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
|
cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
|
||||||
if (cmp == 0)
|
if (cmp == 0)
|
||||||
return (len1 < len2);
|
return (len1 < len2);
|
||||||
else
|
else
|
||||||
@ -256,7 +256,7 @@ bpcharle(char *arg1, char *arg2)
|
|||||||
len1 = bcTruelen(arg1);
|
len1 = bcTruelen(arg1);
|
||||||
len2 = bcTruelen(arg2);
|
len2 = bcTruelen(arg2);
|
||||||
|
|
||||||
cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
|
cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
|
||||||
if (0 == cmp)
|
if (0 == cmp)
|
||||||
return (bool) (len1 <= len2 ? 1 : 0);
|
return (bool) (len1 <= len2 ? 1 : 0);
|
||||||
else
|
else
|
||||||
@ -275,7 +275,7 @@ bpchargt(char *arg1, char *arg2)
|
|||||||
len1 = bcTruelen(arg1);
|
len1 = bcTruelen(arg1);
|
||||||
len2 = bcTruelen(arg2);
|
len2 = bcTruelen(arg2);
|
||||||
|
|
||||||
cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
|
cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
|
||||||
if (cmp == 0)
|
if (cmp == 0)
|
||||||
return (len1 > len2);
|
return (len1 > len2);
|
||||||
else
|
else
|
||||||
@ -294,7 +294,7 @@ bpcharge(char *arg1, char *arg2)
|
|||||||
len1 = bcTruelen(arg1);
|
len1 = bcTruelen(arg1);
|
||||||
len2 = bcTruelen(arg2);
|
len2 = bcTruelen(arg2);
|
||||||
|
|
||||||
cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
|
cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
|
||||||
if (0 == cmp)
|
if (0 == cmp)
|
||||||
return (bool) (len1 >= len2 ? 1 : 0);
|
return (bool) (len1 >= len2 ? 1 : 0);
|
||||||
else
|
else
|
||||||
@ -311,7 +311,7 @@ bpcharcmp(char *arg1, char *arg2)
|
|||||||
len1 = bcTruelen(arg1);
|
len1 = bcTruelen(arg1);
|
||||||
len2 = bcTruelen(arg2);
|
len2 = bcTruelen(arg2);
|
||||||
|
|
||||||
cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
|
cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
|
||||||
if ((0 == cmp) && (len1 != len2))
|
if ((0 == cmp) && (len1 != len2))
|
||||||
return (int32) (len1 < len2 ? -1 : 1);
|
return (int32) (len1 < len2 ? -1 : 1);
|
||||||
else
|
else
|
||||||
@ -325,11 +325,11 @@ bpcharcmp(char *arg1, char *arg2)
|
|||||||
static int
|
static int
|
||||||
vcTruelen(char *arg)
|
vcTruelen(char *arg)
|
||||||
{
|
{
|
||||||
char *s = arg + 4;
|
char *s = arg + VARHDRSZ;
|
||||||
int i;
|
int i;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
len = *(int32 *) arg - 4;
|
len = *(int32 *) arg - VARHDRSZ;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
if (*s++ == '\0')
|
if (*s++ == '\0')
|
||||||
@ -352,7 +352,7 @@ varchareq(char *arg1, char *arg2)
|
|||||||
if (len1 != len2)
|
if (len1 != len2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (strncmp(arg1 + 4, arg2 + 4, len1) == 0);
|
return (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, len1) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -369,7 +369,7 @@ varcharne(char *arg1, char *arg2)
|
|||||||
if (len1 != len2)
|
if (len1 != len2)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return (strncmp(arg1 + 4, arg2 + 4, len1) != 0);
|
return (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, len1) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -384,7 +384,7 @@ varcharlt(char *arg1, char *arg2)
|
|||||||
len1 = vcTruelen(arg1);
|
len1 = vcTruelen(arg1);
|
||||||
len2 = vcTruelen(arg2);
|
len2 = vcTruelen(arg2);
|
||||||
|
|
||||||
cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
|
cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
|
||||||
if (cmp == 0)
|
if (cmp == 0)
|
||||||
return (len1 < len2);
|
return (len1 < len2);
|
||||||
else
|
else
|
||||||
@ -403,7 +403,7 @@ varcharle(char *arg1, char *arg2)
|
|||||||
len1 = vcTruelen(arg1);
|
len1 = vcTruelen(arg1);
|
||||||
len2 = vcTruelen(arg2);
|
len2 = vcTruelen(arg2);
|
||||||
|
|
||||||
cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
|
cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
|
||||||
if (0 == cmp)
|
if (0 == cmp)
|
||||||
return (bool) (len1 <= len2 ? 1 : 0);
|
return (bool) (len1 <= len2 ? 1 : 0);
|
||||||
else
|
else
|
||||||
@ -422,7 +422,7 @@ varchargt(char *arg1, char *arg2)
|
|||||||
len1 = vcTruelen(arg1);
|
len1 = vcTruelen(arg1);
|
||||||
len2 = vcTruelen(arg2);
|
len2 = vcTruelen(arg2);
|
||||||
|
|
||||||
cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
|
cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
|
||||||
if (cmp == 0)
|
if (cmp == 0)
|
||||||
return (len1 > len2);
|
return (len1 > len2);
|
||||||
else
|
else
|
||||||
@ -441,7 +441,7 @@ varcharge(char *arg1, char *arg2)
|
|||||||
len1 = vcTruelen(arg1);
|
len1 = vcTruelen(arg1);
|
||||||
len2 = vcTruelen(arg2);
|
len2 = vcTruelen(arg2);
|
||||||
|
|
||||||
cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
|
cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
|
||||||
if (0 == cmp)
|
if (0 == cmp)
|
||||||
return (bool) (len1 >= len2 ? 1 : 0);
|
return (bool) (len1 >= len2 ? 1 : 0);
|
||||||
else
|
else
|
||||||
@ -458,7 +458,7 @@ varcharcmp(char *arg1, char *arg2)
|
|||||||
|
|
||||||
len1 = vcTruelen(arg1);
|
len1 = vcTruelen(arg1);
|
||||||
len2 = vcTruelen(arg2);
|
len2 = vcTruelen(arg2);
|
||||||
cmp = (strncmp(arg1 + 4, arg2 + 4, Min(len1, len2)));
|
cmp = (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2)));
|
||||||
if ((0 == cmp) && (len1 != len2))
|
if ((0 == cmp) && (len1 != len2))
|
||||||
return (int32) (len1 < len2 ? -1 : 1);
|
return (int32) (len1 < len2 ? -1 : 1);
|
||||||
else
|
else
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.22 1997/11/23 21:39:12 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.23 1997/12/06 22:57:15 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -132,7 +132,7 @@ byteaout(struct varlena * vlena)
|
|||||||
else if (isascii(*vp) && isprint(*vp))
|
else if (isascii(*vp) && isprint(*vp))
|
||||||
len++;
|
len++;
|
||||||
else
|
else
|
||||||
len += 4;
|
len += VARHDRSZ;
|
||||||
rp = result = (char *) palloc(len);
|
rp = result = (char *) palloc(len);
|
||||||
vp = vlena->vl_dat;
|
vp = vlena->vl_dat;
|
||||||
for (i = vlena->vl_len - sizeof(int32); i != 0; i--) /* varlena? */
|
for (i = vlena->vl_len - sizeof(int32); i != 0; i--) /* varlena? */
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.57 1997/12/05 01:04:25 scrappy Exp $
|
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.58 1997/12/06 22:57:28 momjian Exp $
|
||||||
*
|
*
|
||||||
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
||||||
*
|
*
|
||||||
@ -1671,7 +1671,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
|
|||||||
tblinfo[i].typnames[j] = strdup(PQgetvalue(res, j, i_typname));
|
tblinfo[i].typnames[j] = strdup(PQgetvalue(res, j, i_typname));
|
||||||
tblinfo[i].attlen[j] = atoi(PQgetvalue(res, j, i_attlen));
|
tblinfo[i].attlen[j] = atoi(PQgetvalue(res, j, i_attlen));
|
||||||
if (tblinfo[i].attlen[j] > 0)
|
if (tblinfo[i].attlen[j] > 0)
|
||||||
tblinfo[i].attlen[j] = tblinfo[i].attlen[j] - 4;
|
tblinfo[i].attlen[j] = tblinfo[i].attlen[j] - VARHDRSZ;
|
||||||
tblinfo[i].inhAttrs[j] = 0; /* this flag is set in
|
tblinfo[i].inhAttrs[j] = 0; /* this flag is set in
|
||||||
* flagInhAttrs() */
|
* flagInhAttrs() */
|
||||||
tblinfo[i].notnull[j] = (PQgetvalue(res, j, i_attnotnull)[0] == 't') ? true : false;
|
tblinfo[i].notnull[j] = (PQgetvalue(res, j, i_attnotnull)[0] == 't') ? true : false;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.119 1997/12/05 01:13:11 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.120 1997/12/06 22:57:36 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -616,12 +616,12 @@ tableDesc(PsqlSettings *pset, char *table, FILE *fout)
|
|||||||
else if (strcmp(rtype, "bpchar") == 0)
|
else if (strcmp(rtype, "bpchar") == 0)
|
||||||
{
|
{
|
||||||
fprintf(fout,"%-32.32s |", "(bp)char");
|
fprintf(fout,"%-32.32s |", "(bp)char");
|
||||||
fprintf(fout,"%6i |", rsize > 0 ? rsize - 4 : 0);
|
fprintf(fout,"%6i |", rsize > 0 ? rsize - VARHDRSZ : 0);
|
||||||
}
|
}
|
||||||
else if (strcmp(rtype, "varchar") == 0)
|
else if (strcmp(rtype, "varchar") == 0)
|
||||||
{
|
{
|
||||||
fprintf(fout,"%-32.32s |", rtype);
|
fprintf(fout,"%-32.32s |", rtype);
|
||||||
fprintf(fout,"%6i |", rsize > 0 ? rsize - 4 : 0);
|
fprintf(fout,"%6i |", rsize > 0 ? rsize - VARHDRSZ: 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user