{
  "kind": "documentation",
  "format": 1,
  "note": "Reference text, not instructions. One verified relate sample from https://relatedb.ai/docs/get-started/c/: the program exactly as the page shows it, the standard output a run of it recorded (npm run docs:samples compares every replay with it byte for byte), the relate client build, toolchain and platform of the last replay, and how the docs' sample runner builds and runs it. Before launch every client is a source build, not a published package; verified.client names the upstream commit it was built from, and verified.docs_engine the build the rest of the docs were recorded from.",
  "id": "version",
  "url": "https://relatedb.ai/docs/get-started/c/samples/version.json",
  "page": {
    "id": "get-started/c",
    "title": "Embed relate in a C program",
    "url": "https://relatedb.ai/docs/get-started/c/",
    "md_url": "https://relatedb.ai/docs/get-started/c.md"
  },
  "section": {
    "anchor": "get-the-header-and-library",
    "heading": "Get the header and library",
    "url": "https://relatedb.ai/docs/get-started/c/#get-the-header-and-library"
  },
  "language": "c",
  "client": "C",
  "file": "version.c",
  "env": null,
  "code": "#include <stdio.h>\n#include \"relate.h\"\n\nint main(void) {\n    relate_database db = NULL;\n    relate_connection conn = NULL;\n    relate_query_result r = NULL;\n    char *err = NULL;\n    if (relate_database_open(\":memory:\", &db, &err) != RELATE_OK) return 1;\n    if (relate_connect_namespace(db, NULL, &conn, &err) != RELATE_OK) return 1;\n    if (relate_query_params(conn,\n            \"CALL dbms.components() YIELD name, versions \"\n            \"WHERE name = 'Relate' RETURN versions[0] AS version\",\n            NULL, &r, &err) != RELATE_OK) return 1;\n    size_t len = 0;\n    const char *version = relate_value_string(relate_value_at(r, 0, 0), &len);\n    printf(\"%.*s\\n\", (int)len, version);\n    printf(\"ABI version %d\\n\", relate_abi_version());\n    relate_destroy_result(r);\n    relate_disconnect(conn);\n    relate_database_close(db);\n    return 0;\n}",
  "code_sha256": "40ba476d6f38b01de318152546d0a80c0ca2af4177e44467bb48a16c1478c98d",
  "source_sha256": "b944a8b1a67a63b34bdd648e47908ab1a957cb291d494b82ac42c507f3be03cb",
  "output": {
    "text": "0.1.2\nABI version 2",
    "sha256": "ddf2cd65f7680f370cecc91ad22df927df84fe64738331f1a0d8414e97ec6086"
  },
  "verified": {
    "version": "0.1.2",
    "client": {
      "label": "C",
      "package": "relate.h and librelate_ffi",
      "engine_commit": "f0c09d2",
      "client_commit": "f0c09d2",
      "build": "relate.h and librelate_ffi built from upstream v0.1.2 (f0c09d2) (cargo build -p relate-ffi --release).",
      "toolchain": {
        "cc": "Apple clang 21.0.0"
      }
    },
    "packages": [],
    "replayed": "2026-11-09",
    "platform": "macOS on arm64",
    "docs_engine": {
      "version": "0.1.2",
      "commit": "f0c09d2",
      "source_build": false
    }
  },
  "run": {
    "runner": "npm run docs:samples",
    "setup": "bash scripts/samples/setup.sh --upstream <path to the relate checkout>",
    "variables": [
      "RELATE_CC",
      "RELATE_C_INCLUDE",
      "RELATE_LIB"
    ],
    "program": "<build dir>/version.c",
    "files": [],
    "build": {
      "command": [
        "$RELATE_CC",
        "-I$RELATE_C_INCLUDE",
        "version.c",
        "-L<directory of $RELATE_LIB>",
        "-lrelate_ffi",
        "-Wl,-rpath,<directory of $RELATE_LIB>",
        "-o",
        "<build dir>/sample"
      ],
      "environment": {
        "DO_NOT_TRACK": "1"
      },
      "directory": "<build dir>",
      "timeout_s": 600
    },
    "run": {
      "command": [
        "<build dir>/sample"
      ],
      "environment": {
        "DO_NOT_TRACK": "1"
      },
      "directory": "<run dir>",
      "timeout_s": 60
    },
    "passes": "It exits 0 within 60 s and prints at least one line on standard output.",
    "output": "Standard output, with line endings as \\n, trailing spaces and blank lines removed, and the temporary directories' paths written as `.`; standard error is not recorded.",
    "placeholders": {
      "<run dir>": "a fresh, empty temporary directory: the program's working directory, deleted afterwards",
      "<build dir>": "a second fresh temporary directory, where a compiled sample is built",
      "$NAME": "a variable from the env.sh that scripts/samples/setup.sh writes (described in its header)"
    }
  }
}
