From 579a29c59b94370c40a71168271aa5fb96f764c8 Mon Sep 17 00:00:00 2001 From: Drahflow Date: Thu, 5 Mar 2015 00:16:22 +0100 Subject: The nonbreaking-space hack is now official --- elymas/lib/ffi/pq.ey | 31 +++++++++++++++++++++++++++++++ examples/working-compiler/postgresql.test | 15 +++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 examples/working-compiler/postgresql.test diff --git a/elymas/lib/ffi/pq.ey b/elymas/lib/ffi/pq.ey index 0cf1d03..16997ab 100644 --- a/elymas/lib/ffi/pq.ey +++ b/elymas/lib/ffi/pq.ey @@ -171,6 +171,37 @@ > } ; -01 deffst }' each > } ; /connect deffd + + { + connect ==con + con .status { < + con .errorMessage ==msg + > ???io.ffi.pq } rep + + { # ==nsQuery + "" ==spaceQuery + { _ "([^ ]*) (.*)" regex } { -102 -- + spaceQuery -01 cat " " cat =spaceQuery + } loop spaceQuery -01 cat =spaceQuery + spaceQuery ==parameterCountTmp + 0 ==maxParameter + { parameterCountTmp "^(.*)\\$(\\d+)(.*)$" regex } { ==a ==p ==b + a b cat =parameterCountTmp + p txt .consume .u maxParameter max =maxParameter + } loop + + maxParameter { + maxParameter spaceQuery con .execParams + } { + spaceQuery con .exec + } ? * ":-" via + [ + { :-status |COMMAND_OK eq }' { :-clear }' + { :-status |TUPLES_OK eq }' { :-all :-clear }' + { 1 }' { < :-error ==msg > ???io.ffi.pq } + ] conds + } + } /functional deffd > /pq ffi .defv # vim: syn=elymas diff --git a/examples/working-compiler/postgresql.test b/examples/working-compiler/postgresql.test new file mode 100644 index 0000000..16c4bcf --- /dev/null +++ b/examples/working-compiler/postgresql.test @@ -0,0 +1,15 @@ +"lib/ffi.ey" include +"lib/ffi/pq.ey" include + +{ + "dbname=template1" ffi .pq .functional ">>" deffd + "2015-01-01" >>SELECT * FROM pg_stat_activity WHERE backend_start > $1 { ==row + row keys { ==k + k ": " cat row k . cat dump + } each + } each +} { + "Something went wrong with PostgresSQL: " -01 .msg cat die +} ?!io.ffi.pq + +# vim: syn=elymas -- cgit v1.2.3