Commit 607cd930 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Changes from Michael Meskes:

Check strdup calls for out of memory.
Set library version to 2.6.2
Synced preproc.y and keywords.c with gram.y and keywords.c yet again.
Set version to 2.4.3
parent cbfc9ec6
...@@ -5,7 +5,7 @@ PQ_INCLUDE=-I$(SRCDIR)/interfaces/libpq ...@@ -5,7 +5,7 @@ PQ_INCLUDE=-I$(SRCDIR)/interfaces/libpq
SO_MAJOR_VERSION=2 SO_MAJOR_VERSION=2
SO_MINOR_VERSION=6 SO_MINOR_VERSION=6
SO_PATCHLEVEL=1 SO_PATCHLEVEL=2
PORTNAME=@PORTNAME@ PORTNAME=@PORTNAME@
......
...@@ -148,6 +148,22 @@ ecpg_alloc(long size, int lineno) ...@@ -148,6 +148,22 @@ ecpg_alloc(long size, int lineno)
return (new); return (new);
} }
static char *
ecpg_strdup(const char *string, int lineno)
{
char *new = strdup(string);
if (!new)
{
ECPGfinish(actual_connection);
ECPGlog("out of memory\n");
register_error(ECPG_OUT_OF_MEMORY, "out of memory in line %d", lineno);
return NULL;
}
return (new);
}
/* This function returns a newly malloced string that has the ' and \ /* This function returns a newly malloced string that has the ' and \
in the argument quoted with \. in the argument quoted with \.
*/ */
...@@ -246,7 +262,7 @@ ECPGexecute(struct statement * stmt) ...@@ -246,7 +262,7 @@ ECPGexecute(struct statement * stmt)
memcpy((char *) &sqlca, (char *) &sqlca_init, sizeof(sqlca)); memcpy((char *) &sqlca, (char *) &sqlca_init, sizeof(sqlca));
copiedquery = strdup(stmt->command); copiedquery = ecpg_strdup(stmt->command, stmt->lineno);
/* /*
* Now, if the type is one of the fill in types then we take the * Now, if the type is one of the fill in types then we take the
...@@ -914,9 +930,9 @@ ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd ...@@ -914,9 +930,9 @@ ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd
/* add connection to our list */ /* add connection to our list */
if (connection_name != NULL) if (connection_name != NULL)
this->name = strdup(connection_name); this->name = ecpg_strdup(connection_name, lineno);
else else
this->name = strdup(dbname); this->name = ecpg_strdup(dbname, lineno);
if (all_connections == NULL) if (all_connections == NULL)
this->next = NULL; this->next = NULL;
......
...@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global ...@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global
MAJOR_VERSION=2 MAJOR_VERSION=2
MINOR_VERSION=4 MINOR_VERSION=4
PATCHLEVEL=2 PATCHLEVEL=3
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \ CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \ -DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
...@@ -27,6 +27,10 @@ uninstall: ...@@ -27,6 +27,10 @@ uninstall:
ecpg: $(OBJ) ecpg: $(OBJ)
$(CC) -o ecpg $(OBJ) $(LEXLIB) $(LDFLAGS) $(CC) -o ecpg $(OBJ) $(LEXLIB) $(LDFLAGS)
pgc.c: pgc.l
$(LEX) $<
mv lex.yy.c pgc.c
y.tab.h y.tab.c: preproc.y y.tab.h y.tab.c: preproc.y
$(YACC) $(YFLAGS) $< $(YACC) $(YFLAGS) $<
......
...@@ -67,6 +67,7 @@ extern void lex_init(void); ...@@ -67,6 +67,7 @@ extern void lex_init(void);
extern char *input_filename; extern char *input_filename;
extern int yyparse(void); extern int yyparse(void);
extern void *mm_alloc(size_t), *mm_realloc(void *, size_t); extern void *mm_alloc(size_t), *mm_realloc(void *, size_t);
extern char *mm_strdup(const char *);
ScanKeyword *ScanECPGKeywordLookup(char *); ScanKeyword *ScanECPGKeywordLookup(char *);
ScanKeyword *ScanCKeywordLookup(char *); ScanKeyword *ScanCKeywordLookup(char *);
extern void yyerror(char *); extern void yyerror(char *);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.5 1998/09/21 05:52:53 scrappy Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.6 1998/10/03 02:33:36 thomas Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -29,8 +29,9 @@ ...@@ -29,8 +29,9 @@
* search is used to locate entries. * search is used to locate entries.
*/ */
static ScanKeyword ScanKeywords[] = { static ScanKeyword ScanKeywords[] = {
/* name value */ /* name, value */
{"abort", ABORT_TRANS}, {"abort", ABORT_TRANS},
{"absolute", ABSOLUTE},
{"action", ACTION}, {"action", ACTION},
{"add", ADD}, {"add", ADD},
{"after", AFTER}, {"after", AFTER},
...@@ -40,7 +41,6 @@ static ScanKeyword ScanKeywords[] = { ...@@ -40,7 +41,6 @@ static ScanKeyword ScanKeywords[] = {
{"analyze", ANALYZE}, {"analyze", ANALYZE},
{"and", AND}, {"and", AND},
{"any", ANY}, {"any", ANY},
{"archive", ARCHIVE},
{"as", AS}, {"as", AS},
{"asc", ASC}, {"asc", ASC},
{"backward", BACKWARD}, {"backward", BACKWARD},
...@@ -67,7 +67,9 @@ static ScanKeyword ScanKeywords[] = { ...@@ -67,7 +67,9 @@ static ScanKeyword ScanKeywords[] = {
{"createdb", CREATEDB}, {"createdb", CREATEDB},
{"createuser", CREATEUSER}, {"createuser", CREATEUSER},
{"cross", CROSS}, {"cross", CROSS},
{"current", CURRENT}, {"current", CURRENT}, /* 6.4 to 6.5 is migration time! CURRENT
* will be removed in 6.5! Use OLD keyword
* in rules. Jan */
{"current_date", CURRENT_DATE}, {"current_date", CURRENT_DATE},
{"current_time", CURRENT_TIME}, {"current_time", CURRENT_TIME},
{"current_timestamp", CURRENT_TIMESTAMP}, {"current_timestamp", CURRENT_TIMESTAMP},
...@@ -87,6 +89,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -87,6 +89,7 @@ static ScanKeyword ScanKeywords[] = {
{"double", DOUBLE}, {"double", DOUBLE},
{"drop", DROP}, {"drop", DROP},
{"each", EACH}, {"each", EACH},
{"encoding", ENCODING},
{"end", END_TRANS}, {"end", END_TRANS},
{"execute", EXECUTE}, {"execute", EXECUTE},
{"exists", EXISTS}, {"exists", EXISTS},
...@@ -113,6 +116,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -113,6 +116,7 @@ static ScanKeyword ScanKeywords[] = {
{"inherits", INHERITS}, {"inherits", INHERITS},
{"inner", INNER_P}, {"inner", INNER_P},
{"insert", INSERT}, {"insert", INSERT},
{"insensitive", INSENSITIVE},
{"instead", INSTEAD}, {"instead", INSTEAD},
{"interval", INTERVAL}, {"interval", INTERVAL},
{"into", INTO}, {"into", INTO},
...@@ -136,10 +140,12 @@ static ScanKeyword ScanKeywords[] = { ...@@ -136,10 +140,12 @@ static ScanKeyword ScanKeywords[] = {
{"minvalue", MINVALUE}, {"minvalue", MINVALUE},
{"month", MONTH_P}, {"month", MONTH_P},
{"move", MOVE}, {"move", MOVE},
{"names", NAMES},
{"national", NATIONAL}, {"national", NATIONAL},
{"natural", NATURAL}, {"natural", NATURAL},
{"nchar", NCHAR}, {"nchar", NCHAR},
{"new", NEW}, {"new", NEW},
{"next", NEXT},
{"no", NO}, {"no", NO},
{"nocreatedb", NOCREATEDB}, {"nocreatedb", NOCREATEDB},
{"nocreateuser", NOCREATEUSER}, {"nocreateuser", NOCREATEUSER},
...@@ -152,7 +158,9 @@ static ScanKeyword ScanKeywords[] = { ...@@ -152,7 +158,9 @@ static ScanKeyword ScanKeywords[] = {
{"numeric", NUMERIC}, {"numeric", NUMERIC},
{"of", OF}, {"of", OF},
{"oids", OIDS}, {"oids", OIDS},
{"old", CURRENT},
{"on", ON}, {"on", ON},
{"only", ONLY},
{"operator", OPERATOR}, {"operator", OPERATOR},
{"option", OPTION}, {"option", OPTION},
{"or", OR}, {"or", OR},
...@@ -163,12 +171,15 @@ static ScanKeyword ScanKeywords[] = { ...@@ -163,12 +171,15 @@ static ScanKeyword ScanKeywords[] = {
{"position", POSITION}, {"position", POSITION},
{"precision", PRECISION}, {"precision", PRECISION},
{"primary", PRIMARY}, {"primary", PRIMARY},
{"prior", PRIOR},
{"privileges", PRIVILEGES}, {"privileges", PRIVILEGES},
{"procedural", PROCEDURAL}, {"procedural", PROCEDURAL},
{"procedure", PROCEDURE}, {"procedure", PROCEDURE},
{"public", PUBLIC}, {"public", PUBLIC},
{"read", READ},
{"recipe", RECIPE}, {"recipe", RECIPE},
{"references", REFERENCES}, {"references", REFERENCES},
{"relative", RELATIVE},
{"rename", RENAME}, {"rename", RENAME},
{"reset", RESET}, {"reset", RESET},
{"returns", RETURNS}, {"returns", RETURNS},
...@@ -177,9 +188,11 @@ static ScanKeyword ScanKeywords[] = { ...@@ -177,9 +188,11 @@ static ScanKeyword ScanKeywords[] = {
{"rollback", ROLLBACK}, {"rollback", ROLLBACK},
{"row", ROW}, {"row", ROW},
{"rule", RULE}, {"rule", RULE},
{"scroll", SCROLL},
{"second", SECOND_P}, {"second", SECOND_P},
{"select", SELECT}, {"select", SELECT},
{"sequence", SEQUENCE}, {"sequence", SEQUENCE},
{"serial", SERIAL},
{"set", SET}, {"set", SET},
{"setof", SETOF}, {"setof", SETOF},
{"show", SHOW}, {"show", SHOW},
...@@ -190,6 +203,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -190,6 +203,7 @@ static ScanKeyword ScanKeywords[] = {
{"substring", SUBSTRING}, {"substring", SUBSTRING},
{"table", TABLE}, {"table", TABLE},
{"time", TIME}, {"time", TIME},
{"timestamp", TIMESTAMP},
{"timezone_hour", TIMEZONE_HOUR}, {"timezone_hour", TIMEZONE_HOUR},
{"timezone_minute", TIMEZONE_MINUTE}, {"timezone_minute", TIMEZONE_MINUTE},
{"to", TO}, {"to", TO},
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#undef yywrap #undef yywrap
#endif /* yywrap */ #endif /* yywrap */
int debugging = 0;
extern YYSTYPE yylval; extern YYSTYPE yylval;
int llen; int llen;
char literal[MAX_PARSE_BUFFER]; char literal[MAX_PARSE_BUFFER];
......
This diff is collapsed.
...@@ -20,6 +20,21 @@ mm_alloc(size_t size) ...@@ -20,6 +20,21 @@ mm_alloc(size_t size)
return ptr; return ptr;
} }
/* strdup + error check */
char *
mm_strdup(const char *string)
{
char *new = strdup(string);
if (new == NULL)
{
fprintf(stderr, "Out of memory\n");
exit(OUT_OF_MEMORY);
}
return new;
}
/* duplicate memberlist */ /* duplicate memberlist */
static struct ECPGstruct_member * static struct ECPGstruct_member *
struct_member_dup(struct ECPGstruct_member * rm) struct_member_dup(struct ECPGstruct_member * rm)
......
...@@ -52,7 +52,7 @@ exec sql declare cur cursor for ...@@ -52,7 +52,7 @@ exec sql declare cur cursor for
while (1) { while (1) {
strcpy(msg, "fetch"); strcpy(msg, "fetch");
exec sql fetch cur into :personal:ind_personal, :married:ind_married; exec sql fetch in cur into :personal:ind_personal, :married:ind_married;
printf ("%8.8s was born %d (age = %d) %s%s\n", personal.name.arr, personal.birth.born, personal.birth.age, ind_married ? "" : "and married ", ind_married ? "" : married); printf ("%8.8s was born %d (age = %d) %s%s\n", personal.name.arr, personal.birth.born, personal.birth.age, ind_married ? "" : "and married ", ind_married ? "" : married);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment