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

Commit27b0e8c

Browse files
Jan WieckJan Wieck
Jan Wieck
authored and
Jan Wieck
committed
Adding ELSIF support contributed by Klaus Reger.
Jan
1 parenta9da3fe commit27b0e8c

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

‎src/pl/plpgsql/src/gram.y

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* procedural language
55
*
66
* IDENTIFICATION
7-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.17 2001/04/1820:42:56 tgl Exp $
7+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.18 2001/05/1821:16:59 wieck Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -147,6 +147,7 @@ staticPLpgSQL_expr*make_tupret_expr(PLpgSQL_row *row);
147147
%tokenK_DIAGNOSTICS
148148
%tokenK_DOTDOT
149149
%tokenK_ELSE
150+
%tokenK_ELSIF
150151
%tokenK_END
151152
%tokenK_EXCEPTION
152153
%tokenK_EXECUTE
@@ -544,6 +545,7 @@ proc_stmts: proc_stmts proc_stmt
544545
new->stmts[0] = (structPLpgSQL_stmt *)$1;
545546

546547
$$ =new;
548+
547549
}
548550
;
549551

@@ -721,8 +723,53 @@ stmt_else:
721723
memset(new,0,sizeof(PLpgSQL_stmts));
722724
$$ =new;
723725
}
726+
|K_ELSIFlnoexpr_until_thenproc_sectstmt_else
727+
{
728+
/*
729+
* Translate the structure: into:
730+
*
731+
* IF c1 THEN IF c1 THEN
732+
* ... ...
733+
* ELSIF c2 THEN ELSE
734+
* IF c2 THEN
735+
* ... ...
736+
* ELSE ELSE
737+
* ... ...
738+
* END IF END IF
739+
* END IF
740+
*
741+
*/
742+
743+
PLpgSQL_stmts*new;
744+
PLpgSQL_stmt_if *new_if;
745+
746+
/* first create a new if-statement*/
747+
new_if = malloc(sizeof(PLpgSQL_stmt_if));
748+
memset(new_if,0,sizeof(PLpgSQL_stmt_if));
749+
750+
new_if->cmd_type= PLPGSQL_STMT_IF;
751+
new_if->lineno=$2;
752+
new_if->cond=$3;
753+
new_if->true_body=$4;
754+
new_if->false_body=$5;
755+
756+
/* this is a 'container' for the if-statement*/
757+
new = malloc(sizeof(PLpgSQL_stmts));
758+
memset(new,0,sizeof(PLpgSQL_stmts));
759+
760+
new->stmts_alloc =64;
761+
new->stmts_used =1;
762+
new->stmts = malloc(sizeof(PLpgSQL_stmt *) *new->stmts_alloc);
763+
new->stmts[0] = (structPLpgSQL_stmt *)new_if;
764+
765+
$$ =new;
766+
767+
}
768+
724769
|K_ELSEproc_sect
725-
{$$ =$2; }
770+
{
771+
$$ =$2;
772+
}
726773
;
727774

728775
stmt_loop:opt_labelK_LOOPlnoloop_body

‎src/pl/plpgsql/src/scan.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* procedural language
55
*
66
* IDENTIFICATION
7-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.10 2001/04/1820:42:56 tgl Exp $
7+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.11 2001/05/1821:16:59 wieck Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -99,6 +99,7 @@ declare{ return K_DECLARE;}
9999
default{return K_DEFAULT;}
100100
diagnostics{return K_DIAGNOSTICS;}
101101
else{return K_ELSE;}
102+
elsif {return K_ELSIF; }
102103
end{return K_END;}
103104
exception{return K_EXCEPTION;}
104105
execute{return K_EXECUTE;}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp