[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kexi/3.1] src/migration/mdb/3rdparty/mdbtools: mdb-export: Add boolean words option (TRUE/FALSE)
From:       Jaroslaw Staniek <null () kde ! org>
Date:       2018-08-30 21:19:24
Message-ID: E1fvULc-0003tX-UN () code ! kde ! org
[Download RAW message or body]

Git commit 02c7769098885114bc5e9f1d8e962d1e93abca05 by Jaroslaw Staniek, on behalf of \
Ewen McNeill. Committed on 30/08/2018 at 20:52.
Pushed by staniek into branch '3.1'.

mdb-export: Add boolean words option (TRUE/FALSE)

Adds "-B" (--boolean-words) option to mdb-export, which will reconfigure
mdb/data.c to export TRUE/FALSE for boolean values instead of 1/0.  The
option is needed to support BOOLEAN fields on PostgreSQL, which will not
implicitly cast bare 1/0 into a BOOLEAN value.  Value literals are the
SQL TRUE/FALSE, and _quoted_ words meaning true/false and _quoted_
'1'/'0'.  With this flag the SQL TRUE/FALSE values are output, which should
work with several SQL databases.

PostgreSQL Reference:

http://www.postgresql.org/docs/current/static/datatype-boolean.html

(note for KEXI: note used but added to make data.c merges more cleanly)

FIXED-IN:3.1.1
mdbtools 8b1db6c08edbdf

M  +1    -0    src/migration/mdb/3rdparty/mdbtools/include/mdbtools.h
M  +22   -2    src/migration/mdb/3rdparty/mdbtools/libmdb/data.c

https://commits.kde.org/kexi/02c7769098885114bc5e9f1d8e962d1e93abca05

diff --git a/src/migration/mdb/3rdparty/mdbtools/include/mdbtools.h \
b/src/migration/mdb/3rdparty/mdbtools/include/mdbtools.h index 3910653a0..31f48c171 \
                100644
--- a/src/migration/mdb/3rdparty/mdbtools/include/mdbtools.h
+++ b/src/migration/mdb/3rdparty/mdbtools/include/mdbtools.h
@@ -553,6 +553,7 @@ extern LIBMDB_DLL size_t mdb_ole_read_next(MdbHandle *mdb, \
MdbColumn *col, void  extern LIBMDB_DLL size_t mdb_ole_read(MdbHandle *mdb, MdbColumn \
*col, void *ole_ptr, int chunk_size);  extern LIBMDB_DLL void* \
mdb_ole_read_full(MdbHandle *mdb, MdbColumn *col, size_t *size);  extern LIBMDB_DLL \
void mdb_set_date_fmt(const char *); +extern LIBMDB_DLL void \
mdb_set_boolean_fmt_words();  extern LIBMDB_DLL int mdb_read_row(MdbTableDef *table, \
unsigned int row);  
 /* dump.c */
diff --git a/src/migration/mdb/3rdparty/mdbtools/libmdb/data.c \
b/src/migration/mdb/3rdparty/mdbtools/libmdb/data.c index 5c4899371..40e3c76d3 100644
--- a/src/migration/mdb/3rdparty/mdbtools/libmdb/data.c
+++ b/src/migration/mdb/3rdparty/mdbtools/libmdb/data.c
@@ -44,6 +44,25 @@ void mdb_set_date_fmt(const char *fmt)
 		strncpy(date_fmt, fmt, 63);
 }
 
+/* Some databases (eg PostgreSQL) do not understand integer 0/1 values
+ * as TRUE/FALSE, so provide a means to override the values used to be
+ * the SQL Standard TRUE/FALSE values.
+ */
+static char boolean_false_number[] = "0";
+static char boolean_true_number[]  = "1";
+
+static char boolean_false_word[]   = "FALSE";
+static char boolean_true_word[]    = "TRUE";
+
+static char *boolean_false_value   = boolean_false_number;
+static char *boolean_true_value    = boolean_true_number;
+
+void mdb_set_boolean_fmt_words()
+{
+	boolean_false_value = boolean_false_word;
+	boolean_true_value  = boolean_true_word;
+}
+
 void mdb_bind_column(MdbTableDef *table, int col_num, void *bind_ptr, int *len_ptr)
 {
 	MdbColumn *col;
@@ -168,10 +187,11 @@ mdb_xfer_bound_bool(MdbHandle *mdb, MdbColumn *col, int value)
 {
 	col->cur_value_len = value;
 	if (col->bind_ptr) {
-		strcpy(col->bind_ptr, value ? "0" : "1");
+		strcpy(col->bind_ptr,
+                       value ? boolean_false_value : boolean_true_value);
 	}
 	if (col->len_ptr) {
-		*col->len_ptr = 1;
+		*col->len_ptr = strlen(col->bind_ptr);
 	}
 
 	return 1;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic