Overview
Comment: | inserts into pgsql now working |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.63-configdbsync |
Files: | files | file ages | folders |
SHA1: |
70843b7e20b110176fe785f6eb5c2c5c |
User & Date: | srehman on 2017-01-24 16:32:40 |
Other Links: | branch diff | manifest | tags |
Context
2017-01-24
| ||
16:33 | merged with latest v1.63 check-in: 3c1f0f31b1 user: srehman tags: v1.63-configdbsync | |
16:32 | inserts into pgsql now working check-in: 70843b7e20 user: srehman tags: v1.63-configdbsync | |
2017-01-23
| ||
14:08 | fixed prepare statement for postgres check-in: a719a06cf7 user: srehman tags: v1.63-configdbsync | |
Changes
Modified db.scm from [524b1bd5c1] to [a60bfae142].
︙ | ︙ | |||
412 413 414 415 416 417 418 | ;; just tests, test_steps and test_data tables (define db:sync-tests-only (list ;; (list "strs" ;; '("id" #f) ;; '("str" #f)) (list "tests" | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > | > > > | | | | | | | | | | | | 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 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 | ;; just tests, test_steps and test_data tables (define db:sync-tests-only (list ;; (list "strs" ;; '("id" #f) ;; '("str" #f)) (list "tests" '("id" "INTEGER") '("run_id" "INTEGER") '("testname" "TEXT") '("host" "TEXT") '("cpuload" "REAL") '("diskfree" "INTEGER") '("uname" "TEXT") '("rundir" "TEXT") '("shortdir" "TEXT") '("item_path" "TEXT") '("state" "TEXT") '("status" "TEXT") '("attemptnum" "INTEGER") '("final_logf" "TEXT") '("logdat" "TEXT") '("run_duration" "INTEGER") '("comment" "TEXT") '("event_time" "INTEGER") '("fail_count" "INTEGER") '("pass_count" "INTEGER") '("archived" "INTEGER")) (list "test_steps" '("id" "INTEGER") '("test_id" "INTEGER") '("stepname" "TEXT") '("state" "TEXT") '("status" "TEXT") '("event_time" "INTEGER") '("comment" "TEXT") '("logfile" "TEXT")) (list "test_data" '("id" "INTEGER") '("test_id" "INTEGER") '("category" "TEXT") '("variable" "TEXT") '("value" "REAL") '("expected" "REAL") '("tol" "REAL") '("units" "TEXT") '("comment" "TEXT") '("status" "TEXT") '("type" "TEXT")))) ;; needs db to get keys, this is for syncing all tables ;; (define (db:sync-main-list dbstruct) (let ((keys (db:get-keys dbstruct))) (list (list "keys" '("id" "INTEGER") '("fieldname" "TEXT") '("fieldtype" "TEXT")) (list "metadat" '("var" "TEXT") '("val" "TEXT")) (list "runs" '("id" "INTEGER") '("release" "TEXT") '("iteration" "TEXT") '("testsuite_mode" "TEXT") '("runname" "TEXT") '("state" "TEXT") '("status" "TEXT") '("owner" "TEXT") '("event_time" "INTEGER") '("comment" "TEXT") '("fail_count" "INTEGER") '("pass_count" "INTEGER")) (list "test_meta" '("id" "INTEGER") '("testname" "TEXT") '("owner" "TEXT") '("description" "TEXT") '("reviewed" "INTEGER") '("iterated" "TEXT") '("avg_runtime" "REAL") '("avg_disk" "REAL") '("tags" "TEXT") '("jobgroup" "TEXT"))))) (define (db:sync-all-tables-list dbstruct) (append (db:sync-main-list dbstruct) db:sync-tests-only)) ;; use bunch of Unix commands to try to break the lock and recreate the db ;; |
︙ | ︙ | |||
673 674 675 676 677 678 679 | ;; first pass implementation, just insert all changed rows (for-each (lambda (targdb) (set! targdb (dbi:convert (db:dbdat-get-db targdb))) (if (eqv? (dbi:db-dbtype targdb) 'pg) (let* ((prep "")) | < < < < | | | | 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 | ;; first pass implementation, just insert all changed rows (for-each (lambda (targdb) (set! targdb (dbi:convert (db:dbdat-get-db targdb))) (if (eqv? (dbi:db-dbtype targdb) 'pg) (let* ((prep "")) (set! prep (string-intersperse (map cadr fields) ",")) (set! prep (conc "PREPARE fullins (" prep ") AS INSERT INTO " tablename " ( " (string-intersperse (map car fields) ",") " ) VALUES ( ")) ;;maybe add lookup in the future depending on where types are needed (let loop ((i 1)) (set! prep (conc prep "$" i ",")) (if (< i (- num-fields 1)) (loop (+ i 1)) (set! prep (conc prep "$" (+ i 1) " ) ON CONFLICT DO NOTHING;")))) (set! full-ins prep))) (let* ((db (dbi:convert (db:dbdat-get-db targdb))) (stmth (dbi:prepare db full-ins))) ;; (db:delay-if-busy targdb) ;; NO WAITING (for-each (lambda (fromdat-lst) (dbi:with-transaction |
︙ | ︙ |