Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit58de480

Browse files
committed
Clean up comments to be careful about the distinction between variable-
width types and varlena types, since with the introduction of CSTRING asa more-or-less-real type, these concepts aren't identical. I've tried touse varlena consistently to denote datatypes with typlen = -1, ie, theyhave a length word and are potentially TOASTable; while the term variablewidth covers both varlena and cstring (and, perhaps, someday other typeswith other rules for computing the actual width). No code changes in thiscommit except for renaming a couple macros.
1 parentd46172e commit58de480

File tree

11 files changed

+66
-68
lines changed

11 files changed

+66
-68
lines changed

‎src/backend/access/common/heaptuple.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.79 2002/08/24 15:00:45 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.80 2002/08/25 17:20:00 tgl Exp $
1313
*
1414
* NOTES
1515
* The old interface functions have been converted to macros
@@ -116,7 +116,7 @@ DataFill(char *data,
116116
elseif (att[i]->attlen==-1)
117117
{
118118
/* varlena */
119-
*infomask |=HEAP_HASVARLENA;
119+
*infomask |=HEAP_HASVARWIDTH;
120120
if (VARATT_IS_EXTERNAL(value[i]))
121121
*infomask |=HEAP_HASEXTERNAL;
122122
if (VARATT_IS_COMPRESSED(value[i]))
@@ -127,7 +127,7 @@ DataFill(char *data,
127127
elseif (att[i]->attlen==-2)
128128
{
129129
/* cstring */
130-
*infomask |=HEAP_HASVARLENA;
130+
*infomask |=HEAP_HASVARWIDTH;
131131
data_length=strlen(DatumGetCString(value[i]))+1;
132132
memcpy(data,DatumGetPointer(value[i]),data_length);
133133
}
@@ -230,9 +230,9 @@ nocachegetattr(HeapTuple tuple,
230230
/* ----------------
231231
* Three cases:
232232
*
233-
* 1: No nulls and no variable length attributes.
234-
* 2: Has a null or avarlena AFTER att.
235-
* 3: Has nulls orvarlenas BEFORE att.
233+
* 1: No nulls and no variable-width attributes.
234+
* 2: Has a null or avar-width AFTER att.
235+
* 3: Has nulls orvar-widths BEFORE att.
236236
* ----------------
237237
*/
238238

@@ -326,7 +326,7 @@ nocachegetattr(HeapTuple tuple,
326326

327327
/*
328328
* If slow is false, and we got here, we know that we have a tuple
329-
* with no nulls orvarlenas before the target attribute. If possible,
329+
* with no nulls orvar-widths before the target attribute. If possible,
330330
* we also want to initialize the remainder of the attribute cached
331331
* offset values.
332332
*/

‎src/backend/access/common/indextuple.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.58 2002/08/24 15:00:45 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.59 2002/08/25 17:20:00 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -151,7 +151,7 @@ index_formtuple(TupleDesc tupleDescriptor,
151151
* already set the hasnull bit above.
152152
*/
153153

154-
if (tupmask&HEAP_HASVARLENA)
154+
if (tupmask&HEAP_HASVARWIDTH)
155155
infomask |=INDEX_VAR_MASK;
156156

157157
/*
@@ -211,9 +211,9 @@ nocache_index_getattr(IndexTuple tup,
211211
/* ----------------
212212
* Three cases:
213213
*
214-
* 1: No nulls and no variable length attributes.
215-
* 2: Has a null or avarlena AFTER att.
216-
* 3: Has nulls orvarlenas BEFORE att.
214+
* 1: No nulls and no variable-width attributes.
215+
* 2: Has a null or avar-width AFTER att.
216+
* 3: Has nulls orvar-widths BEFORE att.
217217
* ----------------
218218
*/
219219

@@ -302,7 +302,7 @@ nocache_index_getattr(IndexTuple tup,
302302
returnfetchatt(att[attnum],
303303
tp+att[attnum]->attcacheoff);
304304
}
305-
elseif (IndexTupleHasVarlenas(tup))
305+
elseif (IndexTupleHasVarwidths(tup))
306306
{
307307
intj;
308308

@@ -319,7 +319,7 @@ nocache_index_getattr(IndexTuple tup,
319319

320320
/*
321321
* If slow is false, and we got here, we know that we have a tuple
322-
* with no nulls orvarlenas before the target attribute. If possible,
322+
* with no nulls orvar-widths before the target attribute. If possible,
323323
* we also want to initialize the remainder of the attribute cached
324324
* offset values.
325325
*/

‎src/backend/commands/trigger.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.128 2002/08/22 00:01:42 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.129 2002/08/25 17:20:00 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -261,7 +261,7 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
261261

262262
foreach(le,stmt->args)
263263
{
264-
char*ar=((Value*)lfirst(le))->val.str;
264+
char*ar=strVal(lfirst(le));
265265

266266
len+=strlen(ar)+4;
267267
for (;*ar;ar++)
@@ -274,7 +274,7 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
274274
args[0]='\0';
275275
foreach(le,stmt->args)
276276
{
277-
char*s=((Value*)lfirst(le))->val.str;
277+
char*s=strVal(lfirst(le));
278278
char*d=args+strlen(args);
279279

280280
while (*s)
@@ -653,8 +653,6 @@ RelationBuildTriggers(Relation relation)
653653
ScanKeyDataskey;
654654
SysScanDesctgscan;
655655
HeapTuplehtup;
656-
structvarlena*val;
657-
boolisnull;
658656

659657
triggers= (Trigger*)MemoryContextAlloc(CacheMemoryContext,
660658
ntrigs*sizeof(Trigger));
@@ -702,12 +700,14 @@ RelationBuildTriggers(Relation relation)
702700
FUNC_MAX_ARGS*sizeof(int16));
703701
if (build->tgnargs>0)
704702
{
703+
bytea*val;
704+
boolisnull;
705705
char*p;
706706
inti;
707707

708-
val= (structvarlena*)fastgetattr(htup,
709-
Anum_pg_trigger_tgargs,
710-
tgrel->rd_att,&isnull);
708+
val= (bytea*)fastgetattr(htup,
709+
Anum_pg_trigger_tgargs,
710+
tgrel->rd_att,&isnull);
711711
if (isnull)
712712
elog(ERROR,"RelationBuildTriggers: tgargs IS NULL for rel %s",
713713
RelationGetRelationName(relation));

‎src/backend/commands/user.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.107 2002/08/05 03:29:17 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.108 2002/08/25 17:20:01 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -50,7 +50,7 @@ static List *IdArrayToList(IdList *oldarray);
5050
*fputs_quote
5151
*
5252
*Outputs string in quotes, with double-quotes duplicated.
53-
*We could use quote_ident(), but that expectsvarlena.
53+
*We could use quote_ident(), but that expectsa TEXT argument.
5454
*/
5555
staticvoidfputs_quote(char*str,FILE*fp)
5656
{

‎src/backend/libpq/be-fsstubs.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.61 2002/06/2020:29:28 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.62 2002/08/25 17:20:01 tgl Exp $
1212
*
1313
* NOTES
1414
* This should be moved to a more appropriate place. It is here
@@ -313,24 +313,24 @@ loread(PG_FUNCTION_ARGS)
313313
{
314314
int32fd=PG_GETARG_INT32(0);
315315
int32len=PG_GETARG_INT32(1);
316-
structvarlena*retval;
316+
bytea*retval;
317317
inttotalread;
318318

319319
if (len<0)
320320
len=0;
321321

322-
retval= (structvarlena*)palloc(VARHDRSZ+len);
322+
retval= (bytea*)palloc(VARHDRSZ+len);
323323
totalread=lo_read(fd,VARDATA(retval),len);
324324
VARATT_SIZEP(retval)=totalread+VARHDRSZ;
325325

326-
PG_RETURN_POINTER(retval);
326+
PG_RETURN_BYTEA_P(retval);
327327
}
328328

329329
Datum
330330
lowrite(PG_FUNCTION_ARGS)
331331
{
332332
int32fd=PG_GETARG_INT32(0);
333-
structvarlena*wbuf=PG_GETARG_VARLENA_P(1);
333+
bytea*wbuf=PG_GETARG_BYTEA_P(1);
334334
intbytestowrite;
335335
inttotalwritten;
336336

‎src/backend/storage/large_object/inv_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.94 2002/08/05 03:29:17 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.95 2002/08/25 17:20:01 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -396,7 +396,7 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
396396
boolpfreeit;
397397
struct
398398
{
399-
structvarlenahdr;
399+
byteahdr;
400400
chardata[LOBLKSIZE];
401401
}workbuf;
402402
char*workb=VARATT_DATA(&workbuf.hdr);

‎src/include/access/htup.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: htup.h,v 1.57 2002/07/20 05:16:59 momjian Exp $
10+
* $Id: htup.h,v 1.58 2002/08/25 17:20:01 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -95,8 +95,7 @@ typedef HeapTupleHeaderData *HeapTupleHeader;
9595
* information stored in t_infomask:
9696
*/
9797
#defineHEAP_HASNULL0x0001/* has null attribute(s) */
98-
#defineHEAP_HASVARLENA0x0002/* has variable length
99-
* attribute(s) */
98+
#defineHEAP_HASVARWIDTH0x0002/* has variable-width attribute(s) */
10099
#defineHEAP_HASEXTERNAL0x0004/* has external stored
101100
* attribute(s) */
102101
#defineHEAP_HASCOMPRESSED0x0008/* has compressed stored
@@ -425,7 +424,7 @@ typedef HeapTupleData *HeapTuple;
425424
(!(((HeapTuple) (tuple))->t_data->t_infomask & HEAP_HASNULL))
426425

427426
#defineHeapTupleAllFixed(tuple) \
428-
(!(((HeapTuple) (tuple))->t_data->t_infomask &HEAP_HASVARLENA))
427+
(!(((HeapTuple) (tuple))->t_data->t_infomask &HEAP_HASVARWIDTH))
429428

430429
#defineHeapTupleHasExternal(tuple) \
431430
((((HeapTuple)(tuple))->t_data->t_infomask & HEAP_HASEXTERNAL) != 0)

‎src/include/access/itup.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: itup.h,v 1.35 2002/06/2020:29:43 momjian Exp $
10+
* $Id: itup.h,v 1.36 2002/08/25 17:20:01 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -28,7 +28,7 @@ typedef struct IndexTupleData
2828
* t_info is layed out in the following fashion:
2929
*
3030
* 15th (high) bit: has nulls
31-
* 14th bit: hasvarlenas
31+
* 14th bit: hasvar-width attributes
3232
* 13th bit: unused
3333
* 12-0 bit: size of tuple
3434
* ---------------
@@ -67,7 +67,7 @@ typedef InsertIndexResultData *InsertIndexResult;
6767
#defineIndexTupleSize(itup)((Size) (((IndexTuple) (itup))->t_info & INDEX_SIZE_MASK))
6868
#defineIndexTupleDSize(itup)((Size) ((itup).t_info & INDEX_SIZE_MASK))
6969
#defineIndexTupleHasNulls(itup)((((IndexTuple) (itup))->t_info & INDEX_NULL_MASK))
70-
#defineIndexTupleHasVarlenas(itup) ((((IndexTuple) (itup))->t_info & INDEX_VAR_MASK))
70+
#defineIndexTupleHasVarwidths(itup) ((((IndexTuple) (itup))->t_info & INDEX_VAR_MASK))
7171

7272
#defineIndexTupleHasMinHeader(itup) (!IndexTupleHasNulls(itup))
7373

‎src/include/c.h

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
* Fundamental C definitions. This is included by every .c file in
55
* PostgreSQL (via either postgres.h or postgres_fe.h, as appropriate).
66
*
7-
* Note that the definitions here are not intended to be exposed to clients of
8-
* the frontend interface libraries --- so we don't worry much about polluting
9-
* the namespace with lots of stuff...
7+
* Note that the definitions here are not intended to be exposed to clients
8+
*ofthe frontend interface libraries --- so we don't worry much about
9+
*pollutingthe namespace with lots of stuff...
1010
*
1111
*
1212
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: c.h,v 1.122 2002/08/21 17:20:58 petere Exp $
15+
* $Id: c.h,v 1.123 2002/08/25 17:20:01 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -36,18 +36,19 @@
3636
*8)system-specific hacks
3737
*
3838
* NOTE: since this file is included by both frontend and backend modules, it's
39-
* almost certainly wrong to put an "extern" declaration here.typedefs and macros
40-
* are the kind of thing that might go here.
39+
* almost certainly wrong to put an "extern" declaration here.typedefs and
40+
*macrosare the kind of thing that might go here.
4141
*
4242
*----------------------------------------------------------------
4343
*/
4444
#ifndefC_H
4545
#defineC_H
4646

47-
/* We have to include stdlib.h here because it defines many of these macros
48-
on some platforms, and we only want our definitions used if stdlib.h doesn't
49-
have its own. The same goes for stddef and stdarg if present.
50-
*/
47+
/*
48+
* We have to include stdlib.h here because it defines many of these macros
49+
* on some platforms, and we only want our definitions used if stdlib.h doesn't
50+
* have its own. The same goes for stddef and stdarg if present.
51+
*/
5152

5253
#include"pg_config.h"
5354
#include"postgres_ext.h"
@@ -387,10 +388,11 @@ typedef struct
387388
/* ----------------
388389
*Variable-length datatypes all share the 'struct varlena' header.
389390
*
390-
* NOTE: for TOASTable types, this is an oversimplification, since the value may be
391-
* compressed or moved out-of-line. However datatype-specific routines are mostly
392-
* content to deal with de-TOASTed values only, and of course client-side routines
393-
* should never see a TOASTed value. See postgres.h for details of the TOASTed form.
391+
* NOTE: for TOASTable types, this is an oversimplification, since the value
392+
* may be compressed or moved out-of-line. However datatype-specific routines
393+
* are mostly content to deal with de-TOASTed values only, and of course
394+
* client-side routines should never see a TOASTed value. See postgres.h for
395+
* details of the TOASTed form.
394396
* ----------------
395397
*/
396398
structvarlena
@@ -662,9 +664,4 @@ extern intvsnprintf(char *str, size_t count, const char *fmt, va_list args);
662664
#definememmove(d,s,c)bcopy(s, d, c)
663665
#endif
664666

665-
/* ----------------
666-
*end of c.h
667-
* ----------------
668-
*/
669-
670667
#endif/* C_H */

‎src/include/catalog/pg_statistic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: pg_statistic.h,v 1.16 2002/06/2020:29:49 momjian Exp $
11+
* $Id: pg_statistic.h,v 1.17 2002/08/25 17:20:01 tgl Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -43,7 +43,7 @@ CATALOG(pg_statistic) BKI_WITHOUT_OIDS
4343
/*
4444
* stawidth is the average width in bytes of non-null entries.For
4545
* fixed-width datatypes this is of course the same as the typlen, but
46-
* forvarlena types it is more useful. Note that this is the average
46+
* forvar-width types it is more useful. Note that this is the average
4747
* width of the data as actually stored, post-TOASTing (eg, for a
4848
* moved-out-of-line value, only the size of the pointer object is
4949
* counted). This is the appropriate definition for the primary use

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp