Skip to content

Commit 3476f3d

Browse files
committed
Finished implementing cloudsync_changes
1 parent b100edd commit 3476f3d

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/cloudsync.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
extern "C" {
1818
#endif
1919

20-
#define CLOUDSYNC_VERSION "0.9.1"
20+
#define CLOUDSYNC_VERSION "0.9.3"
2121
#define CLOUDSYNC_MAX_TABLENAME_LEN 512
2222

2323
#define CLOUDSYNC_VALUE_NOTSET -1

src/pk.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,15 @@ size_t pk_encode_data (char *buffer, size_t bseek, char *data, size_t datalen) {
332332

333333
char *pk_encode (dbvalue_t **argv, int argc, char *b, bool is_prikey, size_t *bsize) {
334334
size_t bseek = 0;
335-
size_t blen = 0;
336335
char *buffer = b;
337336

337+
// always compute blen (even if it is not a primary key)
338+
size_t blen = pk_encode_size(argv, argc, (is_prikey) ? 1 : 0);
339+
338340
// in primary-key encoding the number of items must be explicitly added to the encoded buffer
339341
if (is_prikey) {
340342
// 1 is the number of items in the serialization
341343
// always 1 byte so max 255 primary keys, even if there is an hard SQLite limit of 128
342-
blen = pk_encode_size(argv, argc, 1);
343344
size_t blen_curr = *bsize;
344345
buffer = (blen > blen_curr || b == NULL) ? cloudsync_memory_alloc((uint64_t)blen) : b;
345346
if (!buffer) return NULL;

src/postgresql/cloudsync_postgresql.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ PG_MODULE_MAGIC;
4848
#endif
4949

5050
#define CLOUDSYNC_RLS_RESTRICTED_VALUE_BYTEA "E'\\\\x0b095f5f5b524c535d5f5f'::bytea"
51+
#define CLOUDSYNC_NULL_VALUE_BYTEA "E'\\\\x05'::bytea"
5152

5253
// External declaration
5354
Datum database_column_datum (dbvm_t *vm, int index);
@@ -1858,11 +1859,11 @@ static char * build_union_sql (void) {
18581859
initStringInfo(&caseexpr);
18591860
appendStringInfoString(&caseexpr,
18601861
"CASE "
1861-
"WHEN t1.col_name = '" CLOUDSYNC_TOMBSTONE_VALUE "' THEN cloudsync_encode_value(NULL::text) "
1862+
"WHEN t1.col_name = '" CLOUDSYNC_TOMBSTONE_VALUE "' THEN " CLOUDSYNC_NULL_VALUE_BYTEA " "
18621863
"WHEN b.ctid IS NULL THEN " CLOUDSYNC_RLS_RESTRICTED_VALUE_BYTEA " "
18631864
"ELSE CASE t1.col_name "
18641865
);
1865-
1866+
18661867
for (uint64 k = 0; k < ncols; k++) {
18671868
HeapTuple ct = SPI_tuptable->vals[k];
18681869
TupleDesc cd = SPI_tuptable->tupdesc;

0 commit comments

Comments
 (0)