# HG changeset patch # User Timo Sirainen # Date 1507294356 -10800 # Node ID a8220182eac6a3687a39641be649ae35cb6196ab # Parent 1d2167636cc64cff83a3e47f6821e877b6dc3050 lib-sql: Add comments about NULL values. diff -r 1d2167636cc6 -r a8220182eac6 src/lib-sql/sql-api.h --- a/src/lib-sql/sql-api.h Tue May 15 17:50:27 2018 +0300 +++ b/src/lib-sql/sql-api.h Fri Oct 06 15:52:36 2017 +0300 @@ -178,15 +178,22 @@ /* Return field index for given name, or -1 if not found. */ int sql_result_find_field(struct sql_result *result, const char *field_name); -/* Returns value of given field as string. */ +/* Returns value of given field as string. Note that it can be NULL. */ const char *sql_result_get_field_value(struct sql_result *result, unsigned int idx); +/* Returns a binary value. Note that a NULL is returned as NULL with size=0, + while empty string returns non-NULL with size=0. */ const unsigned char * sql_result_get_field_value_binary(struct sql_result *result, unsigned int idx, size_t *size_r); +/* Find the field and return its value. NULL return value can mean that either + the field didn't exist or that its value is NULL. */ const char *sql_result_find_field_value(struct sql_result *result, const char *field_name); -/* Return all values of current row. */ +/* Return all values of current row. Note that this array is not + NULL-terminated - you must use sql_result_get_fields_count() to find out + the array's length. It's also possible that some of the values inside the + array are NULL. */ const char *const *sql_result_get_values(struct sql_result *result); /* Return last error message in result. */