@@ -74,6 +74,8 @@ static ObjectAddress create_table_using_stmt(CreateStmt *create_stmt,
7474static void copy_foreign_keys (Oid parent_relid ,Oid partition_oid );
7575static void postprocess_child_table_and_atts (Oid parent_relid ,Oid partition_relid );
7676
77+ static Oid text_to_regprocedure (text * proname_args );
78+
7779static Constraint * make_constraint_common (char * name ,Node * raw_expr );
7880
7981static Value make_string_value_struct (char * str );
@@ -406,13 +408,20 @@ create_partitions_for_value_internal(Oid relid, Datum value, Oid value_type)
406408{
407409ErrorData * edata ;
408410
411+ /* Simply rethrow ERROR if we're in backend */
412+ if (!IsBackgroundWorker )
413+ PG_RE_THROW ();
414+
409415/* Switch to the original context & copy edata */
410416MemoryContextSwitchTo (old_mcxt );
411417edata = CopyErrorData ();
412418FlushErrorState ();
413419
414- elog (LOG ,"create_partitions_internal(): %s [%u]" ,
415- edata -> message ,MyProcPid );
420+ /* Produce log message if we're in BGW */
421+ ereport (LOG ,
422+ (errmsg (CppAsString (create_partitions_for_value_internal )": %s [%u]" ,
423+ edata -> message ,MyProcPid ),
424+ (edata -> detail ) ?errdetail ("%s" ,edata -> detail ) :0 ));
416425
417426FreeErrorData (edata );
418427
@@ -1466,14 +1475,26 @@ invoke_init_callback_internal(init_callback_params *cb_params)
14661475/* Search for init_callback entry in PATHMAN_CONFIG_PARAMS */
14671476if (read_pathman_params (parent_oid ,param_values ,param_isnull ))
14681477{
1469- Datum init_cb_datum ;/*Oid of init_callback */
1478+ Datum init_cb_datum ;/*signature of init_callback */
14701479AttrNumber init_cb_attno = Anum_pathman_config_params_init_callback ;
14711480
1472- /* Extract Datum storing callback'sOid */
1481+ /* Extract Datum storing callback'ssignature */
14731482init_cb_datum = param_values [init_cb_attno - 1 ];
14741483
14751484/* Cache init_callback's Oid */
1476- cb_params -> callback = DatumGetObjectId (init_cb_datum );
1485+ if (init_cb_datum )
1486+ {
1487+ /* Try fetching callback's Oid */
1488+ cb_params -> callback = text_to_regprocedure (DatumGetTextP (init_cb_datum ));
1489+
1490+ if (!RegProcedureIsValid (cb_params -> callback ))
1491+ ereport (ERROR ,
1492+ (errcode (ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION ),
1493+ errmsg ("callback function \"%s\" does not exist" ,
1494+ TextDatumGetCString (init_cb_datum ))));
1495+ }
1496+ else
1497+ cb_params -> callback = InvalidOid ;
14771498cb_params -> callback_is_cached = true;
14781499}
14791500}
@@ -1619,3 +1640,31 @@ validate_part_callback(Oid procid, bool emit_error)
16191640
16201641return is_ok ;
16211642}
1643+
1644+ /*
1645+ * Utility function that converts signature of procedure into regprocedure.
1646+ *
1647+ * Precondition: proc_signature != NULL.
1648+ *
1649+ * Returns InvalidOid if proname_args is not found.
1650+ * Raise error if it's incorrect.
1651+ */
1652+ static Oid
1653+ text_to_regprocedure (text * proc_signature )
1654+ {
1655+ FunctionCallInfoData fcinfo ;
1656+ Datum result ;
1657+
1658+ InitFunctionCallInfoData (fcinfo ,NULL ,1 ,InvalidOid ,NULL ,NULL );
1659+
1660+ #if PG_VERSION_NUM >=90600
1661+ fcinfo .arg [0 ]= PointerGetDatum (proc_signature );
1662+ #else
1663+ fcinfo .arg [0 ]= CStringGetDatum (text_to_cstring (proc_signature ));
1664+ #endif
1665+ fcinfo .argnull [0 ]= false;
1666+
1667+ result = to_regprocedure (& fcinfo );
1668+
1669+ return DatumGetObjectId (result );
1670+ }