Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bef4733

Browse files
committed
Code review for plpgsql fn_signature patch.
Don't quote the output of format_procedure(); it's already quoted quite enough. Remove the fn_name field, which was now just dead weight. Fix remaining expected-output files.
1 parent 4b77bfc commit bef4733

File tree

11 files changed

+95
-98
lines changed

11 files changed

+95
-98
lines changed

src/pl/plpgsql/src/pl_comp.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ do_compile(FunctionCallInfo fcinfo,
341341
ALLOCSET_DEFAULT_MAXSIZE);
342342
compile_tmp_cxt = MemoryContextSwitchTo(func_cxt);
343343

344-
function->fn_name = pstrdup(NameStr(procStruct->proname));
345344
function->fn_signature = format_procedure(fcinfo->flinfo->fn_oid);
346345
function->fn_oid = fcinfo->flinfo->fn_oid;
347346
function->fn_xmin = HeapTupleHeaderGetXmin(procTup->t_data);
@@ -803,7 +802,6 @@ plpgsql_compile_inline(char *proc_source)
803802
ALLOCSET_DEFAULT_MAXSIZE);
804803
compile_tmp_cxt = MemoryContextSwitchTo(func_cxt);
805804

806-
function->fn_name = pstrdup(func_name);
807805
function->fn_signature = pstrdup(func_name);
808806
function->fn_is_trigger = false;
809807
function->fn_input_collation = InvalidOid;

src/pl/plpgsql/src/pl_exec.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ plpgsql_exec_error_callback(void *arg)
798798
* translator: last %s is a phrase such as "during statement block
799799
* local variable initialization"
800800
*/
801-
errcontext("PL/pgSQL function \"%s\" line %d %s",
801+
errcontext("PL/pgSQL function %s line %d %s",
802802
estate->func->fn_signature,
803803
estate->err_stmt->lineno,
804804
_(estate->err_text));
@@ -809,21 +809,21 @@ plpgsql_exec_error_callback(void *arg)
809809
* translator: last %s is a phrase such as "while storing call
810810
* arguments into local variables"
811811
*/
812-
errcontext("PL/pgSQL function \"%s\" %s",
812+
errcontext("PL/pgSQL function %s %s",
813813
estate->func->fn_signature,
814814
_(estate->err_text));
815815
}
816816
}
817817
else if (estate->err_stmt != NULL)
818818
{
819819
/* translator: last %s is a plpgsql statement type name */
820-
errcontext("PL/pgSQL function \"%s\" line %d at %s",
820+
errcontext("PL/pgSQL function %s line %d at %s",
821821
estate->func->fn_signature,
822822
estate->err_stmt->lineno,
823823
plpgsql_stmt_typename(estate->err_stmt));
824824
}
825825
else
826-
errcontext("PL/pgSQL function \"%s\"",
826+
errcontext("PL/pgSQL function %s",
827827
estate->func->fn_signature);
828828
}
829829

src/pl/plpgsql/src/pl_funcs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ plpgsql_dumptree(PLpgSQL_function *func)
14611461
PLpgSQL_datum *d;
14621462

14631463
printf("\nExecution tree of successfully compiled PL/pgSQL function %s:\n",
1464-
func->fn_name);
1464+
func->fn_signature);
14651465

14661466
printf("\nFunction's data area:\n");
14671467
for (i = 0; i < func->ndatums; i++)
@@ -1538,6 +1538,6 @@ plpgsql_dumptree(PLpgSQL_function *func)
15381538
dump_indent = 0;
15391539
printf("%3d:", func->action->lineno);
15401540
dump_block(func->action);
1541-
printf("\nEnd of execution tree of function %s\n\n", func->fn_name);
1541+
printf("\nEnd of execution tree of function %s\n\n", func->fn_signature);
15421542
fflush(stdout);
15431543
}

src/pl/plpgsql/src/plpgsql.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,6 @@ typedef struct PLpgSQL_func_hashkey
678678

679679
typedef struct PLpgSQL_function
680680
{ /* Complete compiled function */
681-
char *fn_name;
682681
char *fn_signature;
683682
Oid fn_oid;
684683
TransactionId fn_xmin;

src/pl/plpython/expected/plpython_error.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ PL/Python function "python_traceback"
292292
SELECT sql_error();
293293
ERROR: division by zero
294294
CONTEXT: SQL statement "select 1/0"
295-
PL/pgSQL function "sql_error()" line 3 at SQL statement
295+
PL/pgSQL function sql_error() line 3 at SQL statement
296296
SELECT python_from_sql_error();
297297
ERROR: spiexceptions.DivisionByZero: division by zero
298298
CONTEXT: Traceback (most recent call last):
@@ -306,7 +306,7 @@ CONTEXT: Traceback (most recent call last):
306306
plpy.execute("select sql_error()")
307307
PL/Python function "python_traceback"
308308
SQL statement "select python_traceback()"
309-
PL/pgSQL function "python_from_sql_error()" line 3 at SQL statement
309+
PL/pgSQL function python_from_sql_error() line 3 at SQL statement
310310
SELECT sql_from_python_error();
311311
ERROR: spiexceptions.DivisionByZero: division by zero
312312
CONTEXT: Traceback (most recent call last):

src/pl/plpython/expected/plpython_error_0.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ PL/Python function "python_traceback"
292292
SELECT sql_error();
293293
ERROR: division by zero
294294
CONTEXT: SQL statement "select 1/0"
295-
PL/pgSQL function "sql_error" line 3 at SQL statement
295+
PL/pgSQL function sql_error() line 3 at SQL statement
296296
SELECT python_from_sql_error();
297297
ERROR: spiexceptions.DivisionByZero: division by zero
298298
CONTEXT: Traceback (most recent call last):
@@ -306,7 +306,7 @@ CONTEXT: Traceback (most recent call last):
306306
plpy.execute("select sql_error()")
307307
PL/Python function "python_traceback"
308308
SQL statement "select python_traceback()"
309-
PL/pgSQL function "python_from_sql_error" line 3 at SQL statement
309+
PL/pgSQL function python_from_sql_error() line 3 at SQL statement
310310
SELECT sql_from_python_error();
311311
ERROR: spiexceptions.DivisionByZero: division by zero
312312
CONTEXT: Traceback (most recent call last):

src/test/regress/expected/domain.out

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,15 +493,15 @@ begin
493493
end$$ language plpgsql;
494494
select doubledecrement(3); -- fail because of implicit null assignment
495495
ERROR: domain pos_int does not allow null values
496-
CONTEXT: PL/pgSQL function "doubledecrement(pos_int)" line 3 during statement block local variable initialization
496+
CONTEXT: PL/pgSQL function doubledecrement(pos_int) line 3 during statement block local variable initialization
497497
create or replace function doubledecrement(p1 pos_int) returns pos_int as $$
498498
declare v pos_int := 0;
499499
begin
500500
return p1;
501501
end$$ language plpgsql;
502502
select doubledecrement(3); -- fail at initialization assignment
503503
ERROR: value for domain pos_int violates check constraint "pos_int_check"
504-
CONTEXT: PL/pgSQL function "doubledecrement(pos_int)" line 3 during statement block local variable initialization
504+
CONTEXT: PL/pgSQL function doubledecrement(pos_int) line 3 during statement block local variable initialization
505505
create or replace function doubledecrement(p1 pos_int) returns pos_int as $$
506506
declare v pos_int := 1;
507507
begin
@@ -514,10 +514,10 @@ select doubledecrement(0); -- fail before call
514514
ERROR: value for domain pos_int violates check constraint "pos_int_check"
515515
select doubledecrement(1); -- fail at assignment to v
516516
ERROR: value for domain pos_int violates check constraint "pos_int_check"
517-
CONTEXT: PL/pgSQL function "doubledecrement(pos_int)" line 4 at assignment
517+
CONTEXT: PL/pgSQL function doubledecrement(pos_int) line 4 at assignment
518518
select doubledecrement(2); -- fail at return
519519
ERROR: value for domain pos_int violates check constraint "pos_int_check"
520-
CONTEXT: PL/pgSQL function "doubledecrement(pos_int)" while casting return value to function's return type
520+
CONTEXT: PL/pgSQL function doubledecrement(pos_int) while casting return value to function's return type
521521
select doubledecrement(3); -- good
522522
doubledecrement
523523
-----------------
@@ -566,7 +566,7 @@ end$$ language plpgsql;
566566
select array_elem_check(121.00);
567567
ERROR: numeric field overflow
568568
DETAIL: A field with precision 4, scale 2 must round to an absolute value less than 10^2.
569-
CONTEXT: PL/pgSQL function "array_elem_check(numeric)" line 5 at assignment
569+
CONTEXT: PL/pgSQL function array_elem_check(numeric) line 5 at assignment
570570
select array_elem_check(1.23456);
571571
array_elem_check
572572
------------------
@@ -584,7 +584,7 @@ end$$ language plpgsql;
584584
select array_elem_check(121.00);
585585
ERROR: numeric field overflow
586586
DETAIL: A field with precision 4, scale 2 must round to an absolute value less than 10^2.
587-
CONTEXT: PL/pgSQL function "array_elem_check(numeric)" line 5 at assignment
587+
CONTEXT: PL/pgSQL function array_elem_check(numeric) line 5 at assignment
588588
select array_elem_check(1.23456);
589589
array_elem_check
590590
------------------
@@ -602,7 +602,7 @@ end$$ language plpgsql;
602602
select array_elem_check(121.00);
603603
ERROR: numeric field overflow
604604
DETAIL: A field with precision 4, scale 2 must round to an absolute value less than 10^2.
605-
CONTEXT: PL/pgSQL function "array_elem_check(numeric)" line 5 at assignment
605+
CONTEXT: PL/pgSQL function array_elem_check(numeric) line 5 at assignment
606606
select array_elem_check(1.23456);
607607
array_elem_check
608608
------------------
@@ -650,7 +650,7 @@ select array_elem_check(3);
650650

651651
select array_elem_check(-1);
652652
ERROR: value for domain orderedpair violates check constraint "orderedpair_check"
653-
CONTEXT: PL/pgSQL function "array_elem_check(integer)" line 5 at assignment
653+
CONTEXT: PL/pgSQL function array_elem_check(integer) line 5 at assignment
654654
drop function array_elem_check(int);
655655
--
656656
-- Renaming

src/test/regress/expected/guc.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ set work_mem = '1MB';
687687
select myfunc(0);
688688
ERROR: division by zero
689689
CONTEXT: SQL statement "SELECT 1/$1"
690-
PL/pgSQL function "myfunc(integer)" line 4 at PERFORM
690+
PL/pgSQL function myfunc(integer) line 4 at PERFORM
691691
select current_setting('work_mem');
692692
current_setting
693693
-----------------

src/test/regress/expected/plancache.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ end$$ language plpgsql;
235235
select cachebug();
236236
NOTICE: table "temptable" does not exist, skipping
237237
CONTEXT: SQL statement "drop table if exists temptable cascade"
238-
PL/pgSQL function "cachebug()" line 4 at SQL statement
238+
PL/pgSQL function cachebug() line 4 at SQL statement
239239
NOTICE: 1
240240
NOTICE: 2
241241
NOTICE: 3
@@ -247,7 +247,7 @@ NOTICE: 3
247247
select cachebug();
248248
NOTICE: drop cascades to view vv
249249
CONTEXT: SQL statement "drop table if exists temptable cascade"
250-
PL/pgSQL function "cachebug()" line 4 at SQL statement
250+
PL/pgSQL function cachebug() line 4 at SQL statement
251251
NOTICE: 1
252252
NOTICE: 2
253253
NOTICE: 3

0 commit comments

Comments
 (0)