@@ -485,6 +485,53 @@ TEST(cypher_parse_order_by_over_cap_rejected_issue1334) {
485485 PASS ();
486486}
487487
488+ /* #1994: a non-numeric SKIP/LIMIT operand must be a loud parse error too. The old
489+ * failure mode was the same one #1334 banned by a different route: expect()
490+ * returned NULL, the clause was dropped, and the query still reported success
491+ * with limit left at its -1 "no LIMIT" sentinel - so query_graph answered a
492+ * bounded query with the entire result set. Cypher parameters ($limit) are the
493+ * everyday trigger: they are what a Neo4j-shaped client writes by default. */
494+ TEST (cypher_parse_nonnumeric_limit_rejected_issue1994 ) {
495+ cbm_query_t * q = NULL ;
496+ char * err = NULL ;
497+ int rc = cbm_cypher_parse ("MATCH (f:Function) RETURN f.name LIMIT $limit" , & q , & err );
498+ ASSERT (rc != 0 );
499+ free (err );
500+ PASS ();
501+ }
502+
503+ TEST (cypher_parse_nonnumeric_skip_rejected_issue1994 ) {
504+ cbm_query_t * q = NULL ;
505+ char * err = NULL ;
506+ /* The orphaned operand also swallowed the LIMIT that followed it. */
507+ int rc = cbm_cypher_parse ("MATCH (f:Function) RETURN f.name SKIP $offset LIMIT 10" , & q , & err );
508+ ASSERT (rc != 0 );
509+ free (err );
510+ PASS ();
511+ }
512+
513+ TEST (cypher_parse_word_limit_operand_rejected_issue1994 ) {
514+ cbm_query_t * q = NULL ;
515+ char * err = NULL ;
516+ int rc = cbm_cypher_parse ("MATCH (f:Function) RETURN f.name LIMIT abc" , & q , & err );
517+ ASSERT (rc != 0 );
518+ free (err );
519+ PASS ();
520+ }
521+
522+ /* Control: a well-formed SKIP/LIMIT still parses and still carries its values. */
523+ TEST (cypher_parse_numeric_skip_limit_still_accepted ) {
524+ cbm_query_t * q = NULL ;
525+ char * err = NULL ;
526+ int rc = cbm_cypher_parse ("MATCH (f:Function) RETURN f.name SKIP 2 LIMIT 10" , & q , & err );
527+ ASSERT_EQ (rc , 0 );
528+ ASSERT_EQ (q -> ret -> skip , 2 );
529+ ASSERT_EQ (q -> ret -> limit , 10 );
530+
531+ cbm_query_free (q );
532+ PASS ();
533+ }
534+
488535TEST (cypher_parse_return_distinct ) {
489536 cbm_query_t * q = NULL ;
490537 char * err = NULL ;
@@ -4556,6 +4603,10 @@ SUITE(cypher) {
45564603 RUN_TEST (cypher_parse_return_order_limit );
45574604 RUN_TEST (cypher_parse_multikey_order_by_issue1334 );
45584605 RUN_TEST (cypher_parse_order_by_over_cap_rejected_issue1334 );
4606+ RUN_TEST (cypher_parse_nonnumeric_limit_rejected_issue1994 );
4607+ RUN_TEST (cypher_parse_nonnumeric_skip_rejected_issue1994 );
4608+ RUN_TEST (cypher_parse_word_limit_operand_rejected_issue1994 );
4609+ RUN_TEST (cypher_parse_numeric_skip_limit_still_accepted );
45594610 RUN_TEST (cypher_parse_return_distinct );
45604611 RUN_TEST (cypher_parse_inline_props );
45614612 RUN_TEST (cypher_parse_error );
0 commit comments