summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/preproc
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2012-02-10 03:58:57 +0100
committerMichael Meskes <meskes@postgresql.org>2012-02-13 15:49:50 +0100
commit9a4880a0dd3cc94770aae2d372302642990c9fc1 (patch)
treee199abd5bd6dba392d1349fdec80c3620312d4a4 /src/interfaces/ecpg/preproc
parent21320763a39994021a4ff045ff66f7204bdb6d78 (diff)
Do not use the variable name when defining a varchar structure in ecpg.
With a unique counter being added anyway, there is no need anymore to have the variable name listed, too.
Diffstat (limited to 'src/interfaces/ecpg/preproc')
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.trailer4
-rw-r--r--src/interfaces/ecpg/preproc/type.c13
-rw-r--r--src/interfaces/ecpg/preproc/type.h1
3 files changed, 5 insertions, 13 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer
index a362aff6e71..35bbe5414ef 100644
--- a/src/interfaces/ecpg/preproc/ecpg.trailer
+++ b/src/interfaces/ecpg/preproc/ecpg.trailer
@@ -877,8 +877,8 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize
mmerror(PARSE_ERROR, ET_ERROR, "pointers to varchar are not implemented");
/* make sure varchar struct name is unique by adding a unique counter to its definition */
- vcn = (char *) mm_alloc(strlen($2) + sizeof(int) * CHAR_BIT * 10 / 3);
- sprintf(vcn, "%s_%d", $2, varchar_counter);
+ vcn = (char *) mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
+ sprintf(vcn, "%d", varchar_counter);
if (strcmp(dimension, "0") == 0)
$$ = cat_str(7, make2_str(mm_strdup(" struct varchar_"), vcn), mm_strdup(" { int len; char arr["), mm_strdup(length), mm_strdup("]; } *"), mm_strdup($2), $4, $5);
else
diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c
index 9934105c344..ff1224754ea 100644
--- a/src/interfaces/ecpg/preproc/type.c
+++ b/src/interfaces/ecpg/preproc/type.c
@@ -375,8 +375,6 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
{
char *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
char *offset = (char *) mm_alloc(strlen(name) + strlen("sizeof(struct varchar_)") + 1 + strlen(varcharsize) + sizeof(int) * CHAR_BIT * 10 / 3);
- char *var_name,
- *ptr;
switch (type)
{
@@ -398,16 +396,11 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
else
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
- /* remove trailing [] is name is array element */
- var_name = mm_strdup(name);
- ptr = strchr(var_name, '[');
- if (ptr)
- *ptr = '\0';
+ /* If we created a varchar structure atomatically, counter is greater than 0. */
if (counter)
- sprintf(offset, "sizeof(struct varchar_%s_%d)", var_name, counter);
+ sprintf(offset, "sizeof(struct varchar_%d)", counter);
else
- sprintf(offset, "sizeof(struct varchar_%s)", var_name);
- free(var_name);
+ sprintf(offset, "sizeof(struct varchar)");
break;
case ECPGt_char:
case ECPGt_unsigned_char:
diff --git a/src/interfaces/ecpg/preproc/type.h b/src/interfaces/ecpg/preproc/type.h
index 68e0d1aa202..b7768fd6614 100644
--- a/src/interfaces/ecpg/preproc/type.h
+++ b/src/interfaces/ecpg/preproc/type.h
@@ -36,7 +36,6 @@ struct ECPGtype
/* Everything is malloced. */
void ECPGmake_struct_member(char *, struct ECPGtype *, struct ECPGstruct_member **);
struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
-struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *, char *);
struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);