Check-in [90180e065d]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixing a bug hanging VirtualKNN tests
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 90180e065dfdd8fa624f9e2c8f5ebf8302dd64e5
User & Date: sandro 2019-02-10 19:03:55
Context
2019-02-14
09:59
implementing ReCreateStylingTriggers(), ReCreateRasterCoveragesTriggers(), ReCreateVectorCoveragesTriggers() and ReCreateTopoTriggers() check-in: 55f7c3ed61 user: sandro tags: trunk
2019-02-10
19:03
fixing a bug hanging VirtualKNN tests check-in: 90180e065d user: sandro tags: trunk
2019-02-08
18:27
modifying the signature of LongLatToDMS() so to accept a third argument for controlling how many decimal digit must be used for representing Seconds check-in: f9ca692b4d user: sandro tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/spatialite/virtualknn.c.

236
237
238
239
240
241
242

243
244
245
246
247
248
249
    ctx->maxx = -DBL_MAX;
    ctx->maxy = -DBL_MAX;
    ctx->min_dist = DBL_MAX;
    ctx->rtree_minx = -DBL_MAX;
    ctx->rtree_miny = -DBL_MAX;
    ctx->rtree_maxx = DBL_MAX;
    ctx->rtree_maxy = DBL_MAX;

    ctx->current_level = 0;
    ctx->max_items = 0;
    ctx->knn_array = NULL;
    ctx->curr_items = 0;
    ctx->rtree_count = 0;
    ctx->max_dist = -DBL_MAX;
}







>







236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
    ctx->maxx = -DBL_MAX;
    ctx->maxy = -DBL_MAX;
    ctx->min_dist = DBL_MAX;
    ctx->rtree_minx = -DBL_MAX;
    ctx->rtree_miny = -DBL_MAX;
    ctx->rtree_maxx = DBL_MAX;
    ctx->rtree_maxy = DBL_MAX;
    ctx->level = 0;
    ctx->current_level = 0;
    ctx->max_items = 0;
    ctx->knn_array = NULL;
    ctx->curr_items = 0;
    ctx->rtree_count = 0;
    ctx->max_dist = -DBL_MAX;
}

Changes to test/check_virtualknn.c.

438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
...
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
...
483
484
485
486
487
488
489
490







491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
    sqlite3 *db_handle = NULL;
    int ret;
    char *err_msg = NULL;
    void *cache = spatialite_alloc_connection ();

    if (argc > 1 || argv[0] == NULL)
	argc = 1;		/* silencing stupid compiler warnings */
/* cazzembaum */
return 0;

    ret =
	sqlite3_open_v2 (":memory:", &db_handle,
			 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "cannot open in-memory db: %s\n",
................................................................................
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (db_handle);
	  return -2;
      }
fprintf(stderr, "********** populate\n");

/* Creating and populating the test table */
    ret = create_table (db_handle);
    if (!ret)
      {
	  sqlite3_close (db_handle);
	  return -3;
................................................................................
      }
    ret = populate_table (db_handle);
    if (!ret)
      {
	  sqlite3_close (db_handle);
	  return -4;
      }
fprintf(stderr, "** create1\n");








/* Creating the VirtualKNN table */
    ret = create_knn (db_handle);
    if (ret)
      {
	  fprintf (stderr, "CREATE VIRTUAL TABLE knn: expected failure !!!\n");
	  sqlite3_close (db_handle);
	  return -5;
      }
fprintf(stderr, "** knn-1\n");

/* Testing KNN - #1 */
    ret = test_knn (db_handle, 0);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #1: unexpected failure\n");
	  sqlite3_close (db_handle);
	  return -6;
      }
fprintf(stderr, "** knn-2\n");

/* Testing KNN - #2 */
    ret = test_knn (db_handle, 1);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #2: unexpected failure\n");
	  sqlite3_close (db_handle);
	  return -7;
      }
fprintf(stderr, "** knn-3\n");

/* Testing KNN - #3 */
    ret = test_knn (db_handle, 2);
    if (ret)
      {
	  fprintf (stderr, "Check KNN #3: unexpected success\n");
	  sqlite3_close (db_handle);
	  return -8;
      }
fprintf(stderr, "** View\n");

/* creating a first SpatialView */
    ret = create_spatial_view_1 (db_handle);
    if (!ret)
      {
	  fprintf (stderr, "Create Spatial View #1: unexpected failure !!!\n");
	  sqlite3_close (db_handle);
	  return -9;
      }
fprintf(stderr, "** knn-4\n");

/* Testing KNN - #4 */
    ret = test_knn (db_handle, 5);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #4: unexpected failure\n");
	  sqlite3_close (db_handle);
	  return -10;
      }
fprintf(stderr, "** knn-5\n");

/* Testing KNN - #5 */
    ret = test_knn (db_handle, 7);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #5: unexpected failure\n");
	  sqlite3_close (db_handle);
	  return -11;
      }
fprintf(stderr, "** second\n");

/* adding a second geometry column */
    ret = add_second_geom (db_handle);
    if (!ret)
      {
	  fprintf (stderr, "Add Second Geometry: unexpected failure !!!\n");
	  sqlite3_close (db_handle);
	  return -12;
      }
fprintf(stderr, "** knn-6\n");

/* Testing KNN - #6 */
    ret = test_knn (db_handle, 3);
    if (ret)
      {
	  fprintf (stderr, "Check KNN #6: unexpected success\n");
	  sqlite3_close (db_handle);
	  return -13;
      }
fprintf(stderr, "** knn-7\n");

/* Testing KNN - #7 */
    ret = test_knn (db_handle, 1);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #7: unexpected failure\n");
	  sqlite3_close (db_handle);
	  return -14;
      }
fprintf(stderr, "** knn-8\n");

/* Testing KNN - #8 */
    ret = test_knn (db_handle, 4);
    if (ret)
      {
	  fprintf (stderr, "Check KNN #8: unexpected success\n");
	  sqlite3_close (db_handle);
	  return -15;
      }
fprintf(stderr, "** spindex\n");

/* creating a second SpatialIndex */
    ret = add_second_rtree (db_handle);
    if (!ret)
      {
	  fprintf (stderr,
		   "Add Second Spatial Index: unexpected failure !!!\n");
	  sqlite3_close (db_handle);
	  return -16;
      }
fprintf(stderr, "** knn-9\n");

/* Testing KNN - #9 */
    ret = test_knn (db_handle, 4);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #9: unexpected failure\n");
	  sqlite3_close (db_handle);
	  return -17;
      }
fprintf(stderr, "** secondView\n");

/* creating a second SpatialView */
    ret = create_spatial_view_2 (db_handle);
    if (!ret)
      {
	  fprintf (stderr, "Create Spatial View #2: unexpected failure !!!\n");
	  sqlite3_close (db_handle);
	  return -18;
      }
fprintf(stderr, "** knn-10\n");

/* Testing KNN - #10 */
    ret = test_knn (db_handle, 6);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #10: unexpected failure\n");
	  sqlite3_close (db_handle);
	  return -19;
      }
fprintf(stderr, "** end\n");

#endif /* end KNN conditional */
#endif /* end GEOS conditional */

    sqlite3_close (db_handle);
    spatialite_cleanup_ex (cache);
    spatialite_shutdown ();

    return 0;
}







<
<







 







<







 







|
>
>
>
>
>
>
>







|

<







|

<







|

<







|

<







|

<







|

<







<
<
<
<
<
<
<
<
<
<


<









<









<









<










<









<









<









<










438
439
440
441
442
443
444


445
446
447
448
449
450
451
...
466
467
468
469
470
471
472

473
474
475
476
477
478
479
...
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503

504
505
506
507
508
509
510
511
512

513
514
515
516
517
518
519
520
521

522
523
524
525
526
527
528
529
530

531
532
533
534
535
536
537
538
539

540
541
542
543
544
545
546
547
548

549
550
551
552
553
554
555










556
557

558
559
560
561
562
563
564
565
566

567
568
569
570
571
572
573
574
575

576
577
578
579
580
581
582
583
584

585
586
587
588
589
590
591
592
593
594

595
596
597
598
599
600
601
602
603

604
605
606
607
608
609
610
611
612

613
614
615
616
617
618
619
620
621

622
623
624
625
626
627
628
629
630
631
    sqlite3 *db_handle = NULL;
    int ret;
    char *err_msg = NULL;
    void *cache = spatialite_alloc_connection ();

    if (argc > 1 || argv[0] == NULL)
	argc = 1;		/* silencing stupid compiler warnings */



    ret =
	sqlite3_open_v2 (":memory:", &db_handle,
			 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "cannot open in-memory db: %s\n",
................................................................................
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (db_handle);
	  return -2;
      }


/* Creating and populating the test table */
    ret = create_table (db_handle);
    if (!ret)
      {
	  sqlite3_close (db_handle);
	  return -3;
................................................................................
      }
    ret = populate_table (db_handle);
    if (!ret)
      {
	  sqlite3_close (db_handle);
	  return -4;
      }
/* adding a second geometry column */
    ret = add_second_geom (db_handle);
    if (!ret)
      {
	  fprintf (stderr, "Add Second Geometry: unexpected failure !!!\n");
	  sqlite3_close (db_handle);
	  return -5;
      }

/* Creating the VirtualKNN table */
    ret = create_knn (db_handle);
    if (ret)
      {
	  fprintf (stderr, "CREATE VIRTUAL TABLE knn: expected failure !!!\n");
	  sqlite3_close (db_handle);
	  return -6;
      }


/* Testing KNN - #1 */
    ret = test_knn (db_handle, 0);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #1: unexpected failure\n");
	  sqlite3_close (db_handle);
	  return -7;
      }


/* Testing KNN - #2 */
    ret = test_knn (db_handle, 1);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #2: unexpected failure\n");
	  sqlite3_close (db_handle);
	  return -8;
      }


/* Testing KNN - #3 */
    ret = test_knn (db_handle, 2);
    if (ret)
      {
	  fprintf (stderr, "Check KNN #3: unexpected success\n");
	  sqlite3_close (db_handle);
	  return -9;
      }


/* creating a first SpatialView */
    ret = create_spatial_view_1 (db_handle);
    if (!ret)
      {
	  fprintf (stderr, "Create Spatial View #1: unexpected failure !!!\n");
	  sqlite3_close (db_handle);
	  return -10;
      }


/* Testing KNN - #4 */
    ret = test_knn (db_handle, 5);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #4: unexpected failure\n");
	  sqlite3_close (db_handle);
	  return -11;
      }


/* Testing KNN - #5 */
    ret = test_knn (db_handle, 7);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #5: unexpected failure\n");
	  sqlite3_close (db_handle);










	  return -12;
      }


/* Testing KNN - #6 */
    ret = test_knn (db_handle, 3);
    if (ret)
      {
	  fprintf (stderr, "Check KNN #6: unexpected success\n");
	  sqlite3_close (db_handle);
	  return -13;
      }


/* Testing KNN - #7 */
    ret = test_knn (db_handle, 1);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #7: unexpected failure\n");
	  sqlite3_close (db_handle);
	  return -14;
      }


/* Testing KNN - #8 */
    ret = test_knn (db_handle, 4);
    if (ret)
      {
	  fprintf (stderr, "Check KNN #8: unexpected success\n");
	  sqlite3_close (db_handle);
	  return -15;
      }


/* creating a second SpatialIndex */
    ret = add_second_rtree (db_handle);
    if (!ret)
      {
	  fprintf (stderr,
		   "Add Second Spatial Index: unexpected failure !!!\n");
	  sqlite3_close (db_handle);
	  return -16;
      }


/* Testing KNN - #9 */
    ret = test_knn (db_handle, 4);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #9: unexpected failure\n");
	  sqlite3_close (db_handle);
	  return -17;
      }


/* creating a second SpatialView */
    ret = create_spatial_view_2 (db_handle);
    if (!ret)
      {
	  fprintf (stderr, "Create Spatial View #2: unexpected failure !!!\n");
	  sqlite3_close (db_handle);
	  return -18;
      }


/* Testing KNN - #10 */
    ret = test_knn (db_handle, 6);
    if (!ret)
      {
	  fprintf (stderr, "Check KNN #10: unexpected failure\n");
	  sqlite3_close (db_handle);
	  return -19;
      }


#endif /* end KNN conditional */
#endif /* end GEOS conditional */

    sqlite3_close (db_handle);
    spatialite_cleanup_ex (cache);
    spatialite_shutdown ();

    return 0;
}