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

Commit588b292

Browse files
committed
fix sigfault when inserting into area not covered with partitions and interval set to NULL
1 parent3bc9643 commit588b292

File tree

2 files changed

+42
-24
lines changed

2 files changed

+42
-24
lines changed

‎init.sql‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,40 @@ END
596596
$$ LANGUAGE plpgsql STRICT;
597597

598598

599+
/*
600+
* Set new relname, schema and tablespace
601+
*/
602+
CREATEOR REPLACE FUNCTION @extschema@.alter_partition(relation REGCLASS,
603+
new_nameTEXT,
604+
new_schema REGNAMESPACE,
605+
new_tablespaceTEXT)
606+
RETURNS VOIDAS
607+
$$
608+
DECLARE
609+
orig_nameTEXT;
610+
orig_schemaOID;
611+
BEGIN
612+
SELECT relname, relnamespaceFROM pg_classWHEREoid= relation
613+
INTO orig_name, orig_schema;
614+
615+
/* Alter table name*/
616+
IF new_name!= orig_name THEN
617+
EXECUTE format('ALTER TABLE %s RENAME TO %s', relation, new_name);
618+
END IF;
619+
620+
/* Alter table schema*/
621+
IF new_schema!= orig_schema THEN
622+
EXECUTE format('ALTER TABLE %s SET SCHEMA %s', relation, new_schema);
623+
END IF;
624+
625+
/* Move to another tablespace*/
626+
IF NOT new_tablespace ISNULL THEN
627+
EXECUTE format('ALTER TABLE %s SET TABLESPACE %s', relation, new_tablespace);
628+
END IF;
629+
END
630+
$$ LANGUAGE plpgsql;
631+
632+
599633
/*
600634
* Partitioning key
601635
*/

‎src/partition_creation.c‎

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -363,43 +363,27 @@ create_partitions_for_value_internal(Oid relid, Datum value, Oid value_type)
363363
RangeEntry*ranges=PrelGetRangesArray(prel);
364364
Datumbound_min,/* absolute MIN */
365365
bound_max;/* absolute MAX */
366-
// Infinitablebound_min,/* lower bound of all partitions */
367-
// bound_max;/* upper bound of all partitions */
368-
// Infinitablestart,
369-
// end;
370366

371367
Oidinterval_type=InvalidOid;
372368
Datuminterval_binary,/* assigned 'width' of one partition */
373369
interval_text;
374370

375-
// bound_min = ranges[0].min;
376-
// bound_max = ranges[PrelLastChild(prel)].max;
377-
378-
// start.value = !IsInfinite(&bound_min) ?
379-
// datumCopy(InfinitableGetValue(&bound_min),
380-
// prel->attbyval,
381-
// prel->attlen) :
382-
// (Datum) 0;
383-
// start.is_infinite = IsInfinite(&bound_min);
384-
385-
// end.value = !IsInfinite(&bound_max) ?
386-
// datumCopy(InfinitableGetValue(&bound_max),
387-
// prel->attbyval,
388-
// prel->attlen) :
389-
// (Datum) 0;
390-
// end.is_infinite = IsInfinite(&bound_max);
391-
392371
/* Read max & min range values from PartRelationInfo */
393-
/* TODO */
394-
// bound_min = PrelGetRangesArray(prel)[0].min;
395-
// bound_max = PrelGetRangesArray(prel)[PrelLastChild(prel)].max;
396372
bound_min=BoundGetValue(&ranges[0].min);
397373
bound_max=BoundGetValue(&ranges[PrelLastChild(prel)].max);
398374

399375
/* Copy datums on order to protect them from cache invalidation */
400376
bound_min=datumCopy(bound_min,prel->attbyval,prel->attlen);
401377
bound_max=datumCopy(bound_max,prel->attbyval,prel->attlen);
402378

379+
/* Check if interval is set */
380+
if (isnull[Anum_pathman_config_range_interval-1])
381+
{
382+
elog(ERROR,
383+
"Could not find appropriate partition for key '%s'",
384+
datum_to_cstring(value,value_type));
385+
}
386+
403387
/* Retrieve interval as TEXT from tuple */
404388
interval_text=values[Anum_pathman_config_range_interval-1];
405389

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp