diff options
| author | Bruce Momjian <bruce@momjian.us> | 1999-09-27 19:16:29 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 1999-09-27 19:16:29 +0000 |
| commit | 3f5a1643879f56695830b32feadef10350698f77 (patch) | |
| tree | 2186ab95aa56209d9ef726d2e0041795fb13c7a1 /src/interfaces/ecpg/lib/ecpglib.c | |
| parent | ebb618bc5d0db1f7006365c98df2283c0bffbafa (diff) | |
| download | postgresql-3f5a1643879f56695830b32feadef10350698f77.tar.gz | |
Hello,
Two patches included:
- the first one enables the use of bool variables in fields which might
become NULL.
Up to now the lib told you that NULL is not a bool variable, even if
you provide a indicator.
- the second patch checks whether a value is null and issues an error if
no indicator is provided.
Sidenote: IIRC, the variable should be left alone if the value is NULL.
ECPGlib sets it's value to 0 on NULL. Is this a violation of the
standard?
Regards
Christof
Diffstat (limited to 'src/interfaces/ecpg/lib/ecpglib.c')
| -rw-r--r-- | src/interfaces/ecpg/lib/ecpglib.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/lib/ecpglib.c b/src/interfaces/ecpg/lib/ecpglib.c index de093895e0..2b0067449f 100644 --- a/src/interfaces/ecpg/lib/ecpglib.c +++ b/src/interfaces/ecpg/lib/ecpglib.c @@ -766,7 +766,16 @@ ECPGexecute(struct statement * stmt) case ECPGt_unsigned_long: ((long *) var->ind_value)[act_tuple] = -PQgetisnull(results, act_tuple, act_field); break; + case ECPGt_NO_INDICATOR: + if (PQgetisnull(results, act_tuple, act_field)) + { + register_error(ECPG_MISSING_INDICATOR, "NULL value without indicator variable on line %d.", stmt->lineno); + status = false; + } + break; default: + register_error(ECPG_UNSUPPORTED, "Unsupported indicator type %s on line %d.", ECPGtype_name(var->ind_type), stmt->lineno); + status = false; break; } @@ -891,6 +900,11 @@ ECPGexecute(struct statement * stmt) ((char *) var->value)[act_tuple] = true; break; } + else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field)) + { + // NULL is valid + break; + } } register_error(ECPG_CONVERT_BOOL, "Unable to convert %s to bool on line %d.", |
