From b607e5be3ff1099d7f0374bafb7a2b497a8860fd Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@otacoo.com>
Date: Mon, 16 Feb 2015 03:12:39 +0900
Subject: [PATCH 2/3] Use FLEXIBLE_ARRAY_MEMBER in catalog tables

---
 src/include/catalog/pg_attribute.h            |  6 +++---
 src/include/catalog/pg_class.h                |  5 +++--
 src/include/catalog/pg_constraint.h           | 12 ++++++------
 src/include/catalog/pg_database.h             |  2 +-
 src/include/catalog/pg_db_role_setting.h      |  3 ++-
 src/include/catalog/pg_default_acl.h          |  3 ++-
 src/include/catalog/pg_event_trigger.h        |  3 ++-
 src/include/catalog/pg_extension.h            |  6 ++++--
 src/include/catalog/pg_foreign_data_wrapper.h |  4 ++--
 src/include/catalog/pg_foreign_server.h       |  4 ++--
 src/include/catalog/pg_foreign_table.h        |  2 +-
 src/include/catalog/pg_language.h             |  2 +-
 src/include/catalog/pg_largeobject_metadata.h |  2 +-
 src/include/catalog/pg_namespace.h            |  2 +-
 src/include/catalog/pg_pltemplate.h           |  2 +-
 src/include/catalog/pg_policy.h               |  3 ++-
 src/include/catalog/pg_proc.h                 | 14 +++++++++-----
 src/include/catalog/pg_statistic.h            | 10 +++++-----
 src/include/catalog/pg_tablespace.h           |  5 +++--
 src/include/catalog/pg_type.h                 |  2 +-
 src/include/catalog/pg_user_mapping.h         |  2 +-
 21 files changed, 53 insertions(+), 41 deletions(-)

diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index 87a3462..73bcefe 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -157,13 +157,13 @@ CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS BKI_ROWTYPE_OID(75) BK
 	/* NOTE: The following fields are not present in tuple descriptors. */
 
 	/* Column-level access permissions */
-	aclitem		attacl[1];
+	aclitem		attacl[FLEXIBLE_ARRAY_MEMBER];
 
 	/* Column-level options */
-	text		attoptions[1];
+	text		attoptions[FLEXIBLE_ARRAY_MEMBER];
 
 	/* Column-level FDW options */
-	text		attfdwoptions[1];
+	text		attfdwoptions[FLEXIBLE_ARRAY_MEMBER];
 #endif
 } FormData_pg_attribute;
 
diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h
index 8b4c35c..9516d5d 100644
--- a/src/include/catalog/pg_class.h
+++ b/src/include/catalog/pg_class.h
@@ -74,8 +74,9 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO
 
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
 	/* NOTE: These fields are not present in a relcache entry's rd_rel field. */
-	aclitem		relacl[1];		/* access permissions */
-	text		reloptions[1];	/* access-method-specific options */
+	aclitem		relacl[FLEXIBLE_ARRAY_MEMBER];		/* access permissions */
+	text		reloptions[FLEXIBLE_ARRAY_MEMBER];	/* access-method-specific
+													 * options */
 #endif
 } FormData_pg_class;
 
diff --git a/src/include/catalog/pg_constraint.h b/src/include/catalog/pg_constraint.h
index 6f32ac8..2100203 100644
--- a/src/include/catalog/pg_constraint.h
+++ b/src/include/catalog/pg_constraint.h
@@ -98,36 +98,36 @@ CATALOG(pg_constraint,2606)
 	 * Columns of conrelid that the constraint applies to, if known (this is
 	 * NULL for trigger constraints)
 	 */
-	int16		conkey[1];
+	int16		conkey[FLEXIBLE_ARRAY_MEMBER];
 
 	/*
 	 * If a foreign key, the referenced columns of confrelid
 	 */
-	int16		confkey[1];
+	int16		confkey[FLEXIBLE_ARRAY_MEMBER];
 
 	/*
 	 * If a foreign key, the OIDs of the PK = FK equality operators for each
 	 * column of the constraint
 	 */
-	Oid			conpfeqop[1];
+	Oid			conpfeqop[FLEXIBLE_ARRAY_MEMBER];
 
 	/*
 	 * If a foreign key, the OIDs of the PK = PK equality operators for each
 	 * column of the constraint (i.e., equality for the referenced columns)
 	 */
-	Oid			conppeqop[1];
+	Oid			conppeqop[FLEXIBLE_ARRAY_MEMBER];
 
 	/*
 	 * If a foreign key, the OIDs of the FK = FK equality operators for each
 	 * column of the constraint (i.e., equality for the referencing columns)
 	 */
-	Oid			conffeqop[1];
+	Oid			conffeqop[FLEXIBLE_ARRAY_MEMBER];
 
 	/*
 	 * If an exclusion constraint, the OIDs of the exclusion operators for
 	 * each column of the constraint
 	 */
-	Oid			conexclop[1];
+	Oid			conexclop[FLEXIBLE_ARRAY_MEMBER];
 
 	/*
 	 * If a check constraint, nodeToString representation of expression
diff --git a/src/include/catalog/pg_database.h b/src/include/catalog/pg_database.h
index 1045139..92e331e 100644
--- a/src/include/catalog/pg_database.h
+++ b/src/include/catalog/pg_database.h
@@ -45,7 +45,7 @@ CATALOG(pg_database,1262) BKI_SHARED_RELATION BKI_ROWTYPE_OID(1248) BKI_SCHEMA_M
 	Oid			dattablespace;	/* default table space for this DB */
 
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
-	aclitem		datacl[1];		/* access permissions */
+	aclitem		datacl[FLEXIBLE_ARRAY_MEMBER];	/* access permissions */
 #endif
 } FormData_pg_database;
 
diff --git a/src/include/catalog/pg_db_role_setting.h b/src/include/catalog/pg_db_role_setting.h
index 9717569..ff931a9 100644
--- a/src/include/catalog/pg_db_role_setting.h
+++ b/src/include/catalog/pg_db_role_setting.h
@@ -38,7 +38,8 @@ CATALOG(pg_db_role_setting,2964) BKI_SHARED_RELATION BKI_WITHOUT_OIDS
 	Oid			setrole;		/* role */
 
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
-	text		setconfig[1];	/* GUC settings to apply at login */
+	text		setconfig[FLEXIBLE_ARRAY_MEMBER];	/* GUC settings to apply
+													 * at login */
 #endif
 } FormData_pg_db_role_setting;
 
diff --git a/src/include/catalog/pg_default_acl.h b/src/include/catalog/pg_default_acl.h
index 0b5c554..dec4e32 100644
--- a/src/include/catalog/pg_default_acl.h
+++ b/src/include/catalog/pg_default_acl.h
@@ -34,7 +34,8 @@ CATALOG(pg_default_acl,826)
 	char		defaclobjtype;	/* see DEFACLOBJ_xxx constants below */
 
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
-	aclitem		defaclacl[1];	/* permissions to add at CREATE time */
+	aclitem		defaclacl[FLEXIBLE_ARRAY_MEMBER];	/* permissions to add
+													 * at CREATE time */
 #endif
 } FormData_pg_default_acl;
 
diff --git a/src/include/catalog/pg_event_trigger.h b/src/include/catalog/pg_event_trigger.h
index ca81a81..bb6c1aa 100644
--- a/src/include/catalog/pg_event_trigger.h
+++ b/src/include/catalog/pg_event_trigger.h
@@ -38,7 +38,8 @@ CATALOG(pg_event_trigger,3466)
 								 * session_replication_role */
 
 #ifdef CATALOG_VARLEN
-	text		evttags[1];		/* command TAGs this event trigger targets */
+	text		evttags[FLEXIBLE_ARRAY_MEMBER];	/* command TAGs this event
+												 * trigger targets */
 #endif
 } FormData_pg_event_trigger;
 
diff --git a/src/include/catalog/pg_extension.h b/src/include/catalog/pg_extension.h
index f45d6cb..ff54dbc 100644
--- a/src/include/catalog/pg_extension.h
+++ b/src/include/catalog/pg_extension.h
@@ -38,8 +38,10 @@ CATALOG(pg_extension,3079)
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
 	/* extversion should never be null, but the others can be. */
 	text		extversion;		/* extension version name */
-	Oid			extconfig[1];	/* dumpable configuration tables */
-	text		extcondition[1];	/* WHERE clauses for config tables */
+	Oid			extconfig[FLEXIBLE_ARRAY_MEMBER];	/* dumpable configuration
+													 * tables */
+	text		extcondition[FLEXIBLE_ARRAY_MEMBER]; /* WHERE clauses for
+													  * config tables */
 #endif
 } FormData_pg_extension;
 
diff --git a/src/include/catalog/pg_foreign_data_wrapper.h b/src/include/catalog/pg_foreign_data_wrapper.h
index 1c7db04..091ea38 100644
--- a/src/include/catalog/pg_foreign_data_wrapper.h
+++ b/src/include/catalog/pg_foreign_data_wrapper.h
@@ -36,8 +36,8 @@ CATALOG(pg_foreign_data_wrapper,2328)
 	Oid			fdwvalidator;	/* option validation function, or 0 if none */
 
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
-	aclitem		fdwacl[1];		/* access permissions */
-	text		fdwoptions[1];	/* FDW options */
+	aclitem		fdwacl[FLEXIBLE_ARRAY_MEMBER];		/* access permissions */
+	text		fdwoptions[FLEXIBLE_ARRAY_MEMBER];	/* FDW options */
 #endif
 } FormData_pg_foreign_data_wrapper;
 
diff --git a/src/include/catalog/pg_foreign_server.h b/src/include/catalog/pg_foreign_server.h
index 7ac6fd9..3c28d57 100644
--- a/src/include/catalog/pg_foreign_server.h
+++ b/src/include/catalog/pg_foreign_server.h
@@ -35,8 +35,8 @@ CATALOG(pg_foreign_server,1417)
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
 	text		srvtype;
 	text		srvversion;
-	aclitem		srvacl[1];		/* access permissions */
-	text		srvoptions[1];	/* FDW-specific options */
+	aclitem		srvacl[FLEXIBLE_ARRAY_MEMBER];		/* access permissions */
+	text		srvoptions[FLEXIBLE_ARRAY_MEMBER];	/* FDW-specific options */
 #endif
 } FormData_pg_foreign_server;
 
diff --git a/src/include/catalog/pg_foreign_table.h b/src/include/catalog/pg_foreign_table.h
index 2e6b947..727214c 100644
--- a/src/include/catalog/pg_foreign_table.h
+++ b/src/include/catalog/pg_foreign_table.h
@@ -32,7 +32,7 @@ CATALOG(pg_foreign_table,3118) BKI_WITHOUT_OIDS
 	Oid			ftserver;		/* OID of foreign server */
 
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
-	text		ftoptions[1];	/* FDW-specific options */
+	text		ftoptions[FLEXIBLE_ARRAY_MEMBER];	/* FDW-specific options */
 #endif
 } FormData_pg_foreign_table;
 
diff --git a/src/include/catalog/pg_language.h b/src/include/catalog/pg_language.h
index b82cca2..c7b10fc 100644
--- a/src/include/catalog/pg_language.h
+++ b/src/include/catalog/pg_language.h
@@ -39,7 +39,7 @@ CATALOG(pg_language,2612)
 	Oid			lanvalidator;	/* Optional validation function */
 
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
-	aclitem		lanacl[1];		/* Access privileges */
+	aclitem		lanacl[FLEXIBLE_ARRAY_MEMBER];	/* Access privileges */
 #endif
 } FormData_pg_language;
 
diff --git a/src/include/catalog/pg_largeobject_metadata.h b/src/include/catalog/pg_largeobject_metadata.h
index 033f7bd..85658d2 100644
--- a/src/include/catalog/pg_largeobject_metadata.h
+++ b/src/include/catalog/pg_largeobject_metadata.h
@@ -33,7 +33,7 @@ CATALOG(pg_largeobject_metadata,2995)
 	Oid			lomowner;		/* OID of the largeobject owner */
 
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
-	aclitem		lomacl[1];		/* access permissions */
+	aclitem		lomacl[FLEXIBLE_ARRAY_MEMBER];	/* access permissions */
 #endif
 } FormData_pg_largeobject_metadata;
 
diff --git a/src/include/catalog/pg_namespace.h b/src/include/catalog/pg_namespace.h
index 2c8887c..e1258a8 100644
--- a/src/include/catalog/pg_namespace.h
+++ b/src/include/catalog/pg_namespace.h
@@ -39,7 +39,7 @@ CATALOG(pg_namespace,2615)
 	Oid			nspowner;
 
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
-	aclitem		nspacl[1];
+	aclitem		nspacl[FLEXIBLE_ARRAY_MEMBER];
 #endif
 } FormData_pg_namespace;
 
diff --git a/src/include/catalog/pg_pltemplate.h b/src/include/catalog/pg_pltemplate.h
index c5e6554..def9cea 100644
--- a/src/include/catalog/pg_pltemplate.h
+++ b/src/include/catalog/pg_pltemplate.h
@@ -39,7 +39,7 @@ CATALOG(pg_pltemplate,1136) BKI_SHARED_RELATION BKI_WITHOUT_OIDS
 	text		tmplinline;		/* name of anonymous-block handler, or NULL */
 	text		tmplvalidator;	/* name of validator function, or NULL */
 	text		tmpllibrary;	/* path of shared library */
-	aclitem		tmplacl[1];		/* access privileges for template */
+	aclitem		tmplacl[FLEXIBLE_ARRAY_MEMBER];	/* access privileges for template */
 #endif
 } FormData_pg_pltemplate;
 
diff --git a/src/include/catalog/pg_policy.h b/src/include/catalog/pg_policy.h
index ae71f3f..87b1b5f 100644
--- a/src/include/catalog/pg_policy.h
+++ b/src/include/catalog/pg_policy.h
@@ -25,7 +25,8 @@ CATALOG(pg_policy,3256)
 	char			polcmd;			/* One of ACL_*_CHR, or '*' for all */
 
 #ifdef CATALOG_VARLEN
-	Oid				polroles[1];	/* Roles associated with policy, not-NULL */
+	Oid				polroles[FLEXIBLE_ARRAY_MEMBER];	/* Roles associated
+														 * with policy, not-NULL */
 	pg_node_tree	polqual;		/* Policy quals. */
 	pg_node_tree	polwithcheck;	/* WITH CHECK quals. */
 #endif
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 9edfdb8..1efae3f 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -61,15 +61,19 @@ CATALOG(pg_proc,1255) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81) BKI_SCHEMA_MACRO
 	oidvector	proargtypes;	/* parameter types (excludes OUT params) */
 
 #ifdef CATALOG_VARLEN
-	Oid			proallargtypes[1];		/* all param types (NULL if IN only) */
-	char		proargmodes[1]; /* parameter modes (NULL if IN only) */
-	text		proargnames[1]; /* parameter names (NULL if no names) */
+	Oid			proallargtypes[FLEXIBLE_ARRAY_MEMBER];	/* all param types
+														 * (NULL if IN only) */
+	char		proargmodes[FLEXIBLE_ARRAY_MEMBER];		/* parameter modes
+														 * (NULL if IN only) */
+	text		proargnames[FLEXIBLE_ARRAY_MEMBER];		/* parameter names
+														 * (NULL if no names) */
 	pg_node_tree proargdefaults;/* list of expression trees for argument
 								 * defaults (NULL if none) */
 	text		prosrc;			/* procedure source text */
 	text		probin;			/* secondary procedure info (can be NULL) */
-	text		proconfig[1];	/* procedure-local GUC settings */
-	aclitem		proacl[1];		/* access permissions */
+	text		proconfig[FLEXIBLE_ARRAY_MEMBER];	/* procedure-local GUC
+													 * settings */
+	aclitem		proacl[FLEXIBLE_ARRAY_MEMBER];		/* access permissions */
 #endif
 } FormData_pg_proc;
 
diff --git a/src/include/catalog/pg_statistic.h b/src/include/catalog/pg_statistic.h
index 62a00fe..a9c695a 100644
--- a/src/include/catalog/pg_statistic.h
+++ b/src/include/catalog/pg_statistic.h
@@ -97,11 +97,11 @@ CATALOG(pg_statistic,2619) BKI_WITHOUT_OIDS
 	Oid			staop5;
 
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
-	float4		stanumbers1[1];
-	float4		stanumbers2[1];
-	float4		stanumbers3[1];
-	float4		stanumbers4[1];
-	float4		stanumbers5[1];
+	float4		stanumbers1[FLEXIBLE_ARRAY_MEMBER];
+	float4		stanumbers2[FLEXIBLE_ARRAY_MEMBER];
+	float4		stanumbers3[FLEXIBLE_ARRAY_MEMBER];
+	float4		stanumbers4[FLEXIBLE_ARRAY_MEMBER];
+	float4		stanumbers5[FLEXIBLE_ARRAY_MEMBER];
 
 	/*
 	 * Values in these arrays are values of the column's data type, or of some
diff --git a/src/include/catalog/pg_tablespace.h b/src/include/catalog/pg_tablespace.h
index 24b1d8f..3868d0b 100644
--- a/src/include/catalog/pg_tablespace.h
+++ b/src/include/catalog/pg_tablespace.h
@@ -34,8 +34,9 @@ CATALOG(pg_tablespace,1213) BKI_SHARED_RELATION
 	Oid			spcowner;		/* owner of tablespace */
 
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
-	aclitem		spcacl[1];		/* access permissions */
-	text		spcoptions[1];	/* per-tablespace options */
+	aclitem		spcacl[FLEXIBLE_ARRAY_MEMBER];		/* access permissions */
+	text		spcoptions[FLEXIBLE_ARRAY_MEMBER];	/* per-tablespace
+													 * options */
 #endif
 } FormData_pg_tablespace;
 
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index 0a900dd..cda6a22 100644
--- a/src/include/catalog/pg_type.h
+++ b/src/include/catalog/pg_type.h
@@ -221,7 +221,7 @@ CATALOG(pg_type,1247) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71) BKI_SCHEMA_MACRO
 	/*
 	 * Access permissions
 	 */
-	aclitem		typacl[1];
+	aclitem		typacl[FLEXIBLE_ARRAY_MEMBER];
 #endif
 } FormData_pg_type;
 
diff --git a/src/include/catalog/pg_user_mapping.h b/src/include/catalog/pg_user_mapping.h
index 3e76e99..5237be3 100644
--- a/src/include/catalog/pg_user_mapping.h
+++ b/src/include/catalog/pg_user_mapping.h
@@ -33,7 +33,7 @@ CATALOG(pg_user_mapping,1418)
 	Oid			umserver;		/* server of this mapping */
 
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
-	text		umoptions[1];	/* user mapping options */
+	text		umoptions[FLEXIBLE_ARRAY_MEMBER];	/* user mapping options */
 #endif
 } FormData_pg_user_mapping;
 
-- 
2.3.0

