Changes to the parser to accept new datatypes.
This commit is contained in:
parent
9a9719e482
commit
524e9d62a7
@ -1361,9 +1361,13 @@ Sun Mar 16 11:28:01 CET 2003
|
||||
- Renamed lib directory to ecpglib.
|
||||
- Added numerical functions to library and preprocessor.
|
||||
|
||||
Don Mar 20 16:53:40 CET 2003
|
||||
Thu Mar 20 16:53:40 CET 2003
|
||||
|
||||
- Added date/timestamp to library and preprocessor.
|
||||
|
||||
Fri Mar 21 15:13:42 CET 2003
|
||||
|
||||
- Made sure preprocessor accepts new datatypes.
|
||||
- Set ecpg version to 2.12.0.
|
||||
- Set ecpg library to 3.4.2.
|
||||
- Set pgtypes library to 1.0.0
|
||||
|
18
src/interfaces/ecpg/include/datetime.h
Normal file
18
src/interfaces/ecpg/include/datetime.h
Normal file
@ -0,0 +1,18 @@
|
||||
#include <pgtypes_timestamp.h>
|
||||
|
||||
#ifndef dtime_t
|
||||
#define dtime_t Timestamp
|
||||
#endif /* dtime_t */
|
||||
|
||||
#ifndef intrvl_t
|
||||
#warning needs interval here
|
||||
#define intrvl_t Timestamp
|
||||
#endif /* intrvl_t */
|
||||
|
||||
extern void dtcurrent (dtime_t *);
|
||||
extern int dtcvasc (char *, dtime_t *);
|
||||
extern int dtsub (dtime_t *, dtime_t *, intrvl_t *);
|
||||
extern int dttoasc (dtime_t *, char *);
|
||||
extern int dttofmtasc (dtime_t *, char *, int, char *);
|
||||
extern int intoasc(intrvl_t *, char *);
|
||||
|
@ -2,14 +2,20 @@
|
||||
|
||||
#ifndef dec_t
|
||||
#define dec_t NumericVar
|
||||
|
||||
#define CSHORTTYPE 0
|
||||
#define CMONEYTYPE 0
|
||||
#define CCHARTYPE 0
|
||||
#define CDECIMALTYPE 0
|
||||
#define CINTTYPE 0
|
||||
#define CDATETYPE 0
|
||||
#define CDOUBLETYPE 0
|
||||
#define CLONGTYPE 0
|
||||
|
||||
#endif /* dec_t */
|
||||
|
||||
int decadd(dec_t *, NumericVar *, NumericVar *);
|
||||
int deccmp(dec_t *, NumericVar *);
|
||||
void deccopy(dec_t *, NumericVar *);
|
||||
int deccvasc(char *, int, dec_t *);
|
||||
int deccvdbl(double, dec_t *);
|
||||
int deccvint(int, dec_t *);
|
||||
int deccvlong(long, dec_t *);
|
||||
int decdiv(dec_t *, NumericVar *, NumericVar *);
|
||||
int decmul(dec_t *, NumericVar *, NumericVar *);
|
||||
int decsub(dec_t *, NumericVar *, NumericVar *);
|
||||
int dectoasc(dec_t *, char *, int, int);
|
||||
int dectodbl(dec_t *, double *);
|
||||
int dectoint(dec_t *, int *);
|
||||
int dectolong(dec_t *, long *);
|
||||
|
||||
|
@ -4,3 +4,25 @@
|
||||
|
||||
#define SQLNOTFOUND 100
|
||||
|
||||
#ifndef Date
|
||||
#define Date long
|
||||
#endif /* ! Date */
|
||||
|
||||
extern int rdatestr (Date, char *);
|
||||
extern void rtoday (Date *);
|
||||
extern int rjulmdy (Date, short *);
|
||||
extern int rdefmtdate (Date *, char *, char *);
|
||||
extern int rfmtdate (Date, char *, char *);
|
||||
extern int rmdyjul (short *, Date *);
|
||||
extern int rstrdate (char *, Date *);
|
||||
extern int rdayofweek(Date);
|
||||
|
||||
extern int rfmtlong(long, char *, char *);
|
||||
extern int rgetmsg(int, char *, int);
|
||||
extern int risnull(int, char *);
|
||||
extern int rsetnull(int, char *);
|
||||
extern int rtypalign(int, int);
|
||||
extern int rtypmsize(int, int);
|
||||
extern void rupshift(char *);
|
||||
|
||||
|
||||
|
@ -30,19 +30,4 @@ int PGTYPESnumeric_ntod(NumericVar *, double *);
|
||||
int PGTYPESnumeric_ntoi(NumericVar *, int *);
|
||||
int PGTYPESnumeric_ntol(NumericVar *, long *);
|
||||
|
||||
int decadd(NumericVar *, NumericVar *, NumericVar *);
|
||||
int deccmp(NumericVar *, NumericVar *);
|
||||
void deccopy(NumericVar *, NumericVar *);
|
||||
int deccvasc(char *, int, NumericVar *);
|
||||
int deccvdbl(double, NumericVar *);
|
||||
int deccvint(int, NumericVar *);
|
||||
int deccvlong(long, NumericVar *);
|
||||
int decdiv(NumericVar *, NumericVar *, NumericVar *);
|
||||
int decmul(NumericVar *, NumericVar *, NumericVar *);
|
||||
int decsub(NumericVar *, NumericVar *, NumericVar *);
|
||||
int dectoasc(NumericVar *, char *, int, int);
|
||||
int dectodbl(NumericVar *, double *);
|
||||
int dectoint(NumericVar *, int *);
|
||||
int dectolong(NumericVar *, long *);
|
||||
|
||||
#endif /* PGTYPES_NUMERIC */
|
||||
|
0
src/interfaces/ecpg/include/sqlda.h
Normal file
0
src/interfaces/ecpg/include/sqlda.h
Normal file
25
src/interfaces/ecpg/include/sqltypes.h
Normal file
25
src/interfaces/ecpg/include/sqltypes.h
Normal file
@ -0,0 +1,25 @@
|
||||
#define CCHARTYPE 100
|
||||
#define CSHORTTYPE 101
|
||||
#define CINTTYPE 102
|
||||
#define CLONGTYPE 103
|
||||
#define CFLOATTYPE 104
|
||||
#define CDOUBLETYPE 105
|
||||
#define CDECIMALTYPE 107
|
||||
#define CFIXCHARTYPE 108
|
||||
#define CSTRINGTYPE 109
|
||||
#define CDATETYPE 110
|
||||
#define CMONEYTYPE 111
|
||||
#define CDTIMETYPE 112
|
||||
#define CLOCATORTYPE 113
|
||||
#define CVCHARTYPE 114
|
||||
#define CINVTYPE 115
|
||||
#define CFILETYPE 116
|
||||
#define CINT8TYPE 117
|
||||
#define CCOLLTYPE 118
|
||||
#define CLVCHARTYPE 119
|
||||
#define CFIXBINTYPE 120
|
||||
#define CVARBINTYPE 121
|
||||
#define CBOOLTYPE 122
|
||||
#define CROWTYPE 123
|
||||
#define CLVCHARPTRTYPE 124
|
||||
#define CTYPEMAX 25
|
@ -9,6 +9,7 @@
|
||||
#include "extern.h"
|
||||
#include "pgtypes_error.h"
|
||||
#include "pgtypes_date.h"
|
||||
#include "ecpg_informix.h"
|
||||
|
||||
Date
|
||||
PGTYPESdate_atod(char *str, char **endptr)
|
||||
@ -103,3 +104,45 @@ PGTYPESdate_day(Date dDate)
|
||||
return j2day(dDate);
|
||||
}
|
||||
|
||||
int
|
||||
rdatestr (Date d, char *str)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
rtoday (Date *d)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
rjulmdy (Date d, short mdy[3])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rdefmtdate (Date *d, char *fmt, char *str)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rfmtdate (Date d, char *fmt, char *str)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rmdyjul (short mdy[3], Date *d)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rstrdate (char *str, Date *d)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
44
src/interfaces/ecpg/pgtypeslib/informix.c
Normal file
44
src/interfaces/ecpg/pgtypeslib/informix.c
Normal file
@ -0,0 +1,44 @@
|
||||
int
|
||||
rfmtlong(long lvalue, char *format, char *outbuf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rgetmsg(int msgnum, char *s, int maxsize)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
risnull(int vtype, char *pcvar)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rsetnull(int vtype, char *pcvar)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rtypalign(int offset, int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rtypmsize(int type, mint len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
rupshift(char *s)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "extern.h"
|
||||
#include "numeric.h"
|
||||
#include "pgtypes_error.h"
|
||||
#include "decimal.h"
|
||||
|
||||
#define Max(x, y) ((x) > (y) ? (x) : (y))
|
||||
#define Min(x, y) ((x) < (y) ? (x) : (y))
|
||||
@ -1040,9 +1041,6 @@ select_div_scale(NumericVar *var1, NumericVar *var2, int *rscale)
|
||||
* NUMERIC_MIN_SIG_DIGITS significant digits, so that numeric gives a
|
||||
* result no less accurate than float8; but use a scale not less than
|
||||
* either input's display scale.
|
||||
*
|
||||
* The result scale is NUMERIC_EXTRA_DIGITS more than the display scale,
|
||||
* to provide some guard digits in the calculation.
|
||||
*/
|
||||
|
||||
/* Get the actual (normalized) weight and first digit of each input */
|
||||
@ -1087,19 +1085,11 @@ select_div_scale(NumericVar *var1, NumericVar *var2, int *rscale)
|
||||
res_dscale = Min(res_dscale, NUMERIC_MAX_DISPLAY_SCALE);
|
||||
|
||||
/* Select result scale */
|
||||
*rscale = res_rscale = res_dscale + NUMERIC_EXTRA_DIGITS;
|
||||
*rscale = res_rscale = res_dscale + 4;
|
||||
|
||||
return res_dscale;
|
||||
}
|
||||
|
||||
|
||||
/* ----------
|
||||
* div_var() -
|
||||
*
|
||||
* Division on variable level. Accuracy of result is determined by
|
||||
* global_rscale.
|
||||
* ----------
|
||||
*/
|
||||
int
|
||||
PGTYPESnumeric_div(NumericVar *var1, NumericVar *var2, NumericVar *result)
|
||||
{
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "extern.h"
|
||||
#include "pgtypes_error.h"
|
||||
#include "pgtypes_timestamp.h"
|
||||
#include "datetime.h"
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
static int64
|
||||
@ -354,3 +355,39 @@ PGTYPEStimestamp_ttoa(Timestamp tstamp)
|
||||
return pgtypes_strdup(buf);
|
||||
}
|
||||
|
||||
void
|
||||
dtcurrent (Timestamp *ts)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
dtcvasc (char *str, Timestamp *ts)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dtsub (Timestamp *ts1, Timestamp *ts2, Timestamp *iv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dttoasc (Timestamp *ts, char *output)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dttofmtasc (Timestamp *ts, char *output, int str_len, char *fmtstr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
intoasc(Timestamp *i, char *str)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.213 2003/03/20 15:56:50 meskes Exp $ */
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.214 2003/03/21 14:17:47 meskes Exp $ */
|
||||
|
||||
/* Copyright comment */
|
||||
%{
|
||||
@ -374,12 +374,12 @@ make_name(void)
|
||||
%type <str> ECPGWhenever ECPGConnect connection_target ECPGOpen
|
||||
%type <str> indicator ECPGExecute ECPGPrepare opt_ecpg_using ecpg_into
|
||||
%type <str> storage_declaration storage_clause opt_initializer c_anything
|
||||
%type <str> variable_list variable c_thing c_term
|
||||
%type <str> variable_list variable c_thing c_term ECPGKeywords_vanames
|
||||
%type <str> opt_pointer ECPGDisconnect dis_name storage_modifier
|
||||
%type <str> ECPGRelease execstring server_name ECPGVarDeclaration
|
||||
%type <str> connection_object opt_server opt_port c_stuff c_stuff_item
|
||||
%type <str> user_name opt_user char_variable ora_user ident opt_reference
|
||||
%type <str> var_type_declarations quoted_ident_stringvar
|
||||
%type <str> var_type_declarations quoted_ident_stringvar ECPGKeywords_rest
|
||||
%type <str> db_prefix server opt_options opt_connection_name c_list
|
||||
%type <str> ECPGSetConnection ECPGTypedef c_args ECPGKeywords
|
||||
%type <str> enum_type civar civarind ECPGCursorStmt ECPGDeallocate
|
||||
@ -389,7 +389,7 @@ make_name(void)
|
||||
%type <str> s_union union_type ECPGSetAutocommit on_off
|
||||
%type <str> ECPGAllocateDescr ECPGDeallocateDescr symbol opt_symbol
|
||||
%type <str> ECPGGetDescriptorHeader ECPGColLabel single_var_declaration
|
||||
%type <str> reserved_keyword unreserved_keyword
|
||||
%type <str> reserved_keyword unreserved_keyword ecpg_interval
|
||||
%type <str> col_name_keyword func_name_keyword precision opt_scale
|
||||
%type <str> ECPGTypeName variablelist ECPGColLabelCommon
|
||||
|
||||
@ -4176,9 +4176,18 @@ opt_scale: ',' NumConst { $$ = $2; }
|
||||
| /* EMPTY */ { $$ = EMPTY; }
|
||||
;
|
||||
|
||||
ecpg_interval: opt_interval { $$ = $1; }
|
||||
| YEAR_P TO MINUTE_P { $$ = make_str("year to minute"); }
|
||||
| DAY_P TO DAY_P { $$ = make_str("day to day"); }
|
||||
| MONTH_P TO MONTH_P { $$ = make_str("month to month"); }
|
||||
;
|
||||
|
||||
single_vt_type: common_type
|
||||
| ECPGColLabelCommon
|
||||
| ECPGColLabelCommon ecpg_interval
|
||||
{
|
||||
if (strlen($2) != 0 && strcmp ($1, "datetime") != 0 && strcmp ($1, "interval") != 0)
|
||||
mmerror (PARSE_ERROR, ET_ERROR, "Interval specification not allowed here ");
|
||||
|
||||
/*
|
||||
* Check for type names that the SQL grammar treats as
|
||||
* unreserved keywords
|
||||
@ -4239,6 +4248,22 @@ single_vt_type: common_type
|
||||
$$.type_index = -1;
|
||||
$$.type_sizeof = NULL;
|
||||
}
|
||||
else if (strcmp($1, "datetime") == 0)
|
||||
{
|
||||
$$.type_enum = ECPGt_timestamp;
|
||||
$$.type_str = make_str("Timestamp");
|
||||
$$.type_dimension = -1;
|
||||
$$.type_index = -1;
|
||||
$$.type_sizeof = NULL;
|
||||
}
|
||||
else if (strcmp($1, "interval") == 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 */
|
||||
@ -4291,7 +4316,7 @@ type_declaration: S_TYPEDEF
|
||||
/* an initializer specified */
|
||||
initializer = 0;
|
||||
}
|
||||
var_type opt_pointer ECPGColLabel opt_array_bounds ';'
|
||||
var_type opt_pointer ECPGColLabelCommon opt_array_bounds ';'
|
||||
{
|
||||
/* add entry to list */
|
||||
struct typedefs *ptr, *this;
|
||||
@ -4434,8 +4459,11 @@ common_type: simple_type
|
||||
;
|
||||
|
||||
var_type: common_type
|
||||
| ECPGColLabel
|
||||
| ECPGColLabel ecpg_interval
|
||||
{
|
||||
if (strlen($2) != 0 && strcmp ($1, "datetime") != 0 && strcmp ($1, "interval") != 0)
|
||||
mmerror (PARSE_ERROR, ET_ERROR, "Interval specification not allowed here ");
|
||||
|
||||
/*
|
||||
* Check for type names that the SQL grammar treats as
|
||||
* unreserved keywords
|
||||
@ -4496,6 +4524,22 @@ var_type: common_type
|
||||
$$.type_index = -1;
|
||||
$$.type_sizeof = NULL;
|
||||
}
|
||||
else if (strcmp($1, "interval") == 0)
|
||||
{
|
||||
$$.type_enum = ECPGt_timestamp;
|
||||
$$.type_str = make_str("Timestamp");
|
||||
$$.type_dimension = -1;
|
||||
$$.type_index = -1;
|
||||
$$.type_sizeof = NULL;
|
||||
}
|
||||
else if (strcmp($1, "datetime") == 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 */
|
||||
@ -4622,7 +4666,7 @@ variable_list: variable
|
||||
{ $$ = cat_str(3, $1, make_str(","), $3); }
|
||||
;
|
||||
|
||||
variable: opt_pointer ECPGColLabel opt_array_bounds opt_initializer
|
||||
variable: opt_pointer ECPGColLabelCommon opt_array_bounds opt_initializer
|
||||
{
|
||||
struct ECPGtype * type;
|
||||
int dimension = $3.index1; /* dimension of array */
|
||||
@ -5173,16 +5217,18 @@ action : SQL_CONTINUE
|
||||
/* some other stuff for ecpg */
|
||||
|
||||
/* additional unreserved keywords */
|
||||
ECPGKeywords: SQL_BREAK { $$ = make_str("break"); }
|
||||
ECPGKeywords: ECPGKeywords_vanames { $$ = $1; }
|
||||
| ECPGKeywords_rest { $$ = $1; }
|
||||
;
|
||||
|
||||
ECPGKeywords_vanames: SQL_BREAK { $$ = make_str("break"); }
|
||||
| SQL_CALL { $$ = make_str("call"); }
|
||||
| SQL_CARDINALITY { $$ = make_str("cardinality"); }
|
||||
| SQL_CONNECT { $$ = make_str("connect"); }
|
||||
| SQL_CONTINUE { $$ = make_str("continue"); }
|
||||
| SQL_COUNT { $$ = make_str("count"); }
|
||||
| SQL_DATA { $$ = make_str("data"); }
|
||||
| SQL_DATETIME_INTERVAL_CODE { $$ = make_str("datetime_interval_code"); }
|
||||
| SQL_DATETIME_INTERVAL_PRECISION { $$ = make_str("datetime_interval_precision"); }
|
||||
| SQL_DISCONNECT { $$ = make_str("disconnect"); }
|
||||
| SQL_FOUND { $$ = make_str("found"); }
|
||||
| SQL_GO { $$ = make_str("go"); }
|
||||
| SQL_GOTO { $$ = make_str("goto"); }
|
||||
@ -5193,7 +5239,6 @@ ECPGKeywords: SQL_BREAK { $$ = make_str("break"); }
|
||||
| SQL_NAME { $$ = make_str("name"); }
|
||||
| SQL_NULLABLE { $$ = make_str("nullable"); }
|
||||
| SQL_OCTET_LENGTH { $$ = make_str("octet_length"); }
|
||||
| SQL_OPEN { $$ = make_str("open"); }
|
||||
| SQL_RELEASE { $$ = make_str("release"); }
|
||||
| SQL_RETURNED_LENGTH { $$ = make_str("returned_length"); }
|
||||
| SQL_RETURNED_OCTET_LENGTH { $$ = make_str("returned_octet_length"); }
|
||||
@ -5203,6 +5248,11 @@ ECPGKeywords: SQL_BREAK { $$ = make_str("break"); }
|
||||
| SQL_SQLPRINT { $$ = make_str("sqlprint"); }
|
||||
| SQL_SQLWARNING { $$ = make_str("sqlwarning"); }
|
||||
| SQL_STOP { $$ = make_str("stop"); }
|
||||
;
|
||||
|
||||
ECPGKeywords_rest: SQL_CONNECT { $$ = make_str("connect"); }
|
||||
| SQL_DISCONNECT { $$ = make_str("disconnect"); }
|
||||
| SQL_OPEN { $$ = make_str("open"); }
|
||||
| SQL_VAR { $$ = make_str("var"); }
|
||||
| SQL_WHENEVER { $$ = make_str("whenever"); }
|
||||
;
|
||||
@ -5272,12 +5322,13 @@ ColLabel: ECPGColLabel { $$ = $1; }
|
||||
ECPGColLabelCommon: ident { $$ = $1; }
|
||||
| col_name_keyword { $$ = $1; }
|
||||
| func_name_keyword { $$ = $1; }
|
||||
| ECPGKeywords_vanames { $$ = $1; }
|
||||
;
|
||||
|
||||
ECPGColLabel: ECPGColLabelCommon { $$ = $1; }
|
||||
| unreserved_keyword { $$ = $1; }
|
||||
| reserved_keyword { $$ = $1; }
|
||||
| ECPGKeywords { $$ = $1; }
|
||||
| ECPGKeywords_rest { $$ = $1; }
|
||||
;
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user