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
/* ----------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp