Hello, I have been working on making SQLite usable on IBM z/OS. Apart from a different compile process, I think there is a glitch in sqlite's management of EBCDIC which should be fixed.

It is about newline character management. Below my analysis of the problem:

- Routine local_getline in shell.c uses fgets to read stdin. By design fgets (at least on z/OS) returns the newline character if read.

- The newline character is at code point 0x15 in all EBCDIC code pages (see https://en.wikipedia.org/wiki/Category:EBCDIC_code_pages).

- The EBCDIC version of table aiClass in sqlite3.c defines code point 0x15 as CC_ILLEGAL, this causes the shell to treat NL as illegal and reject any input as invalid.


The solution simply consists in changing the definition of code point 0x15 from CC_ILLEGAL (27) to CC_SPACE (07).

Below one line the patch generated for SQLite 3.26.0

--- sqlite3.c    2018-12-01 14:38:26.000000000 +0100
+++ sqlite3.c.mbz    2018-12-11 12:13:09.827955214 +0100
@@ -151296,7 +151296,7 @@
 #ifdef SQLITE_EBCDIC
 /*         x0  x1  x2  x3  x4  x5  x6  x7  x8  x9  xa xb xc  xd  xe  xf */
 /* 0x */   27, 27, 27, 27, 27,  7, 27, 27, 27, 27, 27, 27,  7,  7, 27, 27,
-/* 1x */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+/* 1x */   27, 27, 27, 27, 27,  7, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
 /* 2x */   27, 27, 27, 27, 27,  7, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
 /* 3x */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
 /* 4x */    7, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 26, 12, 17, 20, 10,


The above change has been working for me for several sqlite releases now. I would like to have it incorporated in the official source code as this would allow to compile and run official SQLite releases on z/OS unchanged.

Thank you,

mario


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to