Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgsql 16 and 17 support #22

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Conversation

petrov9268
Copy link

@petrov9268 petrov9268 commented Oct 11, 2024

Add pgsql 16 and 17 support

Do not merge.

Currently only tested on 16.0, 16.4 and 17.0, previous versions may be broken due to changes made for pgsql 16 support.

  • pgsql 15
  • pgsql 14
  • pgsql 13
  • pgsql 12
  • pgsql 11?
  • older versions, if they even compile at all at this point

@petrov9268
Copy link
Author

Builds just fine with servers ranging between 9.4.x-17.0.

Supported versions build on initial and the latest version (e.g. 12.0 and 12.20 both build).

There is a problem when building with CFLAGS="-DUSE_VALGRIND" though:

--00:02:32:11.310 517-- Reading syms from /usr/local/pgsql/lib/plpgsql.so
--00:02:32:11.884 517-- REDIR: 0x4ab2c60 (libc.so.6:__wcsnlen_avx2) redirected to 0x4852760 (wcsnlen)
--00:02:32:11.913 517-- Reading syms from /usr/local/pgsql/lib/redis_fdw.so
--00:02:32:11.916 517-- Reading syms from /usr/lib64/libhiredis.so.1.0.0
--00:02:32:12.004 517-- REDIR: 0x4aaf260 (libc.so.6:__strncasecmp_avx2) redirected to 0x484e140 (strncasecmp)
--00:02:32:12.009 517-- REDIR: 0x4ae8820 (libc.so.6:__strpbrk_sse42) redirected to 0x4852470 (strpbrk)
--00:02:32:12.050 517-- REDIR: 0x4aad330 (libc.so.6:__strcasecmp_avx2) redirected to 0x484e060 (strcasecmp)
==00:02:32:12.156 517== Invalid read of size 2
==00:02:32:12.156 517==    at 0x48512EF: memmove (vg_replace_strmem.c:1410)
==00:02:32:12.156 517==    by 0xE78D1B4: redis_deserialize_rtable (redis_fdw.c:835)
==00:02:32:12.156 517==    by 0xE78D9B7: redis_deserialize_fdw (redis_fdw.c:996)
==00:02:32:12.156 517==    by 0xE791BB9: redisBeginForeignScan (redis_fdw.c:2486)
==00:02:32:12.156 517==    by 0x772AF2: ExecInitForeignScan (nodeForeignscan.c:286)
==00:02:32:12.156 517==    by 0x754EFF: ExecInitNode (execProcnode.c:285)
==00:02:32:12.156 517==    by 0x74A77F: InitPlan (execMain.c:938)
==00:02:32:12.156 517==    by 0x74974B: standard_ExecutorStart (execMain.c:265)
==00:02:32:12.156 517==    by 0x7494B1: ExecutorStart (execMain.c:144)
==00:02:32:12.156 517==    by 0x7AD9B3: _SPI_pquery (spi.c:2918)
==00:02:32:12.156 517==    by 0x7AD442: _SPI_execute_plan (spi.c:2690)
==00:02:32:12.156 517==    by 0x7AA3F3: SPI_execute_plan_with_paramlist (spi.c:749)
==00:02:32:12.156 517==  Address 0xe16dc08 is 632 bytes inside a block of size 1,024 alloc'd
==00:02:32:12.156 517==    at 0x484480F: malloc (vg_replace_malloc.c:442)
==00:02:32:12.156 517==    by 0xB5CC8F: AllocSetAlloc (aset.c:920)
==00:02:32:12.156 517==    by 0xB69478: MemoryContextAllocZeroAligned (mcxt.c:956)
==00:02:32:12.156 517==    by 0x7CE504: _copyVar (copyfuncs.c:1451)
==00:02:32:12.156 517==    by 0x7D8F12: copyObjectImpl (copyfuncs.c:5266)
==00:02:32:12.156 517==    by 0x7D0020: _copyTargetEntry (copyfuncs.c:2227)
==00:02:32:12.156 517==    by 0x7D9284: copyObjectImpl (copyfuncs.c:5392)
==00:02:32:12.156 517==    by 0x7ECB93: list_copy_deep (list.c:1611)
==00:02:32:12.156 517==    by 0x7D93D4: copyObjectImpl (copyfuncs.c:5452)
==00:02:32:12.156 517==    by 0x7CB32A: CopyPlanFields (copyfuncs.c:132)
==00:02:32:12.156 517==    by 0x7CBEB6: CopyScanFields (copyfuncs.c:420)
==00:02:32:12.156 517==    by 0x7CC6CC: _copyForeignScan (copyfuncs.c:779)
==00:02:32:12.156 517== 
{
   <insert_a_suppression_name_here>
   Memcheck:Addr2
   fun:memmove
   fun:redis_deserialize_rtable
   fun:redis_deserialize_fdw
   fun:redisBeginForeignScan
   fun:ExecInitForeignScan
   fun:ExecInitNode
   fun:InitPlan
   fun:standard_ExecutorStart
   fun:ExecutorStart
   fun:_SPI_pquery
   fun:_SPI_execute_plan
   fun:SPI_execute_plan_with_paramlist
}
==00:02:32:12.156 517== Invalid read of size 2
==00:02:32:12.156 517==    at 0x48512E0: memmove (vg_replace_strmem.c:1410)
==00:02:32:12.156 517==    by 0xE78D1B4: redis_deserialize_rtable (redis_fdw.c:835)
==00:02:32:12.156 517==    by 0xE78D9B7: redis_deserialize_fdw (redis_fdw.c:996)
==00:02:32:12.156 517==    by 0xE791BB9: redisBeginForeignScan (redis_fdw.c:2486)
==00:02:32:12.156 517==    by 0x772AF2: ExecInitForeignScan (nodeForeignscan.c:286)
==00:02:32:12.156 517==    by 0x754EFF: ExecInitNode (execProcnode.c:285)
==00:02:32:12.156 517==    by 0x74A77F: InitPlan (execMain.c:938)
==00:02:32:12.156 517==    by 0x74974B: standard_ExecutorStart (execMain.c:265)
==00:02:32:12.156 517==    by 0x7494B1: ExecutorStart (execMain.c:144)
==00:02:32:12.156 517==    by 0x7AD9B3: _SPI_pquery (spi.c:2918)
==00:02:32:12.156 517==    by 0x7AD442: _SPI_execute_plan (spi.c:2690)
==00:02:32:12.156 517==    by 0x7AA3F3: SPI_execute_plan_with_paramlist (spi.c:749)
==00:02:32:12.156 517==  Address 0xe16dc0a is 634 bytes inside a block of size 1,024 alloc'd
==00:02:32:12.156 517==    at 0x484480F: malloc (vg_replace_malloc.c:442)
==00:02:32:12.156 517==    by 0xB5CC8F: AllocSetAlloc (aset.c:920)
==00:02:32:12.156 517==    by 0xB69478: MemoryContextAllocZeroAligned (mcxt.c:956)
==00:02:32:12.156 517==    by 0x7CE504: _copyVar (copyfuncs.c:1451)
==00:02:32:12.156 517==    by 0x7D8F12: copyObjectImpl (copyfuncs.c:5266)
==00:02:32:12.156 517==    by 0x7D0020: _copyTargetEntry (copyfuncs.c:2227)
==00:02:32:12.156 517==    by 0x7D9284: copyObjectImpl (copyfuncs.c:5392)
==00:02:32:12.156 517==    by 0x7ECB93: list_copy_deep (list.c:1611)
==00:02:32:12.156 517==    by 0x7D93D4: copyObjectImpl (copyfuncs.c:5452)
==00:02:32:12.156 517==    by 0x7CB32A: CopyPlanFields (copyfuncs.c:132)
==00:02:32:12.156 517==    by 0x7CBEB6: CopyScanFields (copyfuncs.c:420)
==00:02:32:12.156 517==    by 0x7CC6CC: _copyForeignScan (copyfuncs.c:779)
==00:02:32:12.156 517== 
{
   <insert_a_suppression_name_here>
   Memcheck:Addr2
   fun:memmove
   fun:redis_deserialize_rtable
   fun:redis_deserialize_fdw
   fun:redisBeginForeignScan
   fun:ExecInitForeignScan
   fun:ExecInitNode
   fun:InitPlan
   fun:standard_ExecutorStart
   fun:ExecutorStart
   fun:_SPI_pquery
   fun:_SPI_execute_plan
   fun:SPI_execute_plan_with_paramlist
}
==00:02:32:12.157 517== Invalid read of size 2
==00:02:32:12.157 517==    at 0x48512EF: memmove (vg_replace_strmem.c:1410)
==00:02:32:12.157 517==    by 0xE78D25D: redis_deserialize_rtable_cols (redis_fdw.c:886)
==00:02:32:12.157 517==    by 0xE78D9E4: redis_deserialize_fdw (redis_fdw.c:999)
==00:02:32:12.157 517==    by 0xE791BB9: redisBeginForeignScan (redis_fdw.c:2486)
==00:02:32:12.157 517==    by 0x772AF2: ExecInitForeignScan (nodeForeignscan.c:286)
==00:02:32:12.157 517==    by 0x754EFF: ExecInitNode (execProcnode.c:285)
==00:02:32:12.157 517==    by 0x74A77F: InitPlan (execMain.c:938)
==00:02:32:12.157 517==    by 0x74974B: standard_ExecutorStart (execMain.c:265)
==00:02:32:12.157 517==    by 0x7494B1: ExecutorStart (execMain.c:144)
==00:02:32:12.157 517==    by 0x7AD9B3: _SPI_pquery (spi.c:2918)
==00:02:32:12.157 517==    by 0x7AD442: _SPI_execute_plan (spi.c:2690)
==00:02:32:12.157 517==    by 0x7AA3F3: SPI_execute_plan_with_paramlist (spi.c:749)
==00:02:32:12.157 517==  Address 0xe16dcfc is 876 bytes inside a block of size 1,024 alloc'd
==00:02:32:12.157 517==    at 0x484480F: malloc (vg_replace_malloc.c:442)
==00:02:32:12.157 517==    by 0xB5CC8F: AllocSetAlloc (aset.c:920)
==00:02:32:12.157 517==    by 0xB69478: MemoryContextAllocZeroAligned (mcxt.c:956)
==00:02:32:12.157 517==    by 0x7CE504: _copyVar (copyfuncs.c:1451)
==00:02:32:12.157 517==    by 0x7D8F12: copyObjectImpl (copyfuncs.c:5266)
==00:02:32:12.157 517==    by 0x7D0020: _copyTargetEntry (copyfuncs.c:2227)
==00:02:32:12.157 517==    by 0x7D9284: copyObjectImpl (copyfuncs.c:5392)
==00:02:32:12.157 517==    by 0x7ECB93: list_copy_deep (list.c:1611)
==00:02:32:12.157 517==    by 0x7D93D4: copyObjectImpl (copyfuncs.c:5452)
==00:02:32:12.157 517==    by 0x7CB32A: CopyPlanFields (copyfuncs.c:132)
==00:02:32:12.157 517==    by 0x7CBEB6: CopyScanFields (copyfuncs.c:420)
==00:02:32:12.157 517==    by 0x7CC6CC: _copyForeignScan (copyfuncs.c:779)
==00:02:32:12.157 517== 
{
   <insert_a_suppression_name_here>
   Memcheck:Addr2
   fun:memmove
   fun:redis_deserialize_rtable_cols
   fun:redis_deserialize_fdw
   fun:redisBeginForeignScan
   fun:ExecInitForeignScan
   fun:ExecInitNode
   fun:InitPlan
   fun:standard_ExecutorStart
   fun:ExecutorStart
   fun:_SPI_pquery
   fun:_SPI_execute_plan
   fun:SPI_execute_plan_with_paramlist
}
==00:02:32:12.157 517== Invalid read of size 2
==00:02:32:12.157 517==    at 0x48512E0: memmove (vg_replace_strmem.c:1410)
==00:02:32:12.157 517==    by 0xE78D25D: redis_deserialize_rtable_cols (redis_fdw.c:886)
==00:02:32:12.157 517==    by 0xE78D9E4: redis_deserialize_fdw (redis_fdw.c:999)
==00:02:32:12.157 517==    by 0xE791BB9: redisBeginForeignScan (redis_fdw.c:2486)
==00:02:32:12.157 517==    by 0x772AF2: ExecInitForeignScan (nodeForeignscan.c:286)
==00:02:32:12.157 517==    by 0x754EFF: ExecInitNode (execProcnode.c:285)
==00:02:32:12.157 517==    by 0x74A77F: InitPlan (execMain.c:938)
==00:02:32:12.157 517==    by 0x74974B: standard_ExecutorStart (execMain.c:265)
==00:02:32:12.157 517==    by 0x7494B1: ExecutorStart (execMain.c:144)
==00:02:32:12.157 517==    by 0x7AD9B3: _SPI_pquery (spi.c:2918)
==00:02:32:12.157 517==    by 0x7AD442: _SPI_execute_plan (spi.c:2690)
==00:02:32:12.157 517==    by 0x7AA3F3: SPI_execute_plan_with_paramlist (spi.c:749)
==00:02:32:12.157 517==  Address 0xe16dcfe is 878 bytes inside a block of size 1,024 alloc'd
==00:02:32:12.157 517==    at 0x484480F: malloc (vg_replace_malloc.c:442)
==00:02:32:12.157 517==    by 0xB5CC8F: AllocSetAlloc (aset.c:920)
==00:02:32:12.157 517==    by 0xB69478: MemoryContextAllocZeroAligned (mcxt.c:956)
==00:02:32:12.157 517==    by 0x7CE504: _copyVar (copyfuncs.c:1451)
==00:02:32:12.157 517==    by 0x7D8F12: copyObjectImpl (copyfuncs.c:5266)
==00:02:32:12.157 517==    by 0x7D0020: _copyTargetEntry (copyfuncs.c:2227)
==00:02:32:12.157 517==    by 0x7D9284: copyObjectImpl (copyfuncs.c:5392)
==00:02:32:12.157 517==    by 0x7ECB93: list_copy_deep (list.c:1611)
==00:02:32:12.157 517==    by 0x7D93D4: copyObjectImpl (copyfuncs.c:5452)
==00:02:32:12.157 517==    by 0x7CB32A: CopyPlanFields (copyfuncs.c:132)
==00:02:32:12.157 517==    by 0x7CBEB6: CopyScanFields (copyfuncs.c:420)
==00:02:32:12.157 517==    by 0x7CC6CC: _copyForeignScan (copyfuncs.c:779)
==00:02:32:12.157 517== 
{
   <insert_a_suppression_name_here>
   Memcheck:Addr2
   fun:memmove
   fun:redis_deserialize_rtable_cols
   fun:redis_deserialize_fdw
   fun:redisBeginForeignScan
   fun:ExecInitForeignScan
   fun:ExecInitNode
   fun:InitPlan
   fun:standard_ExecutorStart
   fun:ExecutorStart
   fun:_SPI_pquery
   fun:_SPI_execute_plan
   fun:SPI_execute_plan_with_paramlist
}

Script to reproduce:

CREATE FOREIGN TABLE IF NOT EXISTS rft_str(
        key    TEXT,
        value  TEXT,
        expiry INT
) SERVER localredis
  OPTIONS (tabletype 'string', database '1');

CREATE OR REPLACE FUNCTION where_clause_func_expr()
  RETURNS TEXT
  LANGUAGE plpgsql
AS $$
BEGIN
  DECLARE
    _str TEXT = 'strkey';
    _val TEXT;
  BEGIN
    SELECT value INTO _val FROM rft_str WHERE key = lower(_str);
    RETURN _val;
  END;
END;
$$;

SELECT where_clause_func_expr();

This can be a false positive, but it is a good idea to check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant