Fix some whitespace, add note for failing test.
FossilOrigin-Name: 082dff9df32ccebaf9a2fa51d9cedf736af42c60cfb243a228bad545e024c90d
This commit is contained in:
parent
05291751cb
commit
ac222369f0
2 changed files with 51 additions and 46 deletions
|
|
@ -7,6 +7,9 @@ weird prepared statement binding behavior?
|
||||||
I don't know. Maybe it's just me.
|
I don't know. Maybe it's just me.
|
||||||
|
|
||||||
https://docs.kuzudb.com/get-started/prepared-statements/
|
https://docs.kuzudb.com/get-started/prepared-statements/
|
||||||
|
|
||||||
|
% clang -lkuzu -o prepared-test prepared-test.c
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -14,64 +17,64 @@ https://docs.kuzudb.com/get-started/prepared-statements/
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
/* Setup */
|
/* Setup */
|
||||||
kuzu_system_config config = kuzu_default_system_config();
|
kuzu_system_config config = kuzu_default_system_config();
|
||||||
kuzu_database db;
|
kuzu_database db;
|
||||||
kuzu_database_init( "TEST-DB", config, &db );
|
kuzu_database_init( "TEST-DB", config, &db );
|
||||||
|
|
||||||
kuzu_connection conn;
|
kuzu_connection conn;
|
||||||
kuzu_connection_init( &db, &conn );
|
kuzu_connection_init( &db, &conn );
|
||||||
|
|
||||||
kuzu_query_result q;
|
kuzu_query_result q;
|
||||||
kuzu_prepared_statement stmt;
|
kuzu_prepared_statement stmt;
|
||||||
|
|
||||||
char things[3][20] = { "Camel", "Lampshade", "Delicious Cake" };
|
char things[3][20] = { "Camel", "Lampshade", "Delicious Cake" };
|
||||||
|
|
||||||
|
|
||||||
/* Schema install */
|
/* Schema install */
|
||||||
if ( kuzu_connection_query(
|
if ( kuzu_connection_query(
|
||||||
&conn,
|
&conn,
|
||||||
"CREATE NODE TABLE Test ( id SERIAL, thing STRING, PRIMARY KEY(id) )",
|
"CREATE NODE TABLE Test ( id SERIAL, thing STRING, PRIMARY KEY(id) )",
|
||||||
&q ) != KuzuSuccess ) {
|
&q ) != KuzuSuccess ) {
|
||||||
printf( "Couldn't create schema?!\n" );
|
printf( "Couldn't create schema?!\n" );
|
||||||
return( 1 );
|
return( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Prepare statement */
|
/* Prepare statement */
|
||||||
if ( kuzu_connection_prepare(
|
if ( kuzu_connection_prepare(
|
||||||
&conn,
|
&conn,
|
||||||
"CREATE (t:Test {thing: $thing})",
|
"CREATE (t:Test {thing: $thing})",
|
||||||
&stmt
|
&stmt
|
||||||
) != KuzuSuccess ) {
|
) != KuzuSuccess ) {
|
||||||
printf( "Couldn't prepare statement?\n" );
|
printf( "Couldn't prepare statement?\n" );
|
||||||
return( 1 );
|
return( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Lets make some nodes using the prepared statement. */
|
/* Lets make some nodes using the prepared statement. */
|
||||||
for ( int i = 0; i < 3; i++) {
|
for ( int i = 0; i < 3; i++) {
|
||||||
printf( "Binding thing: %s\n", things[i] );
|
printf( "Binding thing: %s\n", things[i] );
|
||||||
if ( kuzu_prepared_statement_bind_string( &stmt, "thing", things[i] ) != KuzuSuccess ) {
|
if ( kuzu_prepared_statement_bind_string( &stmt, "thing", things[i] ) != KuzuSuccess ) {
|
||||||
printf( "Unable to bind thing: %s\n", things[i] );
|
printf( "Unable to bind thing: %s\n", things[i] );
|
||||||
}
|
}
|
||||||
if ( kuzu_connection_execute( &conn, &stmt, &q ) != KuzuSuccess ) {
|
if ( kuzu_connection_execute( &conn, &stmt, &q ) != KuzuSuccess ) {
|
||||||
printf( "Couldn't execute prepared statement.\n" );
|
printf( "Couldn't execute prepared statement.\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cleanup */
|
/* Cleanup */
|
||||||
kuzu_prepared_statement_destroy( &stmt );
|
kuzu_prepared_statement_destroy( &stmt );
|
||||||
kuzu_query_result_destroy( &q );
|
kuzu_query_result_destroy( &q );
|
||||||
kuzu_connection_destroy( &conn );
|
kuzu_connection_destroy( &conn );
|
||||||
kuzu_database_destroy( &db );
|
kuzu_database_destroy( &db );
|
||||||
|
|
||||||
/* HMM */
|
/* HMM */
|
||||||
printf( "Okay. Now 'kuzu TEST-DB' and look around.\n" );
|
printf( "Okay. Now 'kuzu TEST-DB' and look around.\n" );
|
||||||
printf( "\"MATCH (t:Test) RETURN t.thing;\", perhaps.\n\n" );
|
printf( "\"MATCH (t:Test) RETURN t.thing;\", perhaps.\n\n" );
|
||||||
printf( "I'd expect to see what I thought I bound.\n" );
|
printf( "I'd expect to see what I thought I bound.\n" );
|
||||||
printf( "Instead, I see three Camels.\n" );
|
printf( "Instead, I see three Camels.\n" );
|
||||||
printf( "Too many camels!!\n" );
|
printf( "Too many camels!!\n" );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ for thing in @[ "Camel", "Lampshade", "Delicious Cake" ]:
|
||||||
q = p.execute( (thing: thing) )
|
q = p.execute( (thing: thing) )
|
||||||
assert typeOf( q ) is KuzuQueryResult
|
assert typeOf( q ) is KuzuQueryResult
|
||||||
|
|
||||||
|
# This is failing until I can address
|
||||||
|
# https://github.com/kuzudb/kuzu/issues/5102
|
||||||
q = conn.query( "MATCH (d:Doop) RETURN d.thing" )
|
q = conn.query( "MATCH (d:Doop) RETURN d.thing" )
|
||||||
echo $q
|
echo $q
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue