@@ -599,12 +599,11 @@ build_update_trigger_func_name_internal(Oid relid)
599599
600600/*
601601 * Check that relation 'relid' is partitioned by pg_pathman.
602- *
603- * Extract tuple into 'values' and 'isnull' if they're provided.
602+ * Extract tuple into 'values', 'isnull', 'xmin', 'iptr' if they're provided.
604603 */
605604bool
606605pathman_config_contains_relation (Oid relid , Datum * values , bool * isnull ,
607- TransactionId * xmin , HeapTuple * tuple )
606+ TransactionId * xmin , ItemPointerData * iptr )
608607{
609608 Relation rel ;
610609 HeapScanDesc scan ;
@@ -662,8 +661,9 @@ pathman_config_contains_relation(Oid relid, Datum *values, bool *isnull,
662661 * xmin = DatumGetTransactionId (value );
663662 }
664663
665- if (tuple )
666- * tuple = heap_copytuple (htup );
664+ /* Set ItemPointer if necessary */
665+ if (iptr )
666+ * iptr = htup -> t_self ;
667667 }
668668
669669 /* Clean resources */
@@ -677,9 +677,78 @@ pathman_config_contains_relation(Oid relid, Datum *values, bool *isnull,
677677 return contains_rel ;
678678}
679679
680+ /* Invalidate parsed partitioning expression in PATHMAN_CONFIG */
681+ void
682+ pathman_config_invalidate_parsed_expression (Oid relid )
683+ {
684+ ItemPointerData iptr ; /* pointer to tuple */
685+ Datum values [Natts_pathman_config ];
686+ bool nulls [Natts_pathman_config ];
687+
688+ /* Check that PATHMAN_CONFIG table contains this relation */
689+ if (pathman_config_contains_relation (relid , values , nulls , NULL , & iptr ))
690+ {
691+ Relation rel ;
692+ HeapTuple new_htup ;
693+
694+ /* Reset parsed expression */
695+ values [Anum_pathman_config_expression_p - 1 ] = (Datum ) 0 ;
696+ nulls [Anum_pathman_config_expression_p - 1 ] = true;
697+
698+ /* Reset expression type */
699+ values [Anum_pathman_config_atttype - 1 ] = (Datum ) 0 ;
700+ nulls [Anum_pathman_config_atttype - 1 ] = true;
701+
702+ rel = heap_open (get_pathman_config_relid (false), RowExclusiveLock );
703+
704+ /* Form new tuple and perform an update */
705+ new_htup = heap_form_tuple (RelationGetDescr (rel ), values , nulls );
706+ simple_heap_update (rel , & iptr , new_htup );
707+ CatalogUpdateIndexes (rel , new_htup );
708+
709+ heap_close (rel , RowExclusiveLock );
710+ }
711+ }
712+
713+ /* Refresh parsed partitioning expression in PATHMAN_CONFIG */
714+ void
715+ pathman_config_refresh_parsed_expression (Oid relid ,
716+ Datum * values ,
717+ bool * isnull ,
718+ ItemPointer iptr )
719+ {
720+ char * expr_cstr ;
721+ Oid expr_type ;
722+ Datum expr_datum ;
723+
724+ Relation rel ;
725+ HeapTuple htup_new ;
726+
727+ /* get and parse expression */
728+ expr_cstr = TextDatumGetCString (values [Anum_pathman_config_expression - 1 ]);
729+ expr_datum = plan_partitioning_expression (relid , expr_cstr , & expr_type );
730+ pfree (expr_cstr );
731+
732+ /* prepare tuple values */
733+ values [Anum_pathman_config_expression_p - 1 ] = expr_datum ;
734+ isnull [Anum_pathman_config_expression_p - 1 ] = false;
735+
736+ values [Anum_pathman_config_atttype - 1 ] = ObjectIdGetDatum (expr_type );
737+ isnull [Anum_pathman_config_atttype - 1 ] = false;
738+
739+ rel = heap_open (get_pathman_config_relid (false), RowExclusiveLock );
740+
741+ htup_new = heap_form_tuple (RelationGetDescr (rel ), values , isnull );
742+ simple_heap_update (rel , iptr , htup_new );
743+ CatalogUpdateIndexes (rel , htup_new );
744+
745+ heap_close (rel , RowExclusiveLock );
746+ }
747+
748+
680749/*
681- * Loads additional pathman parameters like 'enable_parent' or 'auto'
682- * from PATHMAN_CONFIG_PARAMS.
750+ * Loads additional pathman parameters like 'enable_parent'
751+ * or 'auto' from PATHMAN_CONFIG_PARAMS.
683752 */
684753bool
685754read_pathman_params (Oid relid , Datum * values , bool * isnull )
@@ -722,6 +791,7 @@ read_pathman_params(Oid relid, Datum *values, bool *isnull)
722791 return row_found ;
723792}
724793
794+
725795/*
726796 * Go through the PATHMAN_CONFIG table and create PartRelationInfo entries.
727797 */
@@ -788,10 +858,9 @@ read_pathman_config(void)
788858
789859/*
790860 * Validates range constraint. It MUST have one of the following formats:
791- *
792- * EXPRESSION >= CONST AND EXPRESSION < CONST
793- * EXPRESSION >= CONST
794- * EXPRESSION < CONST
861+ * 1) EXPRESSION >= CONST AND EXPRESSION < CONST
862+ * 2) EXPRESSION >= CONST
863+ * 3) EXPRESSION < CONST
795864 *
796865 * Writes 'lower' & 'upper' and 'lower_null' & 'upper_null' values on success.
797866 */
@@ -838,7 +907,11 @@ validate_range_constraint(const Expr *expr,
838907 lower , upper , lower_null , upper_null );
839908}
840909
841- /* Validates a single expression of kind EXPRESSION >= CONST | EXPRESSION < CONST */
910+ /*
911+ * Validates a single expression of kind:
912+ * 1) EXPRESSION >= CONST
913+ * 2) EXPRESSION < CONST
914+ */
842915static bool
843916validate_range_opexpr (const Expr * expr ,
844917 const PartRelationInfo * prel ,
0 commit comments