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

Commit6918df1

Browse files
committed
plpgsql's PERFORM statement now sets FOUND depending on whether any
rows were returned by the performed query. Per recent pgsql-generaldiscussion.
1 parente11f167 commit6918df1

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

‎doc/src/sgml/plsql.sgml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/plsql.sgml,v 2.59 2002/06/15 19:34:51 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/plsql.sgml,v 2.60 2002/06/24 23:12:06 tgl Exp $
33
-->
44

55
<chapter id="plpgsql">
@@ -903,7 +903,9 @@ PERFORM <replaceable>query</replaceable>;
903903
This executes a <literal>SELECT</literal>
904904
<replaceable>query</replaceable> and discards the
905905
result. <application>PL/pgSQL</application> variables are substituted
906-
in the query as usual.
906+
in the query as usual. Also, the special variable FOUND is set to
907+
true if the query produced at least one row, or false if it produced
908+
no rows.
907909
</para>
908910

909911
<note>
@@ -916,11 +918,7 @@ PERFORM <replaceable>query</replaceable>;
916918
<para>
917919
An example:
918920
<programlisting>
919-
PERFORM create_mv(''cs_session_page_requests_mv'',''
920-
SELECT session_id, page_id, count(*) AS n_hits,
921-
sum(dwell_time) AS dwell_time, count(dwell_time) AS dwell_count
922-
FROM cs_fact_table
923-
GROUP BY session_id, page_id '');
921+
PERFORM create_mv(''cs_session_page_requests_mv'', my_query);
924922
</programlisting>
925923
</para>
926924
</sect2>

‎src/pl/plpgsql/src/pl_exec.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* procedural language
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.55 2002/03/25 07:41:10 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.56 2002/06/24 23:12:06 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -969,9 +969,11 @@ exec_stmt_assign(PLpgSQL_execstate * estate, PLpgSQL_stmt_assign * stmt)
969969
else
970970
{
971971
/*
972-
* PERFORM: evaluate query and discard result.This cannot share
973-
* code with the assignment case since we do not wish to
974-
* constraint the discarded result to be only one row/column.
972+
* PERFORM: evaluate query and discard result (but set FOUND
973+
* depending on whether at least one row was returned).
974+
*
975+
* This cannot share code with the assignment case since we do not
976+
* wish to constrain the discarded result to be only one row/column.
975977
*/
976978
intrc;
977979

@@ -985,6 +987,8 @@ exec_stmt_assign(PLpgSQL_execstate * estate, PLpgSQL_stmt_assign * stmt)
985987
if (rc!=SPI_OK_SELECT)
986988
elog(ERROR,"query \"%s\" didn't return data",expr->query);
987989

990+
exec_set_found(estate, (estate->eval_processed!=0));
991+
988992
exec_eval_cleanup(estate);
989993
}
990994

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp