*** postgresql-7.2.cvs/src/interfaces/ecpg/preproc/preproc.y	Mon Mar 18 13:52:48 2002
--- postgresql-7.2/src/interfaces/ecpg/preproc/preproc.y	Mon Mar 18 14:34:31 2002
***************
*** 169,174 ****
--- 169,175 ----
  		S_DOTPOINT S_EQUAL S_EXTERN S_INC S_LSHIFT S_MEMPOINT
  		S_MEMBER S_MOD S_MUL S_NEQUAL S_OR S_REGISTER S_RSHIFT
  		S_STATIC S_SUB S_VOLATILE
+ 		S_TYPEDEF
  
  /* I need this and don't know where it is defined inside the backend */
  %token	TYPECAST
***************
*** 360,365 ****
--- 361,367 ----
  %type  <str>	enum_type civar civarind ECPGCursorStmt ECPGDeallocate
  %type  <str>	ECPGFree ECPGDeclare ECPGVar opt_at enum_definition
  %type  <str>	struct_type s_struct declaration declarations variable_declarations
+ %type  <str>	var_declaration type_declaration
  %type  <str>	s_union union_type ECPGSetAutocommit on_off
  %type  <str>	ECPGAllocateDescr ECPGDeallocateDescr symbol opt_symbol
  %type  <str>	ECPGGetDescriptorHeader ECPGColLabel
***************
*** 3672,3678 ****
  		| declarations declaration			{ $$ = cat2_str($1, $2); }
  		;
  
! declaration: storage_clause storage_modifier
  		{
  			actual_storage[struct_level] = cat2_str(mm_strdup($1), mm_strdup($2));
  			actual_startline[struct_level] = hashline_number();
--- 3674,3749 ----
  		| declarations declaration			{ $$ = cat2_str($1, $2); }
  		;
  
! declaration: type_declaration { $$ = $1; }
! 			| var_declaration { $$ = $1; };
! 
! type_declaration: S_TYPEDEF
! 	{
! 		/* reset this variable so we see if there was */
! 		/* an initializer specified */
! 		initializer = 0;
! 	}
! 	type opt_type_array_bounds opt_reference ColLabel ';'
! 	{
! 		/* add entry to list */
! 		struct typedefs *ptr, *this;
! 		int dimension = $4.index1;
! 		int length = $4.index2;
! 
! 		if (($3.type_enum == ECPGt_struct ||
! 		     $3.type_enum == ECPGt_union) &&
! 		    initializer == 1)
! 		{
! 			mmerror(PARSE_ERROR, ET_ERROR, "Initializer not allowed in EXEC SQL VAR command");
! 
! 		}
! 		else
! 		{
! 			for (ptr = types; ptr != NULL; ptr = ptr->next)
! 
! 
! 
! 
! 
! 
! 			{
! 				if (strcmp($6, ptr->name) == 0)
! 				{
! 			        	/* re-definition is a bug */
! 					sprintf(errortext, "Type %s already defined", $6);
! 					mmerror(PARSE_ERROR, ET_ERROR, errortext);
! 				}
! 			}
! 
! 			adjust_array($3.type_enum, &dimension, &length, $3.type_dimension, $3.type_index, *$5?1:0);
! 
! 			this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
! 
! 	        	/* initial definition */
! 		        this->next = types;
! 	        	this->name = $6;
! 			this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
! 			this->type->type_enum = $3.type_enum;
! 			this->type->type_str = mm_strdup($6);
! 			this->type->type_dimension = dimension; /* dimension of array */
! 			this->type->type_index = length;    /* lenght of string */
! 			this->struct_member_list = ($3.type_enum == ECPGt_struct || $3.type_enum == ECPGt_union) ?
! 				struct_member_list[struct_level] : NULL;
! 
! 			if ($3.type_enum != ECPGt_varchar &&
! 			    $3.type_enum != ECPGt_char &&
! 	        	    $3.type_enum != ECPGt_unsigned_char &&
! 			    this->type->type_index >= 0)
! 				mmerror(PARSE_ERROR, ET_ERROR, "No multi-dimensional array support for simple data types");
! 
! 		types = this;
! 		}
! 
! 
! 		$$ = cat_str(6, make_str("typedef "), mm_strdup($3.type_str), mm_strdup($4.str), $5, mm_strdup($6), make_str(";"));
! 	};
! 
! var_declaration: storage_clause storage_modifier
  		{
  			actual_storage[struct_level] = cat2_str(mm_strdup($1), mm_strdup($2));
  			actual_startline[struct_level] = hashline_number();
***************
*** 4260,4266 ****
  				types = this;
  			}
  
! 			$$ = cat_str(7, make_str("/* exec sql type"), mm_strdup($3), make_str("is"), mm_strdup($5.type_str), mm_strdup($6.str), $7, make_str("*/"));
  		}
  		;
  
--- 4331,4338 ----
  				types = this;
  			}
  
! //			$$ = cat_str(7, make_str("/* exec sql type"), mm_strdup($3), make_str("is"), mm_strdup($5.type_str), mm_strdup($6.str), $7, make_str("*/"));
! 			$$ = cat_str(6, make_str("typedef "), mm_strdup($5.type_str), mm_strdup($6.str), $7, mm_strdup($3), make_str(";"));
  		}
  		;
  
*** postgresql-7.2.cvs/src/interfaces/ecpg/preproc/c_keywords.c	Mon Mar 18 13:52:48 2002
--- postgresql-7.2/src/interfaces/ecpg/preproc/c_keywords.c	Mon Mar 18 14:00:41 2002
***************
*** 36,41 ****
--- 36,42 ----
  	{"signed", SQL_SIGNED},
  	{"static", S_STATIC},
  	{"struct", SQL_STRUCT},
+ 	{"typedef", S_TYPEDEF},
  	{"union", UNION},
  	{"unsigned", SQL_UNSIGNED},
  	{"varchar", VARCHAR},
