Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitca5ca25

Browse files
author
Amit Kapila
committed
MAXALIGN the target address where we store flattened value.
The API (EOH_flatten_into) that flattens the expanded value representationexpects the target address to be maxaligned. All it's usage adhere to thatprinciple except when serializing datums for parallel query. Fix thatusage.Diagnosed-by: Tom LaneAuthor: Tom Lane and Amit KapilaBackpatch-through: 9.6Discussion:https://postgr.es/m/11629.1536550032@sss.pgh.pa.us
1 parenta051c19 commitca5ca25

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

‎src/backend/utils/adt/datum.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,19 @@ datumSerialize(Datum value, bool isnull, bool typByVal, int typLen,
338338
}
339339
elseif (eoh)
340340
{
341-
EOH_flatten_into(eoh, (void*)*start_address,header);
341+
char*tmp;
342+
343+
/*
344+
* EOH_flatten_into expects the target address to be maxaligned,
345+
* so we can't store directly to *start_address.
346+
*/
347+
tmp= (char*)palloc(header);
348+
EOH_flatten_into(eoh, (void*)tmp,header);
349+
memcpy(*start_address,tmp,header);
342350
*start_address+=header;
351+
352+
/* be tidy. */
353+
pfree(tmp);
343354
}
344355
else
345356
{

‎src/test/regress/expected/select_parallel.out

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,34 @@ ORDER BY 1, 2, 3;
10881088
------------------------------+---------------------------+-------------+--------------
10891089
(0 rows)
10901090

1091-
-- test interation between subquery and partial_paths
1091+
-- test passing expanded-value representations to workers
1092+
CREATE FUNCTION make_some_array(int,int) returns int[] as
1093+
$$declare x int[];
1094+
begin
1095+
x[1] := $1;
1096+
x[2] := $2;
1097+
return x;
1098+
end$$ language plpgsql parallel safe;
1099+
CREATE TABLE fooarr(f1 text, f2 int[], f3 text);
1100+
INSERT INTO fooarr VALUES('1', ARRAY[1,2], 'one');
1101+
PREPARE pstmt(text, int[]) AS SELECT * FROM fooarr WHERE f1 = $1 AND f2 = $2;
1102+
EXPLAIN (COSTS OFF) EXECUTE pstmt('1', make_some_array(1,2));
1103+
QUERY PLAN
1104+
------------------------------------------------------------------
1105+
Gather
1106+
Workers Planned: 3
1107+
-> Parallel Seq Scan on fooarr
1108+
Filter: ((f1 = '1'::text) AND (f2 = '{1,2}'::integer[]))
1109+
(4 rows)
1110+
1111+
EXECUTE pstmt('1', make_some_array(1,2));
1112+
f1 | f2 | f3
1113+
----+-------+-----
1114+
1 | {1,2} | one
1115+
(1 row)
1116+
1117+
DEALLOCATE pstmt;
1118+
-- test interaction between subquery and partial_paths
10921119
SET LOCAL min_parallel_table_scan_size TO 0;
10931120
CREATE VIEW tenk1_vw_sec WITH (security_barrier) AS SELECT * FROM tenk1;
10941121
EXPLAIN (COSTS OFF)

‎src/test/regress/sql/select_parallel.sql

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,23 @@ ORDER BY 1;
410410
SELECT*FROMinformation_schema.foreign_data_wrapper_options
411411
ORDER BY1,2,3;
412412

413-
-- test interation between subquery and partial_paths
413+
-- test passing expanded-value representations to workers
414+
CREATEFUNCTIONmake_some_array(int,int) returnsint[]as
415+
$$declare xint[];
416+
begin
417+
x[1] := $1;
418+
x[2] := $2;
419+
return x;
420+
end$$ language plpgsql parallel safe;
421+
CREATETABLEfooarr(f1text, f2int[], f3text);
422+
INSERT INTO fooarrVALUES('1', ARRAY[1,2],'one');
423+
424+
PREPARE pstmt(text,int[])ASSELECT*FROM fooarrWHERE f1= $1AND f2= $2;
425+
EXPLAIN (COSTS OFF) EXECUTE pstmt('1', make_some_array(1,2));
426+
EXECUTE pstmt('1', make_some_array(1,2));
427+
DEALLOCATE pstmt;
428+
429+
-- test interaction between subquery and partial_paths
414430
SET LOCAL min_parallel_table_scan_size TO0;
415431
CREATEVIEWtenk1_vw_sec WITH (security_barrier)ASSELECT*FROM tenk1;
416432
EXPLAIN (COSTS OFF)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp