mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-17 19:30:00 +08:00
- Fixed bug that reversed string length in typedefs.
This commit is contained in:
parent
e6e814c2b1
commit
86ac85b6ae
@ -79,7 +79,7 @@ extern void add_variable_to_head(struct arguments **, struct variable *, struct
|
||||
extern void add_variable_to_tail(struct arguments **, struct variable *, struct variable *);
|
||||
extern void dump_variables(struct arguments *, int);
|
||||
extern struct typedefs *get_typedef(char *);
|
||||
extern void adjust_array(enum ECPGttype, char **, char **, char *, char *, int);
|
||||
extern void adjust_array(enum ECPGttype, char **, char **, char *, char *, int, bool);
|
||||
extern void reset_variables(void);
|
||||
extern void check_indicator(struct ECPGtype *);
|
||||
extern void remove_variables(int);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.263.2.11 2004/05/05 15:06:21 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.263.2.12 2004/05/07 13:43:29 meskes Exp $ */
|
||||
|
||||
/* Copyright comment */
|
||||
%{
|
||||
@ -4649,8 +4649,7 @@ type_declaration: S_TYPEDEF
|
||||
mmerror(PARSE_ERROR, ET_ERROR, errortext);
|
||||
}
|
||||
}
|
||||
|
||||
adjust_array($3.type_enum, &dimension, &length, $3.type_dimension, $3.type_index, *$4?1:0);
|
||||
adjust_array($3.type_enum, &dimension, &length, $3.type_dimension, $3.type_index, *$4?1:0, true);
|
||||
|
||||
this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
|
||||
|
||||
@ -5098,7 +5097,7 @@ variable: opt_pointer ECPGColLabelCommon opt_array_bounds opt_initializer
|
||||
char *length = $3.index2; /* length of string */
|
||||
char dim[14L];
|
||||
|
||||
adjust_array(actual_type[struct_level].type_enum, &dimension, &length, actual_type[struct_level].type_dimension, actual_type[struct_level].type_index, strlen($1));
|
||||
adjust_array(actual_type[struct_level].type_enum, &dimension, &length, actual_type[struct_level].type_dimension, actual_type[struct_level].type_index, strlen($1), false);
|
||||
|
||||
switch (actual_type[struct_level].type_enum)
|
||||
{
|
||||
@ -5488,7 +5487,7 @@ ECPGTypedef: TYPE_P
|
||||
}
|
||||
}
|
||||
|
||||
adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0);
|
||||
adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0, false);
|
||||
|
||||
this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
|
||||
|
||||
@ -5546,7 +5545,7 @@ ECPGVar: SQL_VAR
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "Initializer not allowed in EXEC SQL VAR command");
|
||||
else
|
||||
{
|
||||
adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0);
|
||||
adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0, false);
|
||||
|
||||
switch ($5.type_enum)
|
||||
{
|
||||
|
@ -459,7 +459,7 @@ get_typedef(char *name)
|
||||
}
|
||||
|
||||
void
|
||||
adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *type_dimension, char *type_index, int pointer_len)
|
||||
adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *type_dimension, char *type_index, int pointer_len, bool type_definition)
|
||||
{
|
||||
if (atoi(type_index) >= 0)
|
||||
{
|
||||
@ -484,7 +484,6 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
|
||||
{
|
||||
snprintf(errortext, sizeof(errortext), "No multilevel (more than 2) pointer supported %d", pointer_len);
|
||||
mmerror(PARSE_ERROR, ET_FATAL, errortext);
|
||||
/* mmerror(PARSE_ERROR, ET_FATAL, "No multilevel (more than 2) pointer supported %d",pointer_len);*/
|
||||
}
|
||||
|
||||
if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char)
|
||||
@ -544,7 +543,11 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
|
||||
* make sure we return length = -1 for arrays without
|
||||
* given bounds
|
||||
*/
|
||||
if (atoi(*dimension) < 0)
|
||||
if (atoi(*dimension) < 0 && !type_definition)
|
||||
/*
|
||||
* do not change this for typedefs
|
||||
* since it will be changed later on when the variable is defined
|
||||
*/
|
||||
*length = make_str("1");
|
||||
else if (atoi(*dimension) == 0)
|
||||
*length = make_str("-1");
|
||||
|
Loading…
Reference in New Issue
Block a user