Skip to content

Commit

Permalink
kafka_fdw_get_watermarks: use bigint (2nd take) (#44)
Browse files Browse the repository at this point in the history
* kafka_fdw_get_watermarks: the C symbol returns int64_t (and so does rdkafka), use bigint

* kafka_fdw_get_watermarks: move function argument type changes into a new update script, bump the
extension's version.

* Remove PARALLEL SAFE label kafka_get_watermarks() function just to be on
the safe side; it hardly makes sense to use it in parallel queries
anyway.

Co-authored-by: Felix Wischke (65278) <[email protected]>
  • Loading branch information
zilder and Felix Wischke (65278) authored Dec 17, 2021
1 parent 7ae38c7 commit 8c1f273
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
12 changes: 12 additions & 0 deletions kafka_fdw--0.0.2--0.0.3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DROP FUNCTION kafka_get_watermarks(IN regclass, OUT int, OUT int, OUT int);

CREATE FUNCTION kafka_get_watermarks(
IN rel regclass,
OUT partition int,
OUT offset_low bigint,
OUT offset_high bigint)
RETURNS SETOF record
AS 'MODULE_PATHNAME', 'kafka_get_watermarks'
LANGUAGE C STRICT;

ALTER TABLE kafka_fdw_offset_dump ALTER COLUMN "offset" TYPE bigint;
2 changes: 1 addition & 1 deletion kafka_fdw.control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# kafka FDW
comment = 'kafka Foreign Data Wrapper for CSV formated messages'
default_version = '0.0.2'
default_version = '0.0.3'
module_pathname = '$libdir/kafka_fdw'
relocatable = true
16 changes: 3 additions & 13 deletions sql/kafka_fdw.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CREATE TABLE kafka_fdw_offset_dump(
tbloid oid,
partition int,
"offset" int,
"offset" bigint,
last_fetch timestamp DEFAULT statement_timestamp(),
PRIMARY KEY(tbloid, partition)
);
Expand All @@ -23,18 +23,8 @@ CREATE FOREIGN DATA WRAPPER kafka_fdw

CREATE FUNCTION kafka_get_watermarks(IN rel regclass,
OUT partition int,
OUT offset_low int,
OUT offset_high int)
OUT offset_low bigint,
OUT offset_high bigint)
RETURNS SETOF record
AS 'MODULE_PATHNAME', 'kafka_get_watermarks'
LANGUAGE C STRICT;

DO $$
DECLARE version_num INTEGER;
BEGIN
SELECT current_setting('server_version_num') INTO STRICT version_num;
IF version_num > 90600 THEN
EXECUTE 'ALTER FUNCTION kafka_get_watermarks(regclass) PARALLEL SAFE';
END IF;
END
$$;

0 comments on commit 8c1f273

Please sign in to comment.