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
SO_MAJOR_VERSION=2
SO_MINOR_VERSION=6
SO_PATCHLEVEL=1
SO_PATCHLEVEL=2
PORTNAME=@PORTNAME@
......
......@@ -148,6 +148,22 @@ ecpg_alloc(long size, int lineno)
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 \
in the argument quoted with \.
*/
......@@ -246,7 +262,7 @@ ECPGexecute(struct statement * stmt)
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
......@@ -914,9 +930,9 @@ ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd
/* add connection to our list */
if (connection_name != NULL)
this->name = strdup(connection_name);
this->name = ecpg_strdup(connection_name, lineno);
else
this->name = strdup(dbname);
this->name = ecpg_strdup(dbname, lineno);
if (all_connections == NULL)
this->next = NULL;
......
......@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global
MAJOR_VERSION=2
MINOR_VERSION=4
PATCHLEVEL=2
PATCHLEVEL=3
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
......@@ -27,6 +27,10 @@ uninstall:
ecpg: $(OBJ)
$(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
$(YACC) $(YFLAGS) $<
......
......@@ -67,6 +67,7 @@ extern void lex_init(void);
extern char *input_filename;
extern int yyparse(void);
extern void *mm_alloc(size_t), *mm_realloc(void *, size_t);
extern char *mm_strdup(const char *);
ScanKeyword *ScanECPGKeywordLookup(char *);
ScanKeyword *ScanCKeywordLookup(char *);
extern void yyerror(char *);
......
......@@ -7,7 +7,7 @@
*
*
* 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 @@
* search is used to locate entries.
*/
static ScanKeyword ScanKeywords[] = {
/* name value */
/* name, value */
{"abort", ABORT_TRANS},
{"absolute", ABSOLUTE},
{"action", ACTION},
{"add", ADD},
{"after", AFTER},
......@@ -40,7 +41,6 @@ static ScanKeyword ScanKeywords[] = {
{"analyze", ANALYZE},
{"and", AND},
{"any", ANY},
{"archive", ARCHIVE},
{"as", AS},
{"asc", ASC},
{"backward", BACKWARD},
......@@ -67,7 +67,9 @@ static ScanKeyword ScanKeywords[] = {
{"createdb", CREATEDB},
{"createuser", CREATEUSER},
{"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_time", CURRENT_TIME},
{"current_timestamp", CURRENT_TIMESTAMP},
......@@ -87,6 +89,7 @@ static ScanKeyword ScanKeywords[] = {
{"double", DOUBLE},
{"drop", DROP},
{"each", EACH},
{"encoding", ENCODING},
{"end", END_TRANS},
{"execute", EXECUTE},
{"exists", EXISTS},
......@@ -113,6 +116,7 @@ static ScanKeyword ScanKeywords[] = {
{"inherits", INHERITS},
{"inner", INNER_P},
{"insert", INSERT},
{"insensitive", INSENSITIVE},
{"instead", INSTEAD},
{"interval", INTERVAL},
{"into", INTO},
......@@ -136,10 +140,12 @@ static ScanKeyword ScanKeywords[] = {
{"minvalue", MINVALUE},
{"month", MONTH_P},
{"move", MOVE},
{"names", NAMES},
{"national", NATIONAL},
{"natural", NATURAL},
{"nchar", NCHAR},
{"new", NEW},
{"next", NEXT},
{"no", NO},
{"nocreatedb", NOCREATEDB},
{"nocreateuser", NOCREATEUSER},
......@@ -152,7 +158,9 @@ static ScanKeyword ScanKeywords[] = {
{"numeric", NUMERIC},
{"of", OF},
{"oids", OIDS},
{"old", CURRENT},
{"on", ON},
{"only", ONLY},
{"operator", OPERATOR},
{"option", OPTION},
{"or", OR},
......@@ -163,12 +171,15 @@ static ScanKeyword ScanKeywords[] = {
{"position", POSITION},
{"precision", PRECISION},
{"primary", PRIMARY},
{"prior", PRIOR},
{"privileges", PRIVILEGES},
{"procedural", PROCEDURAL},
{"procedure", PROCEDURE},
{"public", PUBLIC},
{"read", READ},
{"recipe", RECIPE},
{"references", REFERENCES},
{"relative", RELATIVE},
{"rename", RENAME},
{"reset", RESET},
{"returns", RETURNS},
......@@ -177,9 +188,11 @@ static ScanKeyword ScanKeywords[] = {
{"rollback", ROLLBACK},
{"row", ROW},
{"rule", RULE},
{"scroll", SCROLL},
{"second", SECOND_P},
{"select", SELECT},
{"sequence", SEQUENCE},
{"serial", SERIAL},
{"set", SET},
{"setof", SETOF},
{"show", SHOW},
......@@ -190,6 +203,7 @@ static ScanKeyword ScanKeywords[] = {
{"substring", SUBSTRING},
{"table", TABLE},
{"time", TIME},
{"timestamp", TIMESTAMP},
{"timezone_hour", TIMEZONE_HOUR},
{"timezone_minute", TIMEZONE_MINUTE},
{"to", TO},
......
......@@ -34,7 +34,6 @@
#undef yywrap
#endif /* yywrap */
int debugging = 0;
extern YYSTYPE yylval;
int llen;
char literal[MAX_PARSE_BUFFER];
......
This diff is collapsed.
......@@ -20,6 +20,21 @@ mm_alloc(size_t size)
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 */
static struct ECPGstruct_member *
struct_member_dup(struct ECPGstruct_member * rm)
......
......@@ -52,7 +52,7 @@ exec sql declare cur cursor for
while (1) {
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);
}
......
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