Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nfGLR-0006jy-Mh for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Apr 2022 07:26:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nfGLO-0007w0-7W for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Apr 2022 07:26:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nfGLN-0007p2-E1 for pgsql-hackers@lists.postgresql.org; Fri, 15 Apr 2022 07:26:13 +0000 Received: from mail-qv1-xf2d.google.com ([2607:f8b0:4864:20::f2d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nfGLG-000322-2S for pgsql-hackers@postgresql.org; Fri, 15 Apr 2022 07:26:11 +0000 Received: by mail-qv1-xf2d.google.com with SMTP id n11so6078283qvl.0 for ; Fri, 15 Apr 2022 00:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ah2btc15/tOAFDvbPa2pabBVXcCkzVFNjIoYY200bQI=; b=U0HiBwjEJ27Kww9Q0cGaFPh+zOWmud+BSsgeV2i/ksL96GZZwsZtfpZjhgMvJa5lOX /aT9efNTf5emZd47Rpm20gpjunuZihjZnUqogEH4nBjlBmdenQFnUcUX19vydxDs9MXG ctP4YBRApbkSURwSLo2jLQPwAWFwQpOrIW7Js= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ah2btc15/tOAFDvbPa2pabBVXcCkzVFNjIoYY200bQI=; b=eiqwJFORplIXItVh707S2ZEYMHhmkc3tBfRU7g7slPv8v5lq1E8i4ODgbY+CquE1DZ O+dQouI9Fc59vnzdhpQi5Lih3fiZuX/c1VlwC+LbOb4xOxnON3AgnGcvF9DFDWwrYBDD afjQhjoKgtSOiTMCk+2FrCjBHcqodvPzqGqJJGpsD/No1izNuv029R2HSlwIaWHSPiMn fX2EIZHyCp9OPac2M4eS8bE1uiRDiY39vMgjmJwp+mfWlCGz0CXZiRz0yEQUrZEyGSzK T/U75DW5L1mkoHELlS6tibi2FUp6ig0k2XaEofANxZ/ORaHLrnIqObpYtlaWfhcIANzG DbQg== X-Gm-Message-State: AOAM531+OGvGKvj/Z6p6zd63YAbdXbVq2+kG53K9e1FOC12ErBv+FyuB VjBGdxj+Zxk0cqTOPnYoPbh/kg== X-Google-Smtp-Source: ABdhPJzTXaVSYntHzS2K1HATBuPkgfoQx0qiFvrqW5IAWO9zQLUNv8Ood94W5nRkgaOwhj7y/D8FPg== X-Received: by 2002:a0c:f801:0:b0:427:47d3:3715 with SMTP id r1-20020a0cf801000000b0042747d33715mr16196069qvn.46.1650007565153; Fri, 15 Apr 2022 00:26:05 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::2e]) by smtp.gmail.com with ESMTPSA id k2-20020a37ba02000000b0067dc1b0104asm2084959qkf.124.2022.04.15.00.26.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Apr 2022 00:26:04 -0700 (PDT) Date: Fri, 15 Apr 2022 00:26:01 -0700 From: Noah Misch To: Amit Kapila , Masahiko Sawada Cc: Euler Taveira , "osumi.takamichi@fujitsu.com" , Peter Eisentraut , "David G. Johnston" , "tanghy.fnst@fujitsu.com" , vignesh C , Greg Nancarrow , "houzj.fnst@fujitsu.com" , Alexey Lesovsky , pgsql-hackers Subject: Re: Skipping logical replication transactions on subscriber side Message-ID: <20220415072601.GG862547@rfd.leadboat.com> References: <20220405070816.GC3827588@rfd.leadboat.com> <20220406032100.GA3872143@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="f2QGlHpHGjS2mn6Y" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --f2QGlHpHGjS2mn6Y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Apr 07, 2022 at 08:39:58PM +0900, Masahiko Sawada wrote: > On Thu, Apr 7, 2022 at 7:28 PM Amit Kapila wrote: > > On Thu, Apr 7, 2022 at 8:25 AM Amit Kapila wrote: > > > I'll take care of this today. I think we can mark the new function > > > get_column_offset() being introduced by this patch as parallel safe. > > > > Pushed. > > Thanks! I took a closer look at the test case. The "get_column_offset(coltypes) % 8" part would have caught the problem only when run on an ALIGNOF_DOUBLE==4 platform. Instead of testing the start of the typalign='d' column, let's test the first offset beyond the previous column. The difference between those two values depends on ALIGNOF_DOUBLE. While there, ignore typbyval; it doesn't affect disk tuple layout, so this test shouldn't care. I plan to push the attached patch. --f2QGlHpHGjS2mn6Y Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sanity_check-skiplsn-v1.patch" Author: Noah Misch Commit: Noah Misch Test ALIGNOF_DOUBLE==4 compatibility under ALIGNOF_DOUBLE==8. Today's test case detected alignment problems only when executing on AIX. This change lets popular platforms detect the same problems. Reviewed by FIXME. Discussion: https://postgr.es/m/FIXME diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out index a2faefb..c5c675b 100644 --- a/src/test/regress/expected/sanity_check.out +++ b/src/test/regress/expected/sanity_check.out @@ -39,18 +39,18 @@ WITH check_columns AS ( SELECT t.oid FROM pg_type t JOIN pg_attribute pa ON t.oid = pa.atttypid WHERE pa.attrelid = a.attrelid AND - pa.attnum > 0 AND pa.attnum <= a.attnum + pa.attnum > 0 AND pa.attnum < a.attnum ORDER BY pa.attnum) AS coltypes FROM pg_attribute a JOIN pg_class c ON c.oid = attrelid JOIN pg_namespace n ON c.relnamespace = n.oid WHERE attalign = 'd' AND relkind = 'r' AND attnotnull AND attlen <> -1 AND n.nspname = 'pg_catalog' ) -SELECT relname, attname, coltypes, get_column_offset(coltypes) +SELECT relname, attname, coltypes, get_columns_length(coltypes) FROM check_columns - WHERE get_column_offset(coltypes) % 8 != 0 OR + WHERE get_columns_length(coltypes) % 8 != 0 OR 'name'::regtype::oid = ANY(coltypes); - relname | attname | coltypes | get_column_offset ----------+---------+----------+------------------- + relname | attname | coltypes | get_columns_length +---------+---------+----------+-------------------- (0 rows) diff --git a/src/test/regress/expected/test_setup.out b/src/test/regress/expected/test_setup.out index 8b8ba7d..391b36d 100644 --- a/src/test/regress/expected/test_setup.out +++ b/src/test/regress/expected/test_setup.out @@ -206,7 +206,7 @@ CREATE FUNCTION ttdummy () RETURNS trigger AS :'regresslib' LANGUAGE C; -CREATE FUNCTION get_column_offset (oid[]) +CREATE FUNCTION get_columns_length(oid[]) RETURNS int AS :'regresslib' LANGUAGE C STRICT STABLE PARALLEL SAFE; diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index 8b0c2d9..ade4b51 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -1219,12 +1219,12 @@ binary_coercible(PG_FUNCTION_ARGS) } /* - * Return the column offset of the last data in the given array of - * data types. The input data types must be fixed-length data types. + * Return the length of the portion of a tuple consisting of the given array + * of data types. The input data types must be fixed-length data types. */ -PG_FUNCTION_INFO_V1(get_column_offset); +PG_FUNCTION_INFO_V1(get_columns_length); Datum -get_column_offset(PG_FUNCTION_ARGS) +get_columns_length(PG_FUNCTION_ARGS) { ArrayType *ta = PG_GETARG_ARRAYTYPE_P(0); Oid *type_oids; @@ -1249,14 +1249,10 @@ get_column_offset(PG_FUNCTION_ARGS) get_typlenbyvalalign(typeoid, &typlen, &typbyval, &typalign); /* the data type must be fixed-length */ - if (!(typbyval || (typlen > 0))) + if (typlen < 0) elog(ERROR, "type %u is not fixed-length data type", typeoid); - column_offset = att_align_nominal(column_offset, typalign); - - /* not include the last type size */ - if (i != (ntypes - 1)) - column_offset += typlen; + column_offset = att_align_nominal(column_offset + typlen, typalign); } PG_RETURN_INT32(column_offset); diff --git a/src/test/regress/sql/sanity_check.sql b/src/test/regress/sql/sanity_check.sql index c70ff78..7f338d1 100644 --- a/src/test/regress/sql/sanity_check.sql +++ b/src/test/regress/sql/sanity_check.sql @@ -34,14 +34,14 @@ WITH check_columns AS ( SELECT t.oid FROM pg_type t JOIN pg_attribute pa ON t.oid = pa.atttypid WHERE pa.attrelid = a.attrelid AND - pa.attnum > 0 AND pa.attnum <= a.attnum + pa.attnum > 0 AND pa.attnum < a.attnum ORDER BY pa.attnum) AS coltypes FROM pg_attribute a JOIN pg_class c ON c.oid = attrelid JOIN pg_namespace n ON c.relnamespace = n.oid WHERE attalign = 'd' AND relkind = 'r' AND attnotnull AND attlen <> -1 AND n.nspname = 'pg_catalog' ) -SELECT relname, attname, coltypes, get_column_offset(coltypes) +SELECT relname, attname, coltypes, get_columns_length(coltypes) FROM check_columns - WHERE get_column_offset(coltypes) % 8 != 0 OR + WHERE get_columns_length(coltypes) % 8 != 0 OR 'name'::regtype::oid = ANY(coltypes); diff --git a/src/test/regress/sql/test_setup.sql b/src/test/regress/sql/test_setup.sql index fbceb8c..02c0c84 100644 --- a/src/test/regress/sql/test_setup.sql +++ b/src/test/regress/sql/test_setup.sql @@ -253,7 +253,7 @@ CREATE FUNCTION ttdummy () AS :'regresslib' LANGUAGE C; -CREATE FUNCTION get_column_offset (oid[]) +CREATE FUNCTION get_columns_length(oid[]) RETURNS int AS :'regresslib' LANGUAGE C STRICT STABLE PARALLEL SAFE; --f2QGlHpHGjS2mn6Y--