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

Commit8137f2c

Browse files
committed
Hide most variable-length fields from Form_pg_* structs
Those fields only appear in the structs so that genbki.pl can createthe BKI bootstrap files for the catalogs. But they are not actuallyusable from C. So hiding them can prevent coding mistakes, savesstack space, and can help the compiler.In certain catalogs, the first variable-length field has been keptvisible after manual inspection. These exceptions are noted in Ccomments.reviewed by Tom Lane
1 parent8a3f745 commit8137f2c

32 files changed

+85
-49
lines changed

‎src/backend/catalog/Catalog.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,15 @@ sub Catalogs
143143
elsif ($declaring_attributes)
144144
{
145145
nextif (/^{|^$/);
146+
nextif (/^#/);
146147
if (/^}/)
147148
{
148149
undef$declaring_attributes;
149150
}
150151
else
151152
{
152153
my ($atttype,$attname) =split /\s+/,$_;
154+
die"parse error ($input_file)"unless$attname;
153155
if (exists$RENAME_ATTTYPE{$atttype})
154156
{
155157
$atttype =$RENAME_ATTTYPE{$atttype};

‎src/include/catalog/genbki.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
/* Introduces a catalog's structure definition */
2323
#defineCATALOG(name,oid)typedef struct CppConcat(FormData_,name)
2424

25+
/*
26+
* This is never defined; it's here only for documentation.
27+
*
28+
* Variable-length catalog fields (except possibly the first not nullable one)
29+
* should not be visible in C structures, so they are made invisible by #ifdefs
30+
* of an undefined symbol. See also MARKNOTNULL in bootstrap.c for how this is
31+
* handled.
32+
*/
33+
#undef CATALOG_VARLEN
34+
2535
/* Options that may appear after CATALOG (on the same line) */
2636
#defineBKI_BOOTSTRAP
2737
#defineBKI_SHARED_RELATION

‎src/include/catalog/pg_aggregate.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ CATALOG(pg_aggregate,2600) BKI_WITHOUT_OIDS
4444
regprocaggfinalfn;
4545
Oidaggsortop;
4646
Oidaggtranstype;
47-
textagginitval;/* VARIABLE LENGTH FIELD */
47+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
48+
textagginitval;
49+
#endif
4850
}FormData_pg_aggregate;
4951

5052
/* ----------------

‎src/include/catalog/pg_attrdef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ CATALOG(pg_attrdef,2604)
3232
{
3333
Oidadrelid;/* OID of table containing attribute */
3434
int2adnum;/* attnum of attribute */
35+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
3536
pg_node_treeadbin;/* nodeToString representation of default */
3637
textadsrc;/* human-readable representation of default */
38+
#endif
3739
}FormData_pg_attrdef;
3840

3941
/* ----------------

‎src/include/catalog/pg_attribute.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,8 @@ CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS BKI_ROWTYPE_OID(75) BK
145145
/* attribute's collation */
146146
Oidattcollation;
147147

148-
/*
149-
* VARIABLE LENGTH FIELDS start here. These fields may be NULL, too.
150-
*
151-
* NOTE: the following fields are not present in tuple descriptors!
152-
*/
148+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
149+
/* NOTE: The following fields are not present in tuple descriptors. */
153150

154151
/* Column-level access permissions */
155152
aclitemattacl[1];
@@ -159,6 +156,7 @@ CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS BKI_ROWTYPE_OID(75) BK
159156

160157
/* Column-level FDW options */
161158
textattfdwoptions[1];
159+
#endif
162160
}FormData_pg_attribute;
163161

164162
/*

‎src/include/catalog/pg_class.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,11 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO
6868
boolrelhassubclass;/* has (or has had) derived classes */
6969
TransactionIdrelfrozenxid;/* all Xids < this are frozen in this rel */
7070

71-
/*
72-
* VARIABLE LENGTH FIELDS start here. These fields may be NULL, too.
73-
*
74-
* NOTE: these fields are not present in a relcache entry's rd_rel field.
75-
*/
76-
71+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
72+
/* NOTE: These fields are not present in a relcache entry's rd_rel field. */
7773
aclitemrelacl[1];/* access permissions */
7874
textreloptions[1];/* access-method-specific options */
75+
#endif
7976
}FormData_pg_class;
8077

8178
/* Size of fixed part of pg_class tuples, not counting var-length fields */

‎src/include/catalog/pg_constraint.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@ CATALOG(pg_constraint,2606)
9191
/* Has a local definition and cannot be inherited */
9292
boolconisonly;
9393

94-
/*
95-
* VARIABLE LENGTH FIELDS start here. These fields may be NULL, too.
96-
*/
97-
94+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
9895
/*
9996
* Columns of conrelid that the constraint applies to, if known (this is
10097
* NULL for trigger constraints)
@@ -139,6 +136,7 @@ CATALOG(pg_constraint,2606)
139136
* If a check constraint, source-text representation of expression
140137
*/
141138
textconsrc;
139+
#endif
142140
}FormData_pg_constraint;
143141

144142
/* ----------------

‎src/include/catalog/pg_database.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ CATALOG(pg_database,1262) BKI_SHARED_RELATION BKI_ROWTYPE_OID(1248) BKI_SCHEMA_M
4242
Oiddatlastsysoid;/* highest OID to consider a system OID */
4343
TransactionIddatfrozenxid;/* all Xids < this are frozen in this DB */
4444
Oiddattablespace;/* default table space for this DB */
45-
aclitemdatacl[1];/* access permissions (VAR LENGTH) */
45+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
46+
aclitemdatacl[1];/* access permissions */
47+
#endif
4648
}FormData_pg_database;
4749

4850
/* ----------------

‎src/include/catalog/pg_db_role_setting.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ CATALOG(pg_db_role_setting,2964) BKI_SHARED_RELATION BKI_WITHOUT_OIDS
3535
{
3636
Oidsetdatabase;/* database */
3737
Oidsetrole;/* role */
38+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
3839
textsetconfig[1];/* GUC settings to apply at login */
40+
#endif
3941
}FormData_pg_db_role_setting;
4042

4143
typedefFormData_pg_db_role_setting*Form_pg_db_role_setting;

‎src/include/catalog/pg_default_acl.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,9 @@ CATALOG(pg_default_acl,826)
3232
Oiddefaclrole;/* OID of role owning this ACL */
3333
Oiddefaclnamespace;/* OID of namespace, or 0 for all */
3434
chardefaclobjtype;/* see DEFACLOBJ_xxx constants below */
35-
36-
/*
37-
* VARIABLE LENGTH FIELDS start here.
38-
*/
39-
35+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
4036
aclitemdefaclacl[1];/* permissions to add at CREATE time */
37+
#endif
4138
}FormData_pg_default_acl;
4239

4340
/* ----------------

‎src/include/catalog/pg_description.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ CATALOG(pg_description,2609) BKI_WITHOUT_OIDS
5050
Oidobjoid;/* OID of object itself */
5151
Oidclassoid;/* OID of table containing object */
5252
int4objsubid;/* column number, or 0 if not used */
53+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
5354
textdescription;/* description of object */
55+
#endif
5456
}FormData_pg_description;
5557

5658
/* ----------------

‎src/include/catalog/pg_extension.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,12 @@ CATALOG(pg_extension,3079)
3434
Oidextowner;/* extension owner */
3535
Oidextnamespace;/* namespace of contained objects */
3636
boolextrelocatable;/* if true, allow ALTER EXTENSION SET SCHEMA */
37-
38-
/*
39-
* VARIABLE LENGTH FIELDS start here.
40-
*
41-
* extversion should never be null, but the others can be.
42-
*/
37+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
38+
/* extversion should never be null, but the others can be. */
4339
textextversion;/* extension version name */
4440
Oidextconfig[1];/* dumpable configuration tables */
4541
textextcondition[1];/* WHERE clauses for config tables */
42+
#endif
4643
}FormData_pg_extension;
4744

4845
/* ----------------

‎src/include/catalog/pg_foreign_data_wrapper.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ CATALOG(pg_foreign_data_wrapper,2328)
3434
Oidfdwowner;/* FDW owner */
3535
Oidfdwhandler;/* handler function, or 0 if none */
3636
Oidfdwvalidator;/* option validation function, or 0 if none */
37-
38-
/* VARIABLE LENGTH FIELDS start here. */
39-
37+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
4038
aclitemfdwacl[1];/* access permissions */
4139
textfdwoptions[1];/* FDW options */
40+
#endif
4241
}FormData_pg_foreign_data_wrapper;
4342

4443
/* ----------------

‎src/include/catalog/pg_foreign_server.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ CATALOG(pg_foreign_server,1417)
3131
NameDatasrvname;/* foreign server name */
3232
Oidsrvowner;/* server owner */
3333
Oidsrvfdw;/* server FDW */
34-
35-
/*
36-
* VARIABLE LENGTH FIELDS start here. These fields may be NULL, too.
37-
*/
34+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
3835
textsrvtype;
3936
textsrvversion;
4037
aclitemsrvacl[1];/* access permissions */
4138
textsrvoptions[1];/* FDW-specific options */
39+
#endif
4240
}FormData_pg_foreign_server;
4341

4442
/* ----------------

‎src/include/catalog/pg_foreign_table.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ CATALOG(pg_foreign_table,3118) BKI_WITHOUT_OIDS
3030
{
3131
Oidftrelid;/* OID of foreign table */
3232
Oidftserver;/* OID of foreign server */
33+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
3334
textftoptions[1];/* FDW-specific options */
35+
#endif
3436
}FormData_pg_foreign_table;
3537

3638
/* ----------------

‎src/include/catalog/pg_index.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ CATALOG(pg_index,2610) BKI_WITHOUT_OIDS BKI_SCHEMA_MACRO
4242
boolindcheckxmin;/* must we wait for xmin to be old? */
4343
boolindisready;/* is this index ready for inserts? */
4444

45-
/*VARIABLE LENGTH FIELDS: */
45+
/*variable-length fields start here, but we allow direct access to indkey */
4646
int2vectorindkey;/* column numbers of indexed cols, or 0 */
47+
#ifdefCATALOG_VARLEN
4748
oidvectorindcollation;/* collation identifiers */
4849
oidvectorindclass;/* opclass identifiers */
4950
int2vectorindoption;/* per-column flags (AM-specific meanings) */
@@ -52,6 +53,7 @@ CATALOG(pg_index,2610) BKI_WITHOUT_OIDS BKI_SCHEMA_MACRO
5253
* each zero entry in indkey[] */
5354
pg_node_treeindpred;/* expression tree for predicate, if a partial
5455
* index; else NULL */
56+
#endif
5557
}FormData_pg_index;
5658

5759
/* ----------------

‎src/include/catalog/pg_language.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ CATALOG(pg_language,2612)
3737
Oidlanplcallfoid;/* Call handler for PL */
3838
Oidlaninline;/* Optional anonymous-block handler function */
3939
Oidlanvalidator;/* Optional validation function */
40+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
4041
aclitemlanacl[1];/* Access privileges */
42+
#endif
4143
}FormData_pg_language;
4244

4345
/* ----------------

‎src/include/catalog/pg_largeobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ CATALOG(pg_largeobject,2613) BKI_WITHOUT_OIDS
3232
{
3333
Oidloid;/* Identifier of large object */
3434
int4pageno;/* Page number (starting from 0) */
35+
/* data has variable length, but we allow direct access; see inv_api.c */
3536
byteadata;/* Data for page (may be zero-length) */
3637
}FormData_pg_largeobject;
3738

‎src/include/catalog/pg_largeobject_metadata.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
CATALOG(pg_largeobject_metadata,2995)
3232
{
3333
Oidlomowner;/* OID of the largeobject owner */
34+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
3435
aclitemlomacl[1];/* access permissions */
36+
#endif
3537
}FormData_pg_largeobject_metadata;
3638

3739
/* ----------------

‎src/include/catalog/pg_namespace.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ CATALOG(pg_namespace,2615)
3737
{
3838
NameDatanspname;
3939
Oidnspowner;
40-
aclitemnspacl[1];/* VARIABLE LENGTH FIELD */
40+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
41+
aclitemnspacl[1];
42+
#endif
4143
}FormData_pg_namespace;
4244

4345
/* ----------------

‎src/include/catalog/pg_pltemplate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ CATALOG(pg_pltemplate,1136) BKI_SHARED_RELATION BKI_WITHOUT_OIDS
3333
NameDatatmplname;/* name of PL */
3434
booltmpltrusted;/* PL is trusted? */
3535
booltmpldbacreate;/* PL is installable by db owner? */
36+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
3637
texttmplhandler;/* name of call handler function */
3738
texttmplinline;/* name of anonymous-block handler, or NULL */
3839
texttmplvalidator;/* name of validator function, or NULL */
3940
texttmpllibrary;/* path of shared library */
4041
aclitemtmplacl[1];/* access privileges for template */
42+
#endif
4143
}FormData_pg_pltemplate;
4244

4345
/* ----------------

‎src/include/catalog/pg_proc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ CATALOG(pg_proc,1255) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81) BKI_SCHEMA_MACRO
5353
int2pronargdefaults;/* number of arguments with defaults */
5454
Oidprorettype;/* OID of result type */
5555

56-
/*VARIABLE LENGTH FIELDS: */
56+
/*variable-length fields start here, but we allow direct access to proargtypes */
5757
oidvectorproargtypes;/* parameter types (excludes OUT params) */
58+
#ifdefCATALOG_VARLEN
5859
Oidproallargtypes[1];/* all param types (NULL if IN only) */
5960
charproargmodes[1];/* parameter modes (NULL if IN only) */
6061
textproargnames[1];/* parameter names (NULL if no names) */
@@ -64,6 +65,7 @@ CATALOG(pg_proc,1255) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81) BKI_SCHEMA_MACRO
6465
textprobin;/* secondary procedure info (can be NULL) */
6566
textproconfig[1];/* procedure-local GUC settings */
6667
aclitemproacl[1];/* access permissions */
68+
#endif
6769
}FormData_pg_proc;
6870

6971
/* ----------------

‎src/include/catalog/pg_rewrite.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ CATALOG(pg_rewrite,2618)
3939
charev_type;
4040
charev_enabled;
4141
boolis_instead;
42-
43-
/* NB: remaining fields must be accessed via heap_getattr */
42+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
4443
pg_node_treeev_qual;
4544
pg_node_treeev_action;
45+
#endif
4646
}FormData_pg_rewrite;
4747

4848
/* ----------------

‎src/include/catalog/pg_seclabel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ CATALOG(pg_seclabel,3596) BKI_WITHOUT_OIDS
2525
Oidobjoid;/* OID of the object itself */
2626
Oidclassoid;/* OID of table containing the object */
2727
int4objsubid;/* column number, or 0 if not used */
28+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
2829
textprovider;/* name of label provider */
2930
textlabel;/* security label of the object */
31+
#endif
3032
}FormData_pg_seclabel;
3133

3234
/* ----------------

‎src/include/catalog/pg_shdescription.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ CATALOG(pg_shdescription,2396) BKI_SHARED_RELATION BKI_WITHOUT_OIDS
4242
{
4343
Oidobjoid;/* OID of object itself */
4444
Oidclassoid;/* OID of table containing object */
45+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
4546
textdescription;/* description of object */
47+
#endif
4648
}FormData_pg_shdescription;
4749

4850
/* ----------------

‎src/include/catalog/pg_shseclabel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ CATALOG(pg_shseclabel,3592) BKI_SHARED_RELATION BKI_WITHOUT_OIDS
2424
{
2525
Oidobjoid;/* OID of the shared object itself */
2626
Oidclassoid;/* OID of table containing the shared object */
27+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
2728
textprovider;/* name of label provider */
2829
textlabel;/* security label of the object */
30+
#endif
2931
}FormData_pg_shseclabel;
3032

3133
/* ----------------

‎src/include/catalog/pg_statistic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ CATALOG(pg_statistic,2619) BKI_WITHOUT_OIDS
116116
float4stanumbers3[1];
117117
float4stanumbers4[1];
118118

119+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
119120
/*
120121
* Values in these arrays are values of the column's data type. We
121122
* presently have to cheat quite a bit to allow polymorphic arrays of this
@@ -125,6 +126,7 @@ CATALOG(pg_statistic,2619) BKI_WITHOUT_OIDS
125126
anyarraystavalues2;
126127
anyarraystavalues3;
127128
anyarraystavalues4;
129+
#endif
128130
}FormData_pg_statistic;
129131

130132
#defineSTATISTIC_NUM_SLOTS 4

‎src/include/catalog/pg_tablespace.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ CATALOG(pg_tablespace,1213) BKI_SHARED_RELATION
3232
{
3333
NameDataspcname;/* tablespace name */
3434
Oidspcowner;/* owner of tablespace */
35-
aclitemspcacl[1];/* access permissions (VAR LENGTH) */
35+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
36+
aclitemspcacl[1];/* access permissions */
3637
textspcoptions[1];/* per-tablespace options */
38+
#endif
3739
}FormData_pg_tablespace;
3840

3941
/* ----------------

‎src/include/catalog/pg_trigger.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,13 @@ CATALOG(pg_trigger,2620)
5050
booltginitdeferred;/* constraint trigger is deferred initially */
5151
int2tgnargs;/* # of extra arguments in tgargs */
5252

53-
/* VARIABLE LENGTH FIELDS (note: tgattr and tgargs must not be null) */
53+
/* Variable-length fields start here, but we allow direct access to tgattr.
54+
* Note: tgattr and tgargs must not be null. */
5455
int2vectortgattr;/* column numbers, if trigger is on columns */
56+
#ifdefCATALOG_VARLEN
5557
byteatgargs;/* first\000second\000tgnargs\000 */
5658
pg_node_treetgqual;/* WHEN expression, or NULL if none */
59+
#endif
5760
}FormData_pg_trigger;
5861

5962
/* ----------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp