Database Server v2026

Remind people what Brain Patchwork DX, LLC. did/does.
Post Reply
ONiX
Site Admin
Posts: 80
Joined: Tue Nov 18, 2025 1:27 am

Database Server v2026

Post by ONiX »

Database Server v2026
A compact brochure for European Delphi 7 developers

Overview

Database Server v2026 is a lightweight, Delphi 7–centric client/server dataset framework built around TClientDataSet and the DXSock stack.
It provides: a Delphi component server (TDXCDSServer), a matching client component (TDXCDSClient), and a replication engine (TDXReplicator) with WAL + retry + snapshot-on-reconnect.
Designed for rapid prototyping, LAN apps, internal business tools, and for teams that prefer Delphi 7 tooling and VCL workflows.
Why choose Database Server v2026?

Native Delphi 7 integration: components are VCL-friendly and register on the "DX Client/Server" palette.
Familiar TClientDataSet model: use TClientDataSet and TDataSource in forms the same way as local datasets — but over a TCP link.
Pragmatic replication: master↔master replication with persistent WAL, retry/resend background thread, and snapshot resync on reconnect.
SQL-on-server pattern: run SQL centrally via a server-side provider (wrap your SQL engine with TDataSetProvider / TSQLProviderWrapper) and stream results back to clients.
Config & persistence: XMLINI-based configuration (default dxcds.xml) and configurable data folder for WAL, snapshots, and settings.
Key features (at-a-glance)

Components
TDXCDSServer — host a TClientDataSet on the server; supports dataset operations and stream transfers (binary/XML).
TDXCDSClient — holds a local TClientDataSet instance you can bind to a TDataSource and uses dxsock6 to talk to the server.
TDXReplicator — peer-to-peer replication (master:master) with WAL per peer, retry/resend, and snapshot support.
TSQLProviderWrapper (example) — execute SQL on the server side and return results as a TClientDataSet.

Protocol
Text commands + 4‑byte size-prefixed payloads for data:
GETDATA, APPEND, INSERT, POST, DELETE, FIRST, NEXT, LAST, LOCATE, STREAM_GET, STREAM_PUT, REPL_OP, EXECSQL.
Default server port 2874 [Registered to Brain Patchwork on IANA] (configurable).

Streams
Full dataset transfer via SaveToStream/LoadFromStream (binary) or XML (temporary file helper).

Replication
Per-peer WAL files (persisted to disk), background sender thread, operation-level payloads (INSERT/UPDATE/DELETE), per-replica sequence numbers. Many database solutions require you to either license or purchase third-party tools to replicate your data. Included!

Conflict resolution default: last-writer-wins (by replica sequence + replica-id). Configurable policies can be added.

Configuration & persistence
XMLINI settings (dxcds.xml next to EXE by default): bind IP, port, data folder, stream format (BIN/XML).
Persisted WAL files and per-replica last-seen sequence numbers survive restarts.
Developer tools
Console demo included demonstrating client/server dataset activity, SQL execution, and replication between two servers.
Components register to the "DX Client/Server" palette for fast drag-and-drop use in Delphi 7 forms.
Architecture (simple view)

Client
TDXCDSClient (contains a TClientDataSet) <--> TCP (DXSock6) <--> TDXCDSServer

Server
TDXCDSServer wraps a TClientDataSet and accepts commands
Optional TDataSetProvider / TSQLProviderWrapper executes SQL on a real DB (BDE/dbExpress/etc.)
TDXReplicator manages WAL, sends REPL_OP messages to peers
Peer-to-peer replication: servers exchange small operation payloads and can request dataset snapshots when reconnecting.
SQL support model

Important: TClientDataSet itself is an in‑memory dataset — it does not execute SQL.
Recommended pattern:
Run SQL on the server (using TQuery, TSQLQuery or any provider that executes SQL).
Wrap results with a provider and return them to clients as TClientDataSet result packets (the included TSQLProviderWrapper is an example).
Server executes SQL, builds a TClientDataSet result, serialises it to stream, and sends it back to requesting client (EXECSQL).
This gives you full SQL power on the server (joins, indexes, vendor back-ends) while clients work with familiar TClientDataSet APIs.
Replication details / durability

WAL per-peer: every local change generates a small text payload persisted in a WAL file for each peer.
Sender thread:
Background thread reads WAL files and tries to deliver each operation to the peer's REPL_OP endpoint.
On ACK (OK) the operation is removed from WAL; unacknowledged entries remain for retry.
Snapshot and resync:
Optionally, on reconnect or by configuration the sender thread can request STREAM_GET:BIN from a peer and wholesale replace (or reconcile) the dataset.
Durability:
WAL and last-seen sequences are persisted to disk so replication resumes correctly after restart.
For high-availability production, integrate authentication/TLS and longer-term operation store (e.g., durable queue or database-backed log).
Security & production notes (must-read)

Current implementation is functional, optimistic and intended for trusted LANs or internal systems.
Important production hardening:
Add TLS/SSL for socket links (dxsock supports OpenSSL in special builds) and enable authentication.
Protect WAL and snapshot folders.
Consider signed payloads or access control to avoid unauthorised replication or SQL execution.
Add monitoring/logging, retry backoff and dead-letter queues for persistent failures.
Conflict resolution is last-writer-wins by design. For complex merging use vector clocks or domain-specific merge logic.
Compatibility & platform notes

Primary target: Delphi 7 (Windows). All examples and components are written and tested for Delphi 7.
Lazarus / Free Pascal:
Possible but not drop-in. Key differences:
TClientDataSet / DBClient is Delphi-specific; use TBufDataset or a compatible package in Lazarus.
Replace BDE TQuery/DBTables with SQLDB components (TSQLQuery, TSQLConnector) if using Lazarus.
dxsock units include some cross-platform branches but may need minor adjustments and conditional defines for FPC.
If you want, we can produce a Lazarus port with TBufDataset and SQLdb integration.
Database engines:
Server-side SQL execution works with any engine you can query in Delphi (BDE, Interbase, FireDAC/dbExpress, or ODBC) — adapt TSQLProviderWrapper to your stack.

Getting started (quick)

Drop TDXCDSServer onto a data/server application form; configure Port and BindTo (or use INI).
Drop TDXCDSClient on client forms; assign ClientDataSet to TDataSource.
Use CreateDataSetOnServer + CreateFieldsOnServer to initialise schema; then AppendRecordToServer, GetAllDataFromServer to sync.
For SQL: implement OnExecuteSQL on the server to run SQL and return a TClientDataSet.
For replication: create TDXReplicator for each server, set KeyField and add peers via AddPeer('host', port).
Review the console demo for a full example of creation, replication and SQL request flows.
Sample component names to look for

TDXCDSServer — server-side component (registers in "DX Client/Server")
TDXCDSClient — client-side component (exposes ClientDataSet)
TDXReplicator — replication engine (WAL + sender + snapshot)
TSQLProviderWrapper — example wrapper to run SQL and return TClientDataSet
Roadmap (planned enhancements)

Built-in TLS/secure replication with certificate support (OpenSSL integration).
Optional authenticated session and ACL for commands (EXECSQL protected).
Snapshot reconciliation (merge) strategies beyond overwrite.
GUI replication monitor (status of peers, WAL queue lengths, last-sync time).
Lazarus/FPC port with TBufDataset and SQLdb examples (upon request).

Licensing / distribution

The current implementation is provided as source units and demo code. Check your organisation’s policy for third-party DXSock licensing before redistribution.
Contact your legal/commercial license team to discuss redistributing compiled components or packaging in commercial products.
Want a Lazarus port or a production-hardened build?

If you’d like a Lazarus-ready port (with TBufDataset, SQLdb, and adjusted networking), we have that variant.
For production readiness, we have harden replication: persistent last-seen state, signed ops, authenticated sockets, and monitoring tools.

Contact / next steps

To get the Lazarus port, a hardened (TLS + auth) release, or a step-by-step migration guide for your existing Delphi 7 apps, reply with:
Target DB back-end (SQLite, Interbase/Firebird, MySQL, PostgreSQL, MSSQL)
Deployment OS (Windows and also Linux, and Mac OSX)
Required conflict resolution rules (timestamp, vector clock, application merge)
We will provide an actionable plan (code patches, tests, and an integration checklist).

Thank you — Database Server v2026 brings an idiomatic, Delphi 7 dataset model to client/server and replicated scenarios with a pragmatic, extensible architecture.
Post Reply