Switching fprintf usage to elog
parent
e19e93e715
commit
becb332b8c
|
@ -132,10 +132,10 @@ static void pg_decode_startup(LogicalDecodingContext *ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->debug_mode) {
|
if (data->debug_mode) {
|
||||||
fprintf(stderr, "Decoderbufs DEBUG MODE is ON.\n");
|
elog(NOTICE, "Decoderbufs DEBUG MODE is ON.");
|
||||||
opt->output_type = OUTPUT_PLUGIN_TEXTUAL_OUTPUT;
|
opt->output_type = OUTPUT_PLUGIN_TEXTUAL_OUTPUT;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Decoderbufs DEBUG MODE is OFF.\n");
|
elog(NOTICE, "Decoderbufs DEBUG MODE is OFF.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
|
@ -147,8 +147,7 @@ static void pg_decode_startup(LogicalDecodingContext *ctx,
|
||||||
char *geom_oid_str = NULL;
|
char *geom_oid_str = NULL;
|
||||||
char *geog_oid_str = NULL;
|
char *geog_oid_str = NULL;
|
||||||
if (SPI_connect() == SPI_ERROR_CONNECT) {
|
if (SPI_connect() == SPI_ERROR_CONNECT) {
|
||||||
elog(NOTICE,
|
elog(NOTICE, "Could not connect to SPI manager to scan for PostGIS types");
|
||||||
"Could not connect to SPI manager to scan for PostGIS types");
|
|
||||||
SPI_finish();
|
SPI_finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -159,9 +158,7 @@ static void pg_decode_startup(LogicalDecodingContext *ctx,
|
||||||
geom_oid_str =
|
geom_oid_str =
|
||||||
SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1);
|
SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1);
|
||||||
if (geom_oid_str != NULL) {
|
if (geom_oid_str != NULL) {
|
||||||
fprintf(stderr,
|
elog(NOTICE, "Decoderbufs detected PostGIS geometry type with oid: %s", geom_oid_str);
|
||||||
"Decoderbufs detected PostGIS geometry type with oid: %s\n",
|
|
||||||
geom_oid_str);
|
|
||||||
geometry_oid = atoi(geom_oid_str);
|
geometry_oid = atoi(geom_oid_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,9 +169,7 @@ static void pg_decode_startup(LogicalDecodingContext *ctx,
|
||||||
geog_oid_str =
|
geog_oid_str =
|
||||||
SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1);
|
SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1);
|
||||||
if (geog_oid_str != NULL) {
|
if (geog_oid_str != NULL) {
|
||||||
fprintf(stderr,
|
elog(NOTICE, "Decoderbufs detected PostGIS geography type with oid: %s", geog_oid_str);
|
||||||
"Decoderbufs detected PostGIS geography type with oid: %s\n",
|
|
||||||
geog_oid_str);
|
|
||||||
geography_oid = atoi(geog_oid_str);
|
geography_oid = atoi(geog_oid_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,6 +341,7 @@ static bool geography_point_as_decoderbufs_point(Datum datum,
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
p->x = p2d.x;
|
p->x = p2d.x;
|
||||||
p->y = p2d.y;
|
p->y = p2d.y;
|
||||||
|
elog(DEBUG1, "Translating geography to point: (x,y) = (%f,%f)", p->x, p->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -427,6 +423,7 @@ static void set_datum_value(Decoderbufs__DatumMessage *datum_msg, Oid typid,
|
||||||
default:
|
default:
|
||||||
// PostGIS uses dynamic OIDs so we need to check the type again here
|
// PostGIS uses dynamic OIDs so we need to check the type again here
|
||||||
if (typid == geometry_oid || typid == geography_oid) {
|
if (typid == geometry_oid || typid == geography_oid) {
|
||||||
|
elog(DEBUG1, "Converting geography point to datum_point");
|
||||||
datum_msg->datum_point = palloc(sizeof(Decoderbufs__Point));
|
datum_msg->datum_point = palloc(sizeof(Decoderbufs__Point));
|
||||||
geography_point_as_decoderbufs_point(datum, datum_msg->datum_point);
|
geography_point_as_decoderbufs_point(datum, datum_msg->datum_point);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue