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

Commit167330b

Browse files
committed
Fix convertiong regprocedure to text, small refactoring
1 parent59778f5 commit167330b

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

‎hash.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ BEGIN
141141

142142
/* Fetch init_callback from 'params' table*/
143143
WITH stub_callback(stub)as (values (0))
144-
SELECTcoalesce(init_callback,NULL)
144+
SELECT init_callback
145145
FROM stub_callback
146146
LEFT JOIN @extschema@.pathman_config_paramsAS params
147147
ONparams.partrel= parent_relid

‎init.sql

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ CREATE TABLE IF NOT EXISTS @extschema@.pathman_config_params (
5252
partrelREGCLASSNOT NULLPRIMARY KEY,
5353
enable_parentBOOLEANNOT NULL DEFAULT FALSE,
5454
autoBOOLEANNOT NULL DEFAULT TRUE,
55-
init_callbackTEXT,
55+
init_callbackTEXT DEFAULTNULL,
5656
spawn_using_bgwBOOLEANNOT NULL DEFAULT FALSE
5757

5858
CHECK (@extschema@.validate_part_callback(init_callback))/* check signature*/
@@ -157,12 +157,21 @@ CREATE OR REPLACE FUNCTION @extschema@.set_init_callback(
157157
callbackREGPROC DEFAULT0)
158158
RETURNS VOIDAS
159159
$$
160+
DECLARE
161+
regproc_textTEXT;
160162
BEGIN
161-
PERFORM @extschema@.pathman_set_param(relation,'init_callback',
162-
CASE WHEN callback<>0
163-
THEN regprocedureout(callback)::text
164-
ELSENULL END);
165-
163+
IF callback!=0 THEN
164+
EXECUTE'SELECT quote_ident(nspname) ||''.'' || quote_ident(proname)'
165+
'||''('' || (SELECT string_agg(x.argtype::regtype::text,'','')'
166+
' FROM unnest(proargtypes) AS x(argtype))'
167+
'||'')'''
168+
'FROM pg_proc p JOIN pg_namespace n ON n.oid=p.pronamespace WHERE p.oid=$1'
169+
INTO regproc_text
170+
USING callback;
171+
ELSE
172+
regproc_text :=NULL;
173+
END IF;
174+
PERFORM @extschema@.pathman_set_param(relation,'init_callback', regproc_text);
166175
END
167176
$$
168177
LANGUAGE plpgsql STRICT;

‎range.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ BEGIN
10511051

10521052
/* Fetch init_callback from 'params' table*/
10531053
WITH stub_callback(stub)as (values (0))
1054-
SELECTcoalesce(init_callback,NULL)
1054+
SELECT init_callback
10551055
FROM stub_callback
10561056
LEFT JOIN @extschema@.pathman_config_paramsAS params
10571057
ONparams.partrel= parent_relid

‎src/partition_creation.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,23 +1394,23 @@ make_int_value_struct(int int_val)
13941394
/*
13951395
* Utility function that converts signature of procedure into regprocedure.
13961396
*
1397-
* Precondition:proname_args != NULL.
1397+
* Precondition:proc_signature != NULL.
13981398
*
13991399
* Returns InvalidOid if proname_args is not found.
14001400
* Raise error if it's incorrect.
14011401
*/
14021402
staticOid
1403-
text2regprocedure(text*proname_args)
1403+
text2regprocedure(text*proc_signature)
14041404
{
14051405
FunctionCallInfoDatafcinfo;
14061406
Datumresult;
14071407

14081408
InitFunctionCallInfoData(fcinfo,NULL,1,InvalidOid,NULL,NULL);
14091409

14101410
#ifPG_VERSION_NUM >=90600
1411-
fcinfo.arg[0]=PointerGetDatum(proname_args);
1411+
fcinfo.arg[0]=PointerGetDatum(proc_signature);
14121412
#else
1413-
fcinfo.arg[0]=CStringGetDatum(text_to_cstring(proname_args));
1413+
fcinfo.arg[0]=CStringGetDatum(text_to_cstring(proc_signature));
14141414
#endif
14151415
fcinfo.argnull[0]= false;
14161416

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp