Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/backend/converter/debezium_event_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ parseDBZDML(Jsonb * jb, char op, ConnectorType type, Jsonb * source, bool isfirs
colval->typname = pstrdup(entry->typname);
}
else
elog(ERROR, "cannot find data type for column %s. None-existent column?", colval->name);
elog(ERROR, "cannot find data type for column %s. Non-existent column?", colval->name);

/* jsonpos hash must be looked up using lower case names - todo */
colname_lower = pstrdup(colval->remoteColumnName);
Expand Down Expand Up @@ -1369,7 +1369,7 @@ parseDBZDML(Jsonb * jb, char op, ConnectorType type, Jsonb * source, bool isfirs
colval->typname = pstrdup(entry->typname);
}
else
elog(ERROR, "cannot find data type for column %s. None-existent column?", colval->name);
elog(ERROR, "cannot find data type for column %s. Non-existent column?", colval->name);

/* jsonpos hash must be looked up using lower case names - todo */
colname_lower = pstrdup(colval->remoteColumnName);
Expand Down Expand Up @@ -1596,7 +1596,7 @@ parseDBZDML(Jsonb * jb, char op, ConnectorType type, Jsonb * source, bool isfirs
colval->typname = pstrdup(entry->typname);
}
else
elog(ERROR, "cannot find data type for column %s. None-existent column?", colval->name);
elog(ERROR, "cannot find data type for column %s. Non-existent column?", colval->name);

/* jsonpos hash must be looked up using lower case names - todo */
colname_lower = pstrdup(colval->remoteColumnName);
Expand Down
21 changes: 17 additions & 4 deletions src/backend/converter/format_converter.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ DatatypeHashEntry postgres_defaultTypeMappings[] =
{{"cidr", false}, "cidr", 0},
{{"circle", false}, "circle", 0},
{{"date", false}, "date", 0},
{{"decimal", false}, "dedcimal", -1},
{{"decimal", false}, "decimal", -1},
{{"double precision", false}, "double precision", 0},
{{"float", false}, "float", 0},
{{"float4", false}, "float4", 0},
Expand Down Expand Up @@ -503,7 +503,7 @@ derive_decimal_string_from_byte(const unsigned char *bytes, int len)
unsigned char *mag;
int offset;
int maglen;
char digits[128]; /* enough for DECIMAL(38) and more */
char *digits;
int nd;
int i; /* declare once and reuse */
int outlen;
Expand Down Expand Up @@ -540,9 +540,16 @@ derive_decimal_string_from_byte(const unsigned char *bytes, int len)
if (maglen == 0)
{
out = pstrdup("0");
pfree(mag - offset);
return out;
}

/*
* Allocate enough space for digits.
* 1 byte is at most 3 digits (255), closer to 2.41 digits (log10(256)).
* len * 3 is a safe upper bound.
*/
digits = (char *) palloc(len * 3 + 1);
nd = 0;

/* working copy */
Expand Down Expand Up @@ -584,6 +591,9 @@ derive_decimal_string_from_byte(const unsigned char *bytes, int len)

*p = '\0'; /* fixed misleading indentation */

pfree(digits);
pfree(mag - offset);

return out;
}

Expand Down Expand Up @@ -1021,9 +1031,9 @@ init_sqlserver(void)
}

/*
* init_sqlserver
* init_postgres
*
* initialize data type hash table for sqlserver database
* initialize data type hash table for postgres database
*/
static void
init_postgres(void)
Expand Down Expand Up @@ -1943,6 +1953,9 @@ handle_base64_to_numeric_with_scale(const char * in, int scale)
}
else
snprintf(buffer, sizeof(buffer), "%s", value);

pfree(value);

if (scale > 0)
{
if (strlen(buffer) > scale)
Expand Down
6 changes: 3 additions & 3 deletions src/backend/converter/olr_event_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,7 @@ parseOLRDML(Jsonb * jb, char op, Jsonb * payload, orascn * scn, orascn * c_scn,
colval->typname = pstrdup(entry->typname);
}
else
elog(ERROR, "cannot find data type for column %s. None-existent column?", colval->name);
elog(ERROR, "cannot find data type for column %s. Non-existent column?", colval->name);

colname_lower = pstrdup(colval->remoteColumnName);
fc_normalize_name(LCS_NORMALIZE_LOWERCASE, colname_lower, strlen(colname_lower));
Expand Down Expand Up @@ -1961,7 +1961,7 @@ parseOLRDML(Jsonb * jb, char op, Jsonb * payload, orascn * scn, orascn * c_scn,
colval->typname = pstrdup(entry->typname);
}
else
elog(ERROR, "cannot find data type for column %s. None-existent column?", colval->name);
elog(ERROR, "cannot find data type for column %s. Non-existent column?", colval->name);

colname_lower = pstrdup(colval->remoteColumnName);
fc_normalize_name(LCS_NORMALIZE_LOWERCASE, colname_lower, strlen(colname_lower));
Expand Down Expand Up @@ -2125,7 +2125,7 @@ parseOLRDML(Jsonb * jb, char op, Jsonb * payload, orascn * scn, orascn * c_scn,
colval->typname = pstrdup(entry->typname);
}
else
elog(ERROR, "cannot find data type for column %s. None-existent column?", colval->name);
elog(ERROR, "cannot find data type for column %s. Non-existent column?", colval->name);

colname_lower = pstrdup(colval->remoteColumnName);
fc_normalize_name(LCS_NORMALIZE_LOWERCASE, colname_lower, strlen(colname_lower));
Expand Down
11 changes: 11 additions & 0 deletions src/backend/synchdb/synchdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,16 @@ dbz_engine_get_offset(int connectorId)
elog(WARNING, "Exception occurred while getting connector offset");
(*env)->DeleteLocalRef(env, jdb);
(*env)->DeleteLocalRef(env, jName);
(*env)->DeleteLocalRef(env, jdstdb);
return NULL;
}

if (result == NULL)
{
elog(WARNING, "getConnectorOffset returned NULL");
(*env)->DeleteLocalRef(env, jdb);
(*env)->DeleteLocalRef(env, jName);
(*env)->DeleteLocalRef(env, jdstdb);
return NULL;
}

Expand All @@ -1204,6 +1214,7 @@ dbz_engine_get_offset(int connectorId)
(*env)->DeleteLocalRef(env, jdb);
(*env)->DeleteLocalRef(env, result);
(*env)->DeleteLocalRef(env, jName);
(*env)->DeleteLocalRef(env, jdstdb);

elog(DEBUG1, "Retrieved offset for %s connector: %s",
connectorTypeToString(sdb_state->connectors[connectorId].type), resultStr);
Expand Down
Loading