summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Sergey Mironov <grrwlf@gmail.com>2013-09-13 10:09:15 -0400
committerGravatar Sergey Mironov <grrwlf@gmail.com>2013-09-13 10:09:15 -0400
commit99b557f9f4e8e71809323f752bd4e84747e9ec8b (patch)
tree01b069104bb26141e02fe356fd6d3832aac7ae4a /src
parent0c89ee7ead6a2108f9496e06baffa77c62e47556 (diff)
Add hex SQL syntax for blobs, such as X'0ABC12343'. Works with sqlite.
Diffstat (limited to 'src')
-rw-r--r--src/c/urweb.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c
index 0b4b5846..30e4d7a6 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -2509,7 +2509,7 @@ uw_Basis_string uw_Basis_sqlifyChar(uw_context ctx, uw_Basis_char c) {
char *uw_sqlsuffixBlob = "::bytea";
-uw_Basis_string uw_Basis_sqlifyBlob(uw_context ctx, uw_Basis_blob b) {
+uw_Basis_string uw_Basis_sqlifyBlob_old(uw_context ctx, uw_Basis_blob b) {
char *r, *s2;
size_t i;
@@ -2556,6 +2556,29 @@ uw_Basis_string uw_Basis_sqlifyBlob(uw_context ctx, uw_Basis_blob b) {
return r;
}
+int uw_Xstrings = 1;
+
+uw_Basis_string uw_Basis_sqlifyBlob(uw_context ctx, uw_Basis_blob b) {
+ char *r, *s2;
+ size_t i;
+
+ uw_check_heap(ctx, b.size * 2 + 3 + uw_Xstrings);
+
+ r = s2 = ctx->heap.front;
+ *s2++ = 'X';
+ *s2++ = '\'';
+
+ for (i = 0; i < b.size; ++i) {
+ char c = b.data[i];
+ sprintf(s2, "%02X", c);
+ s2 += 2;
+ }
+
+ *s2++ = '\'';
+ ctx->heap.front = s2 + 1;
+ return r;
+}
+
char *uw_Basis_sqlifyChannel(uw_context ctx, uw_Basis_channel chn) {
int len;
char *r;