Commit db07a3f4 authored by Michael Meskes's avatar Michael Meskes

- Synced preproc.y with gram.y.

- Include some patches by Christof Petig <christof.petig@wtal.de>.
parent 0c439e5e
......@@ -1086,3 +1086,8 @@ Wed Jun 13 14:39:12 CEST 2001
- Applied bug fix by John Summerfield.
- Set ecpg version to 2.9.0.
- Set library version to 3.3.0.
Son Aug 19 11:04:39 CEST 2001
- Synced preproc.y with gram.y.
- Include some patches by Christof Petig <christof.petig@wtal.de>.
......@@ -65,7 +65,7 @@ get_int_item(int lineno, void *var, enum ECPGttype vartype, int value)
{
switch (vartype)
{
case ECPGt_short:
case ECPGt_short:
*(short *) var = (short) value;
break;
case ECPGt_int:
......@@ -143,13 +143,16 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
va_list args;
PGresult *ECPGresult = ECPGresultByDescriptor(lineno, desc_name);
enum ECPGdtype type;
bool DataButNoIndicator = false;
bool Indicator_seen = false,
Data_seen = false;
int ntuples, act_tuple;
va_start(args, index);
if (!ECPGresult)
return (false);
if (PQntuples(ECPGresult) < 1)
ntuples = PQntuples(ECPGresult);
if (ntuples < 1)
{
ECPGraise(lineno, ECPG_NOT_FOUND, NULL);
return (false);
......@@ -184,10 +187,23 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
switch (type)
{
case (ECPGd_indicator):
if (!get_int_item(lineno, var, vartype, -PQgetisnull(ECPGresult, 0, index)))
return (false);
ECPGlog("ECPGget_desc: INDICATOR = %d\n", -PQgetisnull(ECPGresult, 0, index));
/* this is like ECPGexecute
* missing : allocate arrays, perhaps this should go into
* a common function !!
*/
if (ntuples > arrsize)
{ ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
lineno, ntuples, arrsize);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL);
return false;
}
Indicator_seen = true;
for (act_tuple = 0; act_tuple < ntuples ; act_tuple++)
{ if (!get_int_item(lineno, var, vartype, -PQgetisnull(ECPGresult, act_tuple, index)))
return (false);
var = (char*)var + offset;
ECPGlog("ECPGget_desc: INDICATOR[%d] = %d\n", act_tuple, -PQgetisnull(ECPGresult, act_tuple, index));
}
break;
case ECPGd_name:
......@@ -225,10 +241,22 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
case ECPGd_ret_length:
case ECPGd_ret_octet:
if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, 0, index)))
return (false);
ECPGlog("ECPGget_desc: RETURNED = %d\n", PQgetlength(ECPGresult, 0, index));
/* this is like ECPGexecute
* missing : allocate arrays, perhaps this should go into
* a common function !!
*/
if (ntuples > arrsize)
{ ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
lineno, ntuples, arrsize);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL);
return false;
}
for (act_tuple = 0; act_tuple < ntuples ; act_tuple++)
{ if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, act_tuple, index)))
return (false);
var = (char*)var + offset;
ECPGlog("ECPGget_desc: RETURNED[%d] = %d\n", act_tuple, PQgetlength(ECPGresult, act_tuple, index));
}
break;
case ECPGd_octet:
......@@ -259,9 +287,32 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType_DDT(PQftype(ECPGresult, index)));
break;
case ECPGd_data:
if (!get_data(ECPGresult, 0, index, lineno, vartype, ECPGt_NO_INDICATOR, var, NULL, varcharsize, offset, false))
/* this is like ECPGexecute
* missing : allocate arrays, perhaps this should go into
* a common function !!
*/
if (ntuples > arrsize)
{ ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
lineno, ntuples, arrsize);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL);
return false;
}
Data_seen = true;
for (act_tuple = 0; act_tuple < ntuples ; act_tuple++)
{ if (PQgetisnull(ECPGresult, act_tuple, index))
continue; /* do not touch data on null value */
if (!get_data(ECPGresult, act_tuple, index, lineno,
vartype, ECPGt_NO_INDICATOR, var, NULL,
varcharsize, offset, false))
return (false);
}
break;
case ECPGd_cardinality:
if (!get_int_item(lineno, var, vartype, PQntuples(ECPGresult)))
return (false);
ECPGlog("ECPGget_desc: CARDINALITY = %d\n", PQntuples(ECPGresult));
break;
default:
......@@ -273,10 +324,15 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
type = va_arg(args, enum ECPGdtype);
}
if (DataButNoIndicator && PQgetisnull(ECPGresult, 0, index))
{
ECPGraise(lineno, ECPG_MISSING_INDICATOR, NULL);
return (false);
if (Data_seen && !Indicator_seen)
{
for (act_tuple = 0; act_tuple < ntuples ; act_tuple++)
{ if (PQgetisnull(ECPGresult, act_tuple, index))
{
ECPGraise(lineno, ECPG_MISSING_INDICATOR, NULL);
return (false);
}
}
}
return (true);
......
......@@ -812,6 +812,9 @@ ECPGexecute(struct statement * stmt)
ECPGraise(stmt->lineno, ECPG_PGSQL, PQerrorMessage(stmt->connection->connection));
}
else
/* note: since some of the following code is duplicated in descriptor.c
* it should go into a separate function
*/
{
var = stmt->outlist;
switch (PQresultStatus(results))
......@@ -1032,7 +1035,7 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
*
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
*
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.20 2001/08/10 22:50:10 tgl Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.21 2001/08/19 09:21:44 meskes Exp $
*/
PGconn *ECPG_internal_get_connection(char *name);
......
/*
* functions needed for descriptor handling
*
* since descriptor might be either a string constant or a string var
* we need to check for a constant if we expect a constant
*/
#include "postgres_fe.h"
......@@ -71,7 +74,11 @@ static struct descriptor *descriptors;
void
add_descriptor(char *name, char *connection)
{
struct descriptor *new = (struct descriptor *) mm_alloc(sizeof(struct descriptor));
struct descriptor *new;
if (name[0]!='"') return;
new = (struct descriptor *) mm_alloc(sizeof(struct descriptor));
new->next = descriptors;
new->name = mm_alloc(strlen(name) + 1);
......@@ -92,6 +99,8 @@ drop_descriptor(char *name, char *connection)
struct descriptor *i;
struct descriptor **lastptr = &descriptors;
if (name[0]!='"') return;
for (i = descriptors; i; lastptr = &i->next, i = i->next)
{
if (!strcmp(name, i->name))
......@@ -119,6 +128,8 @@ lookup_descriptor(char *name, char *connection)
{
struct descriptor *i;
if (name[0]!='"') return NULL;
for (i = descriptors; i; i = i->next)
{
if (!strcmp(name, i->name))
......@@ -139,7 +150,7 @@ output_get_descr_header(char *desc_name)
{
struct assignment *results;
fprintf(yyout, "{ ECPGget_desc_header(%d, \"%s\", &(", yylineno, desc_name);
fprintf(yyout, "{ ECPGget_desc_header(%d, %s, &(", yylineno, desc_name);
for (results = assignments; results != NULL; results = results->next)
{
if (results->value == ECPGd_count)
......@@ -161,7 +172,7 @@ output_get_descr(char *desc_name, char *index)
{
struct assignment *results;
fprintf(yyout, "{ ECPGget_desc(%d,\"%s\",%s,", yylineno, desc_name, index);
fprintf(yyout, "{ ECPGget_desc(%d, %s, %s,", yylineno, desc_name, index);
for (results = assignments; results != NULL; results = results->next)
{
const struct variable *v = find_variable(results->variable);
......
......@@ -4,7 +4,7 @@
* lexical token lookup for reserved words in postgres embedded SQL
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.23 2001/03/22 04:01:20 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.24 2001/08/19 09:21:44 meskes Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -29,6 +29,7 @@ static ScanKeyword ScanKeywords[] = {
{"bool", SQL_BOOL},
{"break", SQL_BREAK},
{"call", SQL_CALL},
{"cardinality", SQL_CARDINALITY},
{"connect", SQL_CONNECT},
{"connection", SQL_CONNECTION},
{"continue", SQL_CONTINUE},
......
......@@ -111,7 +111,7 @@ output_statement(char *stmt, int mode, char *descriptor, char *con)
if (descriptor == NULL)
fprintf(yyout, "{ ECPGdo(__LINE__, %s, \"", con ? con : "NULL");
else
fprintf(yyout, "{ ECPGdo_descriptor(__LINE__, %s, \"%s\", \"",
fprintf(yyout, "{ ECPGdo_descriptor(__LINE__, %s, %s, \"",
con ? con : "NULL", descriptor);
/* do this char by char as we have to filter '\"' */
......
This diff is collapsed.
......@@ -480,6 +480,8 @@ get_dtype(enum ECPGdtype typ)
case ECPGd_type:
return ("ECPGd_type");
break;
case ECPGd_cardinality:
return ("ECPGd_cardinality");
default:
sprintf(errortext, "illegal descriptor item %d\n", typ);
yyerror(errortext);
......
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