summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1999-09-27 19:16:29 +0000
committerBruce Momjian <bruce@momjian.us>1999-09-27 19:16:29 +0000
commit3f5a1643879f56695830b32feadef10350698f77 (patch)
tree2186ab95aa56209d9ef726d2e0041795fb13c7a1 /src
parentebb618bc5d0db1f7006365c98df2283c0bffbafa (diff)
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')
-rw-r--r--src/interfaces/ecpg/ChangeLog5
-rw-r--r--src/interfaces/ecpg/include/ecpgerrno.h1
-rw-r--r--src/interfaces/ecpg/lib/ecpglib.c14
3 files changed, 20 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index 2738caf6a98..961cd416109 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -1,3 +1,8 @@
+Tue Aug 24 15:53:28 MEST 1999
+
+ - made NULL a valid bool value
+ - check for indicator variables on NULL
+
Wed Feb 11 10:58:13 CET 1998
- Added '-d' option to turn on debugging.
diff --git a/src/interfaces/ecpg/include/ecpgerrno.h b/src/interfaces/ecpg/include/ecpgerrno.h
index a3bc132497d..db2618f31d0 100644
--- a/src/interfaces/ecpg/include/ecpgerrno.h
+++ b/src/interfaces/ecpg/include/ecpgerrno.h
@@ -22,6 +22,7 @@
#define ECPG_FLOAT_FORMAT -206
#define ECPG_CONVERT_BOOL -207
#define ECPG_EMPTY -208
+#define ECPG_MISSING_INDICATOR -209
#define ECPG_NO_CONN -220
#define ECPG_NOT_CONN -221
diff --git a/src/interfaces/ecpg/lib/ecpglib.c b/src/interfaces/ecpg/lib/ecpglib.c
index de093895e0c..2b0067449f1 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.",