On 22.12.2019 17:23, Keith Medcalf wrote:

I get:

RBU error: near ")": syntax error ERROR 1, expected 101 Done - Press
ENTER to exit.

with the current trunk ...

Thanks for following up on this. I spotted a typo in the test code.
Corrected version below. With that, Dan's fix works for me on trunk,
currently at 0b1dbd60f5.

Ralf

----------------------------------------------

#include <stdio.h>
#include "sqlite3.h"
#include "sqlite3rbu.h"

static void check(int r, int e) {
  if (r != e) {
    printf ("ERROR %d, expected %d\n", e, r);
  }
}

static int callback (void *user, int nCol, char **r, char **c) {
  int i;
  for (i = 0; i < nCol; i++) {
    printf("%s ", r[i]);
  }
  printf("\n");
  return 0;
}

static int runrbu(char *zTarget, char *zRbu) {
  sqlite3rbu* rbu;
  int rc;
  char* zError;

  rbu = sqlite3rbu_open (zTarget, zRbu, NULL);
  do {
    rc = sqlite3rbu_step(rbu);
  } while (rc == SQLITE_OK);

  rc = sqlite3rbu_close(rbu, &zError);
  if (zError) {
    printf("RBU error: %s\n", zError);
    sqlite3_free(zError);
  }
  return rc;
}

int main(void)
{
  sqlite3 *db, *dbRbu;
  int rc;

  remove ("test.db");
  check(SQLITE_OK, sqlite3_open_v2 ("test.db", &db,
    SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL));

  check(SQLITE_OK, sqlite3_exec(db,
    "CREATE TABLE t1(a, b, c PRIMARY KEY);" \
    "CREATE INDEX i1 ON t1(a, null, b+1);" \
    "CREATE INDEX i2 ON t1(a+1, b+1, c+1);" \

    "INSERT INTO t1 VALUES(1, 2, 3);" \
    "INSERT INTO t1 VALUES(4, 5, 6);" \
    "INSERT INTO t1 VALUES(7, 8, 9);" \
    "INSERT INTO t1 VALUES(10, 11, 12);" ,
    callback, NULL, NULL));

  sqlite3_close(db);

  remove ("rbu.db");
  check(SQLITE_OK, sqlite3_open_v2 ("rbu.db", &dbRbu,
    SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL));

  check(SQLITE_OK, sqlite3_exec(dbRbu,
    "CREATE TABLE data_t1(a, b, c, rbu_control);" \
    "INSERT INTO data_t1 VALUES(13, 14, 15, 0);" \
    "INSERT INTO data_t1 VALUES(NULL, NULL, 6, 1);" \
    "INSERT INTO data_t1 VALUES(NULL, 'three', 3, '.x.');",
    callback, NULL, NULL));

  sqlite3_close(dbRbu);

  check(SQLITE_DONE, runrbu("test.db", "rbu.db"));

  printf("Done - Press ENTER to exit.\n");
  getchar();

  return 0;
}
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to