diff options
author | Michael Meskes <meskes@postgresql.org> | 2004-07-05 09:45:54 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2004-07-05 09:45:54 +0000 |
commit | 073f7312a4c0aff9030ccc52010095a260c6a7a6 (patch) | |
tree | bc64a74145ae3c68e0b6466b25610447d1db95f8 /src/interfaces/ecpg/ecpglib/execute.c | |
parent | da09dea3e32fcc430102f6377caee24a2afe2101 (diff) | |
download | postgresql-073f7312a4c0aff9030ccc52010095a260c6a7a6.tar.gz postgresql-073f7312a4c0aff9030ccc52010095a260c6a7a6.zip |
- Fixed indicator in SET DESCRIPTOR.
- Added special handling of descriptor header information.
- Some code cleanup.
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/execute.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/execute.c | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index 6464ecb4b32..a3a601aed52 100644 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@ -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) { /* |