avoid_variable_width_result.patch

text/plain

Filename: avoid_variable_width_result.patch
Type: text/plain
Part: 1
Message: Re: per-column generic option
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index b2c54b5..7f9e1fe 100644
*** a/src/bin/psql/describe.c
--- b/src/bin/psql/describe.c
*************** describeOneTableDetails(const char *sche
*** 1281,1287 ****
  		res = NULL;
  	}
  
! 	/* Get column info */
  	printfPQExpBuffer(&buf, "SELECT a.attname,");
  	appendPQExpBuffer(&buf, "\n  pg_catalog.format_type(a.atttypid, a.atttypmod),"
  					  "\n  (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid) for 128)"
--- 1281,1292 ----
  		res = NULL;
  	}
  
! 	/*
! 	 * Get column info
! 	 *
! 	 * You need to modify value of "firstvcol" which willbe defined below if
! 	 * you are adding column(s) preceding to verbose-only columns.
! 	 */
  	printfPQExpBuffer(&buf, "SELECT a.attname,");
  	appendPQExpBuffer(&buf, "\n  pg_catalog.format_type(a.atttypid, a.atttypmod),"
  					  "\n  (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid) for 128)"
*************** describeOneTableDetails(const char *sche
*** 1295,1300 ****
--- 1300,1307 ----
  		appendPQExpBuffer(&buf, "\n  NULL AS attcollation");
  	if (tableinfo.relkind == 'i')
  		appendPQExpBuffer(&buf, ",\n  pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef");
+ 	else
+ 		appendPQExpBuffer(&buf, ",\n  NULL AS indexdef");
  	if (verbose)
  		appendPQExpBuffer(&buf, ",\n  a.attstorage, pg_catalog.col_description(a.attrelid, a.attnum)");
  	appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_attribute a");
*************** describeOneTableDetails(const char *sche
*** 1461,1467 ****
  		/* Storage and Description */
  		if (verbose)
  		{
! 			int			firstvcol = (tableinfo.relkind == 'i' ? 7 : 6);
  			char	   *storage = PQgetvalue(res, i, firstvcol);
  
  			/* these strings are literal in our syntax, so not translated. */
--- 1468,1474 ----
  		/* Storage and Description */
  		if (verbose)
  		{
! 			int			firstvcol = 7;
  			char	   *storage = PQgetvalue(res, i, firstvcol);
  
  			/* these strings are literal in our syntax, so not translated. */