[MonetDB-users] PHP XQuery error
Hi everyone, I am a new MonetDB user. I am specifically interested in MonetDB's XQuery support with client access through PHP. I currently get parsing errors when trying any kind of XQuery through the PHP module. I'm wondering if this is a a bug in the client or if I am possibly doing something wrong. E.g.: #!/usr/bin/env php <?php $db = monetdb_connect('xquery', 'localhost', 50000, 'monetdb', 'monetdb') or die ("Failed to connect\n"); $query = 'count(1,2,3,4)'; $res = monetdb_query($query); ?> Results in: Warning: monetdb_query(): Query failed: parse error: syntax error, unexpected ;, expecting $end on line 1, column 15 (next token is `;') !parse error: XQuery parsing failed in /home/user/monet.php on line 6 ... for any variation of an XQuery. I have tried the server from the Ubuntu repository as well as I've built it from source with the same results. Here is my environment: PHP 5.2.6-3ubuntu4.1 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 23 2009 14:37:14) Ubuntu 9.04: Linux ubuntu 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:45:36 UTC 2009 x86_64 GNU/Linux Mserver --dbinit="module(pathfinder);" # MonetDB Server v4.30.4 # based on GDK v1.30.4 # Copyright (c) 1993-July 2008, CWI. All rights reserved. # Copyright (c) August 2008-2009, MonetDB B.V.. All rights reserved. # Compiled for x86_64-pc-linux-gnu/64bit with 64bit OIDs; dynamically linked. # Visit http://monetdb.cwi.nl/ for further information. # PF/Tijah module v0.13.0 loaded. http://dbappl.cs.utwente.nl/pftijah # MonetDB/XQuery module v0.28.3 loaded (default back-end is 'algebra') # XRPC administrative console at http://127.0.0.1:50001/admin MonetDB> Thanks for any insight! - Gene Stevens
Dear Gene, I'm not sure, whether MonetDB's PHP interface has ever been tested with XQuery; hence, we're very much interested in your experiences and feedback ;-) Regarding the error you encounter, this is due to the fact that your query is not correct XQuery. Instead of count(1,2,3,4) you probably meant count((1,2,3,4)) right? You can also check, whether MonetDB/XQuery (or more precisely its Pathfinder XQuery compiler) does "like" your queries by checking them with the stand-alone compiler "pf", or with "mclient" (the latter requires a running MonetDB/XQuery server): $ echo 'count(1,2,3,4)' | pf > /tmp/x.mil error in function application: at (1,1-1,14): wrong number of arguments for function `fn:count' (expected 1, got 4) # halted in /ufs/manegold/_/scratch0/Monet/Testing/Stable/source/pathfinder/compiler/semantics/functions.c (check_fun_usage), line 361 $ mclient -lxquery -s'count(1,2,3,4)' MAPI = monetdb@localhost:50000 QUERY = count(1,2,3,4) ERROR = !error in function application: at (1,1-1,14): wrong number of arguments for function `fn:count' (expected 1, got 4) !# halted in !# /ufs/manegold/_/scratch0/Monet/Testing/Stable/source/pathfinder/compiler/semantics/functions.c !# /(check_fun_usage), line 361 $ mclient -lxquery -s'count((1,2,3,4))' 4 $ echo 'count((1,2,3,4))' | pf > /tmp/y.mil $ wc -l /tmp/[xy].mil 0 /tmp/x.mil 110 /tmp/y.mil 110 total Hope this helps you further... Stefan On Sat, Aug 08, 2009 at 07:56:40AM -0600, Gene Stevens wrote:
Hi everyone,
I am a new MonetDB user. I am specifically interested in MonetDB's XQuery support with client access through PHP.
I currently get parsing errors when trying any kind of XQuery through the PHP module. I'm wondering if this is a a bug in the client or if I am possibly doing something wrong. E.g.:
#!/usr/bin/env php <?php $db = monetdb_connect('xquery', 'localhost', 50000, 'monetdb', 'monetdb') or die ("Failed to connect\n"); $query = 'count(1,2,3,4)'; $res = monetdb_query($query); ?>
Results in:
Warning: monetdb_query(): Query failed: parse error: syntax error, unexpected ;, expecting $end on line 1, column 15 (next token is `;') !parse error: XQuery parsing failed in /home/user/monet.php on line 6
... for any variation of an XQuery. I have tried the server from the Ubuntu repository as well as I've built it from source with the same results.
Here is my environment:
PHP 5.2.6-3ubuntu4.1 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 23 2009 14:37:14) Ubuntu 9.04: Linux ubuntu 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:45:36 UTC 2009 x86_64 GNU/Linux
Mserver --dbinit="module(pathfinder);" # MonetDB Server v4.30.4 # based on GDK v1.30.4 # Copyright (c) 1993-July 2008, CWI. All rights reserved. # Copyright (c) August 2008-2009, MonetDB B.V.. All rights reserved. # Compiled for x86_64-pc-linux-gnu/64bit with 64bit OIDs; dynamically linked. # Visit http://monetdb.cwi.nl/ for further information. # PF/Tijah module v0.13.0 loaded. http://dbappl.cs.utwente.nl/pftijah # MonetDB/XQuery module v0.28.3 loaded (default back-end is 'algebra') # XRPC administrative console at http://127.0.0.1:50001/admin MonetDB>
Thanks for any insight! - Gene Stevens
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
Hello Gene,
I think you might have found a bug in the PHP client. The PHP client
might only have been tested with SQL and not with XQuery. When using
the SQL language, a semi-colon may be automatically added at the end
of a statement, but when using XQuery that should of course not be
done.
However, you will get an error anyway with the current query. The
error you should have gotten is:
error in function application: at (1,1-1,14): wrong number of
arguments for function `fn:count' (expected 1, got 4)
# halted in functions.c (check_fun_usage), line 361
You should change your query to something like: "count((1,2,3,4))" or
"count(1 to 4)"
Greetings,
Wouter
2009/8/8 Gene Stevens
Hi everyone,
I am a new MonetDB user. I am specifically interested in MonetDB's XQuery support with client access through PHP.
I currently get parsing errors when trying any kind of XQuery through the PHP module. I'm wondering if this is a a bug in the client or if I am possibly doing something wrong. E.g.:
#!/usr/bin/env php <?php $db = monetdb_connect('xquery', 'localhost', 50000, 'monetdb', 'monetdb') or die ("Failed to connect\n"); $query = 'count(1,2,3,4)'; $res = monetdb_query($query); ?>
Results in:
Warning: monetdb_query(): Query failed: parse error: syntax error, unexpected ;, expecting $end on line 1, column 15 (next token is `;') !parse error: XQuery parsing failed in /home/user/monet.php on line 6
.... for any variation of an XQuery. I have tried the server from the Ubuntu repository as well as I've built it from source with the same results.
Here is my environment:
PHP 5.2.6-3ubuntu4.1 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 23 2009 14:37:14) Ubuntu 9.04: Linux ubuntu 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:45:36 UTC 2009 x86_64 GNU/Linux
Mserver --dbinit="module(pathfinder);" # MonetDB Server v4.30.4 # based on GDK v1.30.4 # Copyright (c) 1993-July 2008, CWI. All rights reserved. # Copyright (c) August 2008-2009, MonetDB B.V.. All rights reserved. # Compiled for x86_64-pc-linux-gnu/64bit with 64bit OIDs; dynamically linked. # Visit http://monetdb.cwi.nl/ for further information. # PF/Tijah module v0.13.0 loaded. http://dbappl.cs.utwente.nl/pftijah # MonetDB/XQuery module v0.28.3 loaded (default back-end is 'algebra') # XRPC administrative console at http://127.0.0.1:50001/admin MonetDB>
Thanks for any insight! - Gene Stevens
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
Hi Wouter and Stefan, Thanks so much for your replies. I apologize for the simple XQuery error below: I tried to clean up and test a simple example before posting to the list ...oops. As you can tell, the error is the same even with a corrected sequence: "count((1,2,3,4))". I've been using XQuery for about two years now, mostly with BDB XML daemonized within our own servers. I found this project just the other day and it very much piqued my curiosity and got me a little excited after my ultimately disappointing experience with Oracle's product, their query planner in particular. I'm very interested to see how this database handles XML/XQuery, performance-wise, specifically for analytical workloads on large data sets: think analysis/reporting on billions of audit events. But I have a number of projects with different needs where MonetDB might be valuable. I am not a C developer (I'm a PHP/XML web services developer), but if there is anything I can do to help, please let me know. Thanks - Gene Stevens On Aug 8, 2009, at 8:42 AM, Wouter Alink wrote:
Hello Gene,
I think you might have found a bug in the PHP client. The PHP client might only have been tested with SQL and not with XQuery. When using the SQL language, a semi-colon may be automatically added at the end of a statement, but when using XQuery that should of course not be done.
However, you will get an error anyway with the current query. The error you should have gotten is:
error in function application: at (1,1-1,14): wrong number of arguments for function `fn:count' (expected 1, got 4) # halted in functions.c (check_fun_usage), line 361
You should change your query to something like: "count((1,2,3,4))" or "count(1 to 4)"
Greetings, Wouter
2009/8/8 Gene Stevens
: Hi everyone,
I am a new MonetDB user. I am specifically interested in MonetDB's XQuery support with client access through PHP.
I currently get parsing errors when trying any kind of XQuery through the PHP module. I'm wondering if this is a a bug in the client or if I am possibly doing something wrong. E.g.:
#!/usr/bin/env php <?php $db = monetdb_connect('xquery', 'localhost', 50000, 'monetdb', 'monetdb') or die ("Failed to connect\n"); $query = 'count(1,2,3,4)'; $res = monetdb_query($query); ?>
Results in:
Warning: monetdb_query(): Query failed: parse error: syntax error, unexpected ;, expecting $end on line 1, column 15 (next token is `;') !parse error: XQuery parsing failed in /home/user/monet.php on line 6
.... for any variation of an XQuery. I have tried the server from the Ubuntu repository as well as I've built it from source with the same results.
Here is my environment:
PHP 5.2.6-3ubuntu4.1 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 23 2009 14:37:14) Ubuntu 9.04: Linux ubuntu 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:45:36 UTC 2009 x86_64 GNU/Linux
Mserver --dbinit="module(pathfinder);" # MonetDB Server v4.30.4 # based on GDK v1.30.4 # Copyright (c) 1993-July 2008, CWI. All rights reserved. # Copyright (c) August 2008-2009, MonetDB B.V.. All rights reserved. # Compiled for x86_64-pc-linux-gnu/64bit with 64bit OIDs; dynamically linked. # Visit http://monetdb.cwi.nl/ for further information. # PF/Tijah module v0.13.0 loaded. http://dbappl.cs.utwente.nl/pftijah # MonetDB/XQuery module v0.28.3 loaded (default back-end is 'algebra') # XRPC administrative console at http://127.0.0.1:50001/admin MonetDB>
Thanks for any insight! - Gene Stevens
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
I don't know whether you compiled from sources, but the following path
in the clients package should do the trick... (haven't tested it
properly).
$ cvs diff -u src/php/Cimpl/php_monetdb.c
Index: src/php/Cimpl/php_monetdb.c
===================================================================
RCS file: /cvsroot/monetdb/clients/src/php/Cimpl/php_monetdb.c,v
retrieving revision 1.14
diff -u -r1.14 php_monetdb.c
--- src/php/Cimpl/php_monetdb.c 15 May 2009 12:31:28 -0000 1.14
+++ src/php/Cimpl/php_monetdb.c 9 Aug 2009 09:06:32 -0000
@@ -923,7 +923,12 @@
len = strlen(Z_STRVAL_PP(query));
myq = alloca(sizeof(char) * (len + 2));
memcpy(myq, Z_STRVAL_PP(query), len + 1);
- myq[len++] = ';';
+
+ /* only add the ';' for languages that use ';' as statement
delimiter (all but xquery). */
+ if (strcmp(mapi_get_lang(monetdb),"xquery") != 0) {
+ myq[len++] = ';';
+ }
+
myq[len] = '\0';
monetdb_result = mapi_query(monetdb, myq);
if ((MG(auto_reset_persistent) & 2) && monetdb_result == NULL) {
2009/8/8 Gene Stevens
Hi Wouter and Stefan,
Thanks so much for your replies. I apologize for the simple XQuery error below: I tried to clean up and test a simple example before posting to the list ...oops. As you can tell, the error is the same even with a corrected sequence: "count((1,2,3,4))".
I've been using XQuery for about two years now, mostly with BDB XML daemonized within our own servers. I found this project just the other day and it very much piqued my curiosity and got me a little excited after my ultimately disappointing experience with Oracle's product, their query planner in particular. I'm very interested to see how this database handles XML/XQuery, performance-wise, specifically for analytical workloads on large data sets: think analysis/reporting on billions of audit events. But I have a number of projects with different needs where MonetDB might be valuable.
I am not a C developer (I'm a PHP/XML web services developer), but if there is anything I can do to help, please let me know.
Thanks - Gene Stevens
On Aug 8, 2009, at 8:42 AM, Wouter Alink wrote:
Hello Gene,
I think you might have found a bug in the PHP client. The PHP client might only have been tested with SQL and not with XQuery. When using the SQL language, a semi-colon may be automatically added at the end of a statement, but when using XQuery that should of course not be done.
However, you will get an error anyway with the current query. The error you should have gotten is:
error in function application: at (1,1-1,14): wrong number of arguments for function `fn:count' (expected 1, got 4) # halted in functions.c (check_fun_usage), line 361
You should change your query to something like: "count((1,2,3,4))" or "count(1 to 4)"
Greetings, Wouter
2009/8/8 Gene Stevens
: Hi everyone,
I am a new MonetDB user. I am specifically interested in MonetDB's XQuery support with client access through PHP.
I currently get parsing errors when trying any kind of XQuery through the PHP module. I'm wondering if this is a a bug in the client or if I am possibly doing something wrong. E.g.:
#!/usr/bin/env php <?php $db = monetdb_connect('xquery', 'localhost', 50000, 'monetdb', 'monetdb') or die ("Failed to connect\n"); $query = 'count(1,2,3,4)'; $res = monetdb_query($query); ?>
Results in:
Warning: monetdb_query(): Query failed: parse error: syntax error, unexpected ;, expecting $end on line 1, column 15 (next token is `;') !parse error: XQuery parsing failed in /home/user/monet.php on line 6
.... for any variation of an XQuery. I have tried the server from the Ubuntu repository as well as I've built it from source with the same results.
Here is my environment:
PHP 5.2.6-3ubuntu4.1 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 23 2009 14:37:14) Ubuntu 9.04: Linux ubuntu 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:45:36 UTC 2009 x86_64 GNU/Linux
Mserver --dbinit="module(pathfinder);" # MonetDB Server v4.30.4 # based on GDK v1.30.4 # Copyright (c) 1993-July 2008, CWI. All rights reserved. # Copyright (c) August 2008-2009, MonetDB B.V.. All rights reserved. # Compiled for x86_64-pc-linux-gnu/64bit with 64bit OIDs; dynamically linked. # Visit http://monetdb.cwi.nl/ for further information. # PF/Tijah module v0.13.0 loaded. http://dbappl.cs.utwente.nl/pftijah # MonetDB/XQuery module v0.28.3 loaded (default back-end is 'algebra') # XRPC administrative console at http://127.0.0.1:50001/admin MonetDB>
Thanks for any insight! - Gene Stevens
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
Hi Wouter, Thanks a bunch. That fixed the error: #!/usr/bin/env php <?php $db = monetdb_connect('xquery', 'localhost', 50000, 'monetdb', 'monetdb') or die ("Failed to connect\n"); $res = monetdb_query('<node>{ for $i in (1,2,3,4) return $i }</node>'); while ($row = monetdb_fetch_row($res)) { var_dump($row); } ?> ...produces this result: array(1) { [0]=> string(20) "<node>1 2 3 4</node>" } - Gene Stevens On Aug 9, 2009, at 3:21 AM, Wouter Alink wrote:
I don't know whether you compiled from sources, but the following path in the clients package should do the trick... (haven't tested it properly).
$ cvs diff -u src/php/Cimpl/php_monetdb.c Index: src/php/Cimpl/php_monetdb.c =================================================================== RCS file: /cvsroot/monetdb/clients/src/php/Cimpl/php_monetdb.c,v retrieving revision 1.14 diff -u -r1.14 php_monetdb.c --- src/php/Cimpl/php_monetdb.c 15 May 2009 12:31:28 -0000 1.14 +++ src/php/Cimpl/php_monetdb.c 9 Aug 2009 09:06:32 -0000 @@ -923,7 +923,12 @@ len = strlen(Z_STRVAL_PP(query)); myq = alloca(sizeof(char) * (len + 2)); memcpy(myq, Z_STRVAL_PP(query), len + 1); - myq[len++] = ';'; + + /* only add the ';' for languages that use ';' as statement delimiter (all but xquery). */ + if (strcmp(mapi_get_lang(monetdb),"xquery") != 0) { + myq[len++] = ';'; + } + myq[len] = '\0'; monetdb_result = mapi_query(monetdb, myq); if ((MG(auto_reset_persistent) & 2) && monetdb_result == NULL) {
2009/8/8 Gene Stevens
: Hi Wouter and Stefan,
Thanks so much for your replies. I apologize for the simple XQuery error below: I tried to clean up and test a simple example before posting to the list ...oops. As you can tell, the error is the same even with a corrected sequence: "count((1,2,3,4))".
I've been using XQuery for about two years now, mostly with BDB XML daemonized within our own servers. I found this project just the other day and it very much piqued my curiosity and got me a little excited after my ultimately disappointing experience with Oracle's product, their query planner in particular. I'm very interested to see how this database handles XML/XQuery, performance-wise, specifically for analytical workloads on large data sets: think analysis/reporting on billions of audit events. But I have a number of projects with different needs where MonetDB might be valuable.
I am not a C developer (I'm a PHP/XML web services developer), but if there is anything I can do to help, please let me know.
Thanks - Gene Stevens
On Aug 8, 2009, at 8:42 AM, Wouter Alink wrote:
Hello Gene,
I think you might have found a bug in the PHP client. The PHP client might only have been tested with SQL and not with XQuery. When using the SQL language, a semi-colon may be automatically added at the end of a statement, but when using XQuery that should of course not be done.
However, you will get an error anyway with the current query. The error you should have gotten is:
error in function application: at (1,1-1,14): wrong number of arguments for function `fn:count' (expected 1, got 4) # halted in functions.c (check_fun_usage), line 361
You should change your query to something like: "count((1,2,3,4))" or "count(1 to 4)"
Greetings, Wouter
2009/8/8 Gene Stevens
: Hi everyone,
I am a new MonetDB user. I am specifically interested in MonetDB's XQuery support with client access through PHP.
I currently get parsing errors when trying any kind of XQuery through the PHP module. I'm wondering if this is a a bug in the client or if I am possibly doing something wrong. E.g.:
#!/usr/bin/env php <?php $db = monetdb_connect('xquery', 'localhost', 50000, 'monetdb', 'monetdb') or die ("Failed to connect\n"); $query = 'count(1,2,3,4)'; $res = monetdb_query($query); ?>
Results in:
Warning: monetdb_query(): Query failed: parse error: syntax error, unexpected ;, expecting $end on line 1, column 15 (next token is `;') !parse error: XQuery parsing failed in /home/user/monet.php on line 6
.... for any variation of an XQuery. I have tried the server from the Ubuntu repository as well as I've built it from source with the same results.
Here is my environment:
PHP 5.2.6-3ubuntu4.1 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 23 2009 14:37:14) Ubuntu 9.04: Linux ubuntu 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:45:36 UTC 2009 x86_64 GNU/Linux
Mserver --dbinit="module(pathfinder);" # MonetDB Server v4.30.4 # based on GDK v1.30.4 # Copyright (c) 1993-July 2008, CWI. All rights reserved. # Copyright (c) August 2008-2009, MonetDB B.V.. All rights reserved. # Compiled for x86_64-pc-linux-gnu/64bit with 64bit OIDs; dynamically linked. # Visit http://monetdb.cwi.nl/ for further information. # PF/Tijah module v0.13.0 loaded. http://dbappl.cs.utwente.nl/pftijah # MonetDB/XQuery module v0.28.3 loaded (default back-end is 'algebra') # XRPC administrative console at http://127.0.0.1:50001/admin MonetDB>
Thanks for any insight! - Gene Stevens
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
Hello Gene,
I had some more time to look at the issue. It seems that the PHP
interface still does not produce the expected behavior when a query
returns multiple results. This doesn't affect your query as your query
only yields 1 result.
In my opinion a different row should be available for each item in the
sequence of results. An example: a query like "1 to 4" should return 4
rows with 1 column, containing 1, 2, 3, and 4 respectively. Currently
it doesn't seem to do so. I added a test for this, so we can monitor
the status through our testweb, but probably someone more familiar
with the MonetDB/PHP interface code should have a look at how to fix
this.
Greetings,
Wouter
2009/8/9 Gene Stevens
Hi Wouter,
Thanks a bunch. That fixed the error:
#!/usr/bin/env php <?php $db = monetdb_connect('xquery', 'localhost', 50000, 'monetdb', 'monetdb') or die ("Failed to connect\n"); $res = monetdb_query('<node>{ for $i in (1,2,3,4) return $i }</node>'); while ($row = monetdb_fetch_row($res)) { var_dump($row); } ?>
....produces this result:
array(1) { [0]=> string(20) "<node>1 2 3 4</node>" }
- Gene Stevens
On Aug 9, 2009, at 3:21 AM, Wouter Alink wrote:
I don't know whether you compiled from sources, but the following path in the clients package should do the trick... (haven't tested it properly).
$ cvs diff -u src/php/Cimpl/php_monetdb.c Index: src/php/Cimpl/php_monetdb.c =================================================================== RCS file: /cvsroot/monetdb/clients/src/php/Cimpl/php_monetdb.c,v retrieving revision 1.14 diff -u -r1.14 php_monetdb.c --- src/php/Cimpl/php_monetdb.c 15 May 2009 12:31:28 -0000 1.14 +++ src/php/Cimpl/php_monetdb.c 9 Aug 2009 09:06:32 -0000 @@ -923,7 +923,12 @@ len = strlen(Z_STRVAL_PP(query)); myq = alloca(sizeof(char) * (len + 2)); memcpy(myq, Z_STRVAL_PP(query), len + 1); - myq[len++] = ';'; + + /* only add the ';' for languages that use ';' as statement delimiter (all but xquery). */ + if (strcmp(mapi_get_lang(monetdb),"xquery") != 0) { + myq[len++] = ';'; + } + myq[len] = '\0'; monetdb_result = mapi_query(monetdb, myq); if ((MG(auto_reset_persistent) & 2) && monetdb_result == NULL) {
2009/8/8 Gene Stevens
: Hi Wouter and Stefan,
Thanks so much for your replies. I apologize for the simple XQuery error below: I tried to clean up and test a simple example before posting to the list ...oops. As you can tell, the error is the same even with a corrected sequence: "count((1,2,3,4))".
I've been using XQuery for about two years now, mostly with BDB XML daemonized within our own servers. I found this project just the other day and it very much piqued my curiosity and got me a little excited after my ultimately disappointing experience with Oracle's product, their query planner in particular. I'm very interested to see how this database handles XML/XQuery, performance-wise, specifically for analytical workloads on large data sets: think analysis/reporting on billions of audit events. But I have a number of projects with different needs where MonetDB might be valuable.
I am not a C developer (I'm a PHP/XML web services developer), but if there is anything I can do to help, please let me know.
Thanks - Gene Stevens
On Aug 8, 2009, at 8:42 AM, Wouter Alink wrote:
Hello Gene,
I think you might have found a bug in the PHP client. The PHP client might only have been tested with SQL and not with XQuery. When using the SQL language, a semi-colon may be automatically added at the end of a statement, but when using XQuery that should of course not be done.
However, you will get an error anyway with the current query. The error you should have gotten is:
error in function application: at (1,1-1,14): wrong number of arguments for function `fn:count' (expected 1, got 4) # halted in functions.c (check_fun_usage), line 361
You should change your query to something like: "count((1,2,3,4))" or "count(1 to 4)"
Greetings, Wouter
2009/8/8 Gene Stevens
: Hi everyone,
I am a new MonetDB user. I am specifically interested in MonetDB's XQuery support with client access through PHP.
I currently get parsing errors when trying any kind of XQuery through the PHP module. I'm wondering if this is a a bug in the client or if I am possibly doing something wrong. E.g.:
#!/usr/bin/env php <?php $db = monetdb_connect('xquery', 'localhost', 50000, 'monetdb', 'monetdb') or die ("Failed to connect\n"); $query = 'count(1,2,3,4)'; $res = monetdb_query($query); ?>
Results in:
Warning: monetdb_query(): Query failed: parse error: syntax error, unexpected ;, expecting $end on line 1, column 15 (next token is `;') !parse error: XQuery parsing failed in /home/user/monet.php on line 6
.... for any variation of an XQuery. I have tried the server from the Ubuntu repository as well as I've built it from source with the same results.
Here is my environment:
PHP 5.2.6-3ubuntu4.1 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 23 2009 14:37:14) Ubuntu 9.04: Linux ubuntu 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:45:36 UTC 2009 x86_64 GNU/Linux
Mserver --dbinit="module(pathfinder);" # MonetDB Server v4.30.4 # based on GDK v1.30.4 # Copyright (c) 1993-July 2008, CWI. All rights reserved. # Copyright (c) August 2008-2009, MonetDB B.V.. All rights reserved. # Compiled for x86_64-pc-linux-gnu/64bit with 64bit OIDs; dynamically linked. # Visit http://monetdb.cwi.nl/ for further information. # PF/Tijah module v0.13.0 loaded. http://dbappl.cs.utwente.nl/pftijah # MonetDB/XQuery module v0.28.3 loaded (default back-end is 'algebra') # XRPC administrative console at http://127.0.0.1:50001/admin MonetDB>
Thanks for any insight! - Gene Stevens
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
Just chiming in here On 10-08-2009 01:05:51 +0200, Wouter Alink wrote:
I had some more time to look at the issue. It seems that the PHP interface still does not produce the expected behavior when a query returns multiple results. This doesn't affect your query as your query only yields 1 result.
In my opinion a different row should be available for each item in the sequence of results. An example: a query like "1 to 4" should return 4 rows with 1 column, containing 1, 2, 3, and 4 respectively. Currently it doesn't seem to do so. I added a test for this, so we can monitor the status through our testweb, but probably someone more familiar with the MonetDB/PHP interface code should have a look at how to fix this.
Wouter's previous fix, is indeed something that has to be done, the PHP module assumes SQL access at the moment. For getting "useful" results from the XQuery server, the PHP module needs a small fix to ask the server for SQL-ish results, like JDBC does. I'll see if I can get you a patch which you can test.
On 14-08-2009 09:41:51 +0200, Fabian Groffen wrote:
Wouter's previous fix, is indeed something that has to be done, the PHP module assumes SQL access at the moment. For getting "useful" results from the XQuery server, the PHP module needs a small fix to ask the server for SQL-ish results, like JDBC does. I'll see if I can get you a patch which you can test.
Ok, the PHP module already had XQuery support, dating back from when either XQuery still accepted a ; at the end, or when the module didn't protect itself by adding the ; if it was missing. It looks to me as if the module is doing all it can at the moment.
My guess is that (looking at the current test output, which shows
"1,") the result delimiter (output-mode i think it is called) is still
set incorrect. I recall from the JDBC code that there was something
like a xml-seq-mapi output mode that needed to be used. But I don't
know where or what needs to be changed exactly.
Wouter
2009/8/14 Fabian Groffen
On 14-08-2009 09:41:51 +0200, Fabian Groffen wrote:
Wouter's previous fix, is indeed something that has to be done, the PHP module assumes SQL access at the moment. For getting "useful" results from the XQuery server, the PHP module needs a small fix to ask the server for SQL-ish results, like JDBC does. I'll see if I can get you a patch which you can test.
Ok, the PHP module already had XQuery support, dating back from when either XQuery still accepted a ; at the end, or when the module didn't protect itself by adding the ; if it was missing.
It looks to me as if the module is doing all it can at the moment.
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
On 14-08-2009 10:31:45 +0200, Wouter Alink wrote:
My guess is that (looking at the current test output, which shows "1,") the result delimiter (output-mode i think it is called) is still set incorrect. I recall from the JDBC code that there was something like a xml-seq-mapi output mode that needed to be used. But I don't know where or what needs to be changed exactly.
JDBC does Xoutput seq, PHP does mapi_output("seq"), which I suspect is doing the same.
The test below produces the following results for JDBC (is there
actually a test in the testweb for this? I couldn't find it)
on the May2009 branch it produces:
Result: 1
Result: "aap"
Result: 1.000000
Result: false
Result: <aap/>
Result: attribute aap { "beer" }
-----------------------------------------
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class TestJDBC {
public static void main(String[] args) throws ClassNotFoundException,
SQLException {
Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
Connection conn =
DriverManager.getConnection("jdbc:monetdb://localhost:50100/demo?language=xquery");
Statement st = conn.createStatement();
try {
ResultSet rs = st.executeQuery("1,\"aap\",1.0,false(), <aap/>,
attribute { \"aap\" } { \"beer\" }");
try {
while (rs.next()) {
System.out.println("Result: " + rs.getString(1));
}
} finally {
rs.close();
}
} finally {
st.close();
}
}
}
2009/8/14 Fabian Groffen
On 14-08-2009 10:31:45 +0200, Wouter Alink wrote:
My guess is that (looking at the current test output, which shows "1,") the result delimiter (output-mode i think it is called) is still set incorrect. I recall from the JDBC code that there was something like a xml-seq-mapi output mode that needed to be used. But I don't know where or what needs to be changed exactly.
JDBC does Xoutput seq, PHP does mapi_output("seq"), which I suspect is doing the same.
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
participants (4)
-
Fabian Groffen
-
Gene Stevens
-
Stefan Manegold
-
Wouter Alink