mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
- Fixed indicator in SET DESCRIPTOR.
- Added special handling of descriptor header information. - Some code cleanup.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* dynamic SQL support routines
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.10 2004/07/04 15:02:22 meskes Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.11 2004/07/05 09:45:53 meskes Exp $
|
||||
*/
|
||||
|
||||
#define POSTGRES_ECPG_INTERNAL
|
||||
@@ -430,6 +430,27 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
|
||||
return (true);
|
||||
}
|
||||
|
||||
bool
|
||||
ECPGset_desc_header(int lineno, char *desc_name, int count)
|
||||
{
|
||||
struct descriptor *desc;
|
||||
|
||||
for (desc = all_descriptors; desc; desc = desc->next)
|
||||
{
|
||||
if (strcmp(desc_name, desc->name)==0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (desc == NULL)
|
||||
{
|
||||
ECPGraise(lineno, ECPG_UNKNOWN_DESCRIPTOR, ECPG_SQLSTATE_INVALID_SQL_DESCRIPTOR_NAME, desc_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
desc->count = count;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ECPGset_desc(int lineno, char *desc_name, int index,...)
|
||||
{
|
||||
@@ -581,6 +602,7 @@ ECPGallocate_desc(int line, const char *name)
|
||||
ECPGfree(new);
|
||||
return false;
|
||||
}
|
||||
new->count = -1;
|
||||
new->items = NULL;
|
||||
new->result = PQmakeEmptyPGresult(NULL, 0);
|
||||
if (!new->result)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.36 2004/07/04 15:02:22 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.37 2004/07/05 09:45:53 meskes Exp $ */
|
||||
|
||||
/*
|
||||
* The aim is to get a simpler inteface to the database routines.
|
||||
@@ -1080,6 +1080,7 @@ ECPGexecute(struct statement * stmt)
|
||||
int hostvarl = 0;
|
||||
|
||||
tobeinserted = NULL;
|
||||
|
||||
/* A descriptor is a special case since it contains many variables but is listed only once. */
|
||||
if (var->type == ECPGt_descriptor)
|
||||
{
|
||||
@@ -1100,28 +1101,43 @@ ECPGexecute(struct statement * stmt)
|
||||
}
|
||||
|
||||
desc_counter++;
|
||||
for (desc_item = desc->items; desc_item; desc_item = desc_item->next)
|
||||
if (desc->count < 0 || desc->count >= desc_counter)
|
||||
{
|
||||
if (desc_item->num == desc_counter)
|
||||
for (desc_item = desc->items; desc_item; desc_item = desc_item->next)
|
||||
{
|
||||
desc_inlist.type = ECPGt_char;
|
||||
desc_inlist.value = desc_item->data;
|
||||
desc_inlist.pointer = &(desc_item->data);
|
||||
desc_inlist.varcharsize = strlen(desc_item->data);
|
||||
desc_inlist.arrsize = 1;
|
||||
desc_inlist.offset = 0;
|
||||
desc_inlist.ind_type = ECPGt_NO_INDICATOR;
|
||||
desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
|
||||
desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
|
||||
|
||||
if (!ECPGstore_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, &malloced))
|
||||
return false;
|
||||
|
||||
break;
|
||||
if (desc_item->num == desc_counter)
|
||||
{
|
||||
desc_inlist.type = ECPGt_char;
|
||||
desc_inlist.value = desc_item->data;
|
||||
desc_inlist.pointer = &(desc_item->data);
|
||||
desc_inlist.varcharsize = strlen(desc_item->data);
|
||||
desc_inlist.arrsize = 1;
|
||||
desc_inlist.offset = 0;
|
||||
if (!desc_item->indicator)
|
||||
{
|
||||
desc_inlist.ind_type = ECPGt_NO_INDICATOR;
|
||||
desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
|
||||
desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
desc_inlist.ind_type = ECPGt_int;
|
||||
desc_inlist.ind_value = &(desc_item->indicator);
|
||||
desc_inlist.ind_pointer = &(desc_inlist.ind_value);
|
||||
desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
|
||||
desc_inlist.ind_offset = 0;
|
||||
}
|
||||
if (!ECPGstore_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, &malloced))
|
||||
return false;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!desc_item) /* no more entries found in descriptor */
|
||||
if (!desc_item) /* no more entries found in descriptor */
|
||||
desc_counter = 0;
|
||||
}
|
||||
else
|
||||
desc_counter = 0;
|
||||
}
|
||||
else
|
||||
@@ -1129,6 +1145,7 @@ ECPGexecute(struct statement * stmt)
|
||||
if (!ECPGstore_input(stmt->lineno, stmt->force_indicator, var, &tobeinserted, &malloced))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tobeinserted)
|
||||
{
|
||||
/*
|
||||
|
Reference in New Issue
Block a user