summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/preproc
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2003-03-20 15:56:50 +0000
committerMichael Meskes <meskes@postgresql.org>2003-03-20 15:56:50 +0000
commit2e6f97560a837f692a143d74c0255b4c92c1bbdb (patch)
tree29103e353c5fd2ddd5795c40566bab2641d19ec8 /src/interfaces/ecpg/preproc
parent26a6378e842db462114b267a0a94c7723e6583c2 (diff)
Started adding date and timestamp.
Diffstat (limited to 'src/interfaces/ecpg/preproc')
-rw-r--r--src/interfaces/ecpg/preproc/preproc.y67
-rw-r--r--src/interfaces/ecpg/preproc/type.c22
2 files changed, 66 insertions, 23 deletions
diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y
index 42c8799ea77..d618da6d8f9 100644
--- a/src/interfaces/ecpg/preproc/preproc.y
+++ b/src/interfaces/ecpg/preproc/preproc.y
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.212 2003/03/16 10:42:54 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.213 2003/03/20 15:56:50 meskes Exp $ */
/* Copyright comment */
%{
@@ -4223,6 +4223,22 @@ single_vt_type: common_type
$$.type_index = -1;
$$.type_sizeof = NULL;
}
+ else if (strcmp($1, "date") == 0)
+ {
+ $$.type_enum = ECPGt_date;
+ $$.type_str = make_str("Date");
+ $$.type_dimension = -1;
+ $$.type_index = -1;
+ $$.type_sizeof = NULL;
+ }
+ else if (strcmp($1, "timestamp") == 0)
+ {
+ $$.type_enum = ECPGt_timestamp;
+ $$.type_str = make_str("Timestamp");
+ $$.type_dimension = -1;
+ $$.type_index = -1;
+ $$.type_sizeof = NULL;
+ }
else
{
/* this is for typedef'ed types */
@@ -4236,17 +4252,6 @@ single_vt_type: common_type
struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
}
}
- | ECPGColLabelCommon '(' precision opt_scale ')'
- {
- if (strcmp($1, "numeric") != 0 && strcmp($1, "decimal") != 0)
- mmerror(PARSE_ERROR, ET_ERROR, "Only numeric/decimal have precision/scale argument");
-
- $$.type_enum = ECPGt_numeric;
- $$.type_str = EMPTY;
- $$.type_dimension = -1;
- $$.type_index = -1;
- $$.type_sizeof = NULL;
- }
;
/*
@@ -4415,6 +4420,17 @@ common_type: simple_type
$$.type_index = -1;
$$.type_sizeof = NULL;
}
+ | ECPGColLabelCommon '(' precision opt_scale ')'
+ {
+ if (strcmp($1, "numeric") != 0 && strcmp($1, "decimal") != 0)
+ mmerror(PARSE_ERROR, ET_ERROR, "Only numeric/decimal have precision/scale argument");
+
+ $$.type_enum = ECPGt_numeric;
+ $$.type_str = EMPTY;
+ $$.type_dimension = -1;
+ $$.type_index = -1;
+ $$.type_sizeof = NULL;
+ }
;
var_type: common_type
@@ -4464,6 +4480,22 @@ var_type: common_type
$$.type_index = -1;
$$.type_sizeof = NULL;
}
+ else if (strcmp($1, "date") == 0)
+ {
+ $$.type_enum = ECPGt_date;
+ $$.type_str = make_str("Date");
+ $$.type_dimension = -1;
+ $$.type_index = -1;
+ $$.type_sizeof = NULL;
+ }
+ else if (strcmp($1, "timestamp") == 0)
+ {
+ $$.type_enum = ECPGt_timestamp;
+ $$.type_str = make_str("Timestamp");
+ $$.type_dimension = -1;
+ $$.type_index = -1;
+ $$.type_sizeof = NULL;
+ }
else
{
/* this is for typedef'ed types */
@@ -4477,17 +4509,6 @@ var_type: common_type
struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
}
}
- | ECPGColLabelCommon '(' precision opt_scale ')'
- {
- if (strcmp($1, "numeric") != 0 && strcmp($1, "decimal") != 0)
- mmerror(PARSE_ERROR, ET_ERROR, "Only numeric/decimal have precision/scale argument");
-
- $$.type_enum = ECPGt_numeric;
- $$.type_str = EMPTY;
- $$.type_dimension = -1;
- $$.type_index = -1;
- $$.type_sizeof = NULL;
- }
;
enum_type: SQL_ENUM opt_symbol enum_definition
diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c
index ec916a1e623..c55244fb1c4 100644
--- a/src/interfaces/ecpg/preproc/type.c
+++ b/src/interfaces/ecpg/preproc/type.c
@@ -175,6 +175,12 @@ get_type(enum ECPGttype type)
case ECPGt_descriptor:
return ("ECPGt_descriptor");
break;
+ case ECPGt_date:
+ return ("ECPGt_date");
+ break;
+ case ECPGt_timestamp:
+ return ("ECPGt_timestamp");
+ break;
default:
sprintf(errortext, "illegal variable type %d\n", type);
yyerror(errortext);
@@ -330,6 +336,22 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
sprintf(offset, "sizeof(struct NumericVar)");
break;
+ case ECPGt_date:
+
+ /*
+ * we have to use a pointer and translate the variable type
+ */
+ sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
+ sprintf(offset, "sizeof(Date)");
+ break;
+ case ECPGt_timestamp:
+
+ /*
+ * we have to use a pointer and translate the variable type
+ */
+ sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
+ sprintf(offset, "sizeof(Date)");
+ break;
default:
/*