diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 9573a9b..0631bc2 100644
*** a/src/backend/nodes/outfuncs.c
--- b/src/backend/nodes/outfuncs.c
*************** _outValue(StringInfo str, const Value *v
*** 2506,2512 ****
  			break;
  		case T_String:
  			appendStringInfoChar(str, '"');
! 			_outToken(str, value->val.str);
  			appendStringInfoChar(str, '"');
  			break;
  		case T_BitString:
--- 2506,2513 ----
  			break;
  		case T_String:
  			appendStringInfoChar(str, '"');
! 			if (value->val.str[0] != '\0')
! 				_outToken(str, value->val.str);
  			appendStringInfoChar(str, '"');
  			break;
  		case T_BitString:
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 0781ac8..7237e5d 100644
*** a/src/backend/utils/adt/ruleutils.c
--- b/src/backend/utils/adt/ruleutils.c
*************** set_relation_column_names(deparse_namesp
*** 3086,3092 ****
  		i = 0;
  		foreach(lc, rte->eref->colnames)
  		{
! 			real_colnames[i] = strVal(lfirst(lc));
  			i++;
  		}
  	}
--- 3086,3101 ----
  		i = 0;
  		foreach(lc, rte->eref->colnames)
  		{
! 			/*
! 			 * If the column name shown in eref is an empty string, then it's
! 			 * a column that was dropped at the time of parsing the query, so
! 			 * treat it as dropped.
! 			 */
! 			char	   *cname = strVal(lfirst(lc));
! 
! 			if (cname[0] == '\0')
! 				cname = NULL;
! 			real_colnames[i] = cname;
  			i++;
  		}
  	}
diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out
index 06b2037..e2d4276 100644
*** a/src/test/regress/expected/create_view.out
--- b/src/test/regress/expected/create_view.out
*************** select pg_get_viewdef('vv6', true);
*** 1332,1337 ****
--- 1332,1389 ----
        JOIN tt13 USING (z);
  (1 row)
  
+ --
+ -- Check some cases involving dropped columns in a function's rowtype result
+ --
+ create table tt14t (f1 text, f2 text, f3 text, f4 text);
+ insert into tt14t values('foo', 'bar', 'baz', 'quux');
+ alter table tt14t drop column f2;
+ create function tt14f() returns setof tt14t as
+ $$
+ declare
+     rec1 record;
+ begin
+     for rec1 in select * from tt14t
+     loop
+         return next rec1;
+     end loop;
+ end;
+ $$
+ language plpgsql;
+ create view tt14v as select t.* from tt14f() t;
+ select pg_get_viewdef('tt14v', true);
+          pg_get_viewdef         
+ --------------------------------
+   SELECT t.f1,                 +
+      t.f3,                     +
+      t.f4                      +
+     FROM tt14f() t(f1, f3, f4);
+ (1 row)
+ 
+ select * from tt14v;
+  f1  | f3  |  f4  
+ -----+-----+------
+  foo | baz | quux
+ (1 row)
+ 
+ -- this perhaps should be rejected, but it isn't:
+ alter table tt14t drop column f3;
+ -- f3 is still in the view but will read as nulls
+ select pg_get_viewdef('tt14v', true);
+          pg_get_viewdef         
+ --------------------------------
+   SELECT t.f1,                 +
+      t.f3,                     +
+      t.f4                      +
+     FROM tt14f() t(f1, f3, f4);
+ (1 row)
+ 
+ select * from tt14v;
+  f1  | f3 |  f4  
+ -----+----+------
+  foo |    | quux
+ (1 row)
+ 
  -- clean up all the random objects we made above
  set client_min_messages = warning;
  DROP SCHEMA temp_view_test CASCADE;
diff --git a/src/test/regress/sql/create_view.sql b/src/test/regress/sql/create_view.sql
index e09bc1a..d3b3f12 100644
*** a/src/test/regress/sql/create_view.sql
--- b/src/test/regress/sql/create_view.sql
*************** alter table tt11 add column z int;
*** 435,440 ****
--- 435,474 ----
  
  select pg_get_viewdef('vv6', true);
  
+ --
+ -- Check some cases involving dropped columns in a function's rowtype result
+ --
+ 
+ create table tt14t (f1 text, f2 text, f3 text, f4 text);
+ insert into tt14t values('foo', 'bar', 'baz', 'quux');
+ 
+ alter table tt14t drop column f2;
+ 
+ create function tt14f() returns setof tt14t as
+ $$
+ declare
+     rec1 record;
+ begin
+     for rec1 in select * from tt14t
+     loop
+         return next rec1;
+     end loop;
+ end;
+ $$
+ language plpgsql;
+ 
+ create view tt14v as select t.* from tt14f() t;
+ 
+ select pg_get_viewdef('tt14v', true);
+ select * from tt14v;
+ 
+ -- this perhaps should be rejected, but it isn't:
+ alter table tt14t drop column f3;
+ 
+ -- f3 is still in the view but will read as nulls
+ select pg_get_viewdef('tt14v', true);
+ select * from tt14v;
+ 
  -- clean up all the random objects we made above
  set client_min_messages = warning;
  DROP SCHEMA temp_view_test CASCADE;
