Skip to content

Commit 58aeafa

Browse files
committed
fix(database_postgresql): extract the correct pk names, the type is nameoid not textoid
1 parent 8512b26 commit 58aeafa

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/postgresql/database_postgresql.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,12 +1671,6 @@ int database_update_schema_hash (cloudsync_context *data, uint64_t *hash) {
16711671

16721672
// MARK: - PRIMARY KEY -
16731673

1674-
int database_pk_rowid (cloudsync_context *data, const char *table_name, char ***names, int *count) {
1675-
// PostgreSQL doesn't have rowid concept like SQLite
1676-
// Use OID or primary key columns instead
1677-
return database_pk_names(data, table_name, names, count);
1678-
}
1679-
16801674
int database_pk_names (cloudsync_context *data, const char *table_name, char ***names, int *count) {
16811675
if (!table_name || !names || !count) return DBRES_MISUSE;
16821676

@@ -1711,10 +1705,10 @@ int database_pk_names (cloudsync_context *data, const char *table_name, char ***
17111705
bool isnull;
17121706
Datum datum = SPI_getbinval(tuple, SPI_tuptable->tupdesc, 1, &isnull);
17131707
if (!isnull) {
1714-
text *txt = DatumGetTextP(datum);
1715-
char *name = text_to_cstring(txt);
1716-
pk_names[i] = (name) ? cloudsync_string_dup(name) : NULL;
1717-
if (name) pfree(name);
1708+
// information_schema.column_name is of type 'name', not 'text'
1709+
Name namedata = DatumGetName(datum);
1710+
char *name = NameStr(*namedata);
1711+
pk_names[i] = cloudsync_string_dup(name);
17181712
}
17191713

17201714
// Cleanup on allocation failure

0 commit comments

Comments
 (0)