On Tue, Jun 17, 2014 at 08:46:00PM -0400, Bruce Momjian wrote:
> On Tue, Jun 17, 2014 at 07:12:16PM -0400, Tom Lane wrote:
> > Bruce Momjian <br...@momjian.us> writes:
> > > On Tue, Jun 17, 2014 at 03:55:02PM -0400, Alvaro Herrera wrote:
> > >> Can't you compare it to the historic default value?  I mean, add an
> > >> assumption that people thus far has never tweaked it.
> > 
> > > Well, if they did tweak it, then they would be unable to use pg_upgrade
> > > because it would complain about a mismatch if they actually matched the
> > > old and new servers.
> > 
> > What about comparing to the symbolic value LOBLKSIZE?  This would make
> > pg_upgrade assume that the old installation had been tweaked the same
> > as in its own build.  This ends up being the same as what you said,
> > ie, effectively no comparison ... but it might be less complicated to
> > code/understand.
> 
> OK, assume the compiled-in default is the value for an old cluster that
> has no value --- yeah, I could do that.

Turns out I already had values that could be missing in the old cluster,
so I just used the same format for this, rather than testing for
LOBLKSIZE.

Attached patch applied.

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +
diff --git a/contrib/pg_upgrade/controldata.c b/contrib/pg_upgrade/controldata.c
new file mode 100644
index 9282b8e..d105a59
*** a/contrib/pg_upgrade/controldata.c
--- b/contrib/pg_upgrade/controldata.c
*************** get_control_data(ClusterInfo *cluster, b
*** 54,59 ****
--- 54,60 ----
  	bool		got_ident = false;
  	bool		got_index = false;
  	bool		got_toast = false;
+ 	bool		got_large_object = false;
  	bool		got_date_is_int = false;
  	bool		got_float8_pass_by_value = false;
  	bool		got_data_checksum_version = false;
*************** get_control_data(ClusterInfo *cluster, b
*** 357,362 ****
--- 358,374 ----
  			cluster->controldata.toast = str2uint(p);
  			got_toast = true;
  		}
+ 		else if ((p = strstr(bufin, "Size of a large-object chunk:")) != NULL)
+ 		{
+ 			p = strchr(p, ':');
+ 
+ 			if (p == NULL || strlen(p) <= 1)
+ 				pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+ 
+ 			p++;				/* removing ':' char */
+ 			cluster->controldata.large_object = str2uint(p);
+ 			got_large_object = true;
+ 		}
  		else if ((p = strstr(bufin, "Date/time type storage:")) != NULL)
  		{
  			p = strchr(p, ':');
*************** get_control_data(ClusterInfo *cluster, b
*** 475,480 ****
--- 487,494 ----
  		!got_tli ||
  		!got_align || !got_blocksz || !got_largesz || !got_walsz ||
  		!got_walseg || !got_ident || !got_index || !got_toast ||
+ 		(!got_large_object &&
+ 		 cluster->controldata.cat_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
  		!got_date_is_int || !got_float8_pass_by_value || !got_data_checksum_version)
  	{
  		pg_log(PG_REPORT,
*************** get_control_data(ClusterInfo *cluster, b
*** 527,532 ****
--- 541,550 ----
  		if (!got_toast)
  			pg_log(PG_REPORT, "  maximum TOAST chunk size\n");
  
+ 		if (!got_large_object &&
+ 			cluster->controldata.cat_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
+ 			pg_log(PG_REPORT, "  large-object chunk size\n");
+ 
  		if (!got_date_is_int)
  			pg_log(PG_REPORT, "  dates/times are integers?\n");
  
*************** check_control_data(ControlData *oldctrl,
*** 576,581 ****
--- 594,602 ----
  	if (oldctrl->toast == 0 || oldctrl->toast != newctrl->toast)
  		pg_fatal("old and new pg_controldata maximum TOAST chunk sizes are invalid or do not match\n");
  
+ 	if (oldctrl->large_object == 0 || oldctrl->large_object != newctrl->large_object)
+ 		pg_fatal("old and new pg_controldata large-object chunk sizes are invalid or do not match\n");
+ 
  	if (oldctrl->date_is_int != newctrl->date_is_int)
  		pg_fatal("old and new pg_controldata date/time storage types do not match\n");
  
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
new file mode 100644
index 1ac3394..0207391
*** a/contrib/pg_upgrade/pg_upgrade.h
--- b/contrib/pg_upgrade/pg_upgrade.h
*************** extern char *output_files[];
*** 116,121 ****
--- 116,127 ----
  #define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
  
  /*
+  * large object chunk size added to pg_controldata,
+  * commit 5f93c37805e7485488480916b4585e098d3cc883
+  */
+ #define LARGE_OBJECT_SIZE_PG_CONTROL_VER 942
+ 
+ /*
   * Each relation is represented by a relinfo structure.
   */
  typedef struct
*************** typedef struct
*** 203,208 ****
--- 209,215 ----
  	uint32		ident;
  	uint32		index;
  	uint32		toast;
+ 	uint32		large_object;
  	bool		date_is_int;
  	bool		float8_pass_by_value;
  	bool		data_checksum_version;
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to