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

Commit7c1e67b

Browse files
author
Thomas G. Lockhart
committed
Implement IS OF type predicate. Can now do queries of the form:
select value IS OF (integer, float8);
1 parentb71310d commit7c1e67b

File tree

1 file changed

+44
-9
lines changed

1 file changed

+44
-9
lines changed

‎src/backend/parser/parse_expr.c

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.123 2002/07/18 17:14:19 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.124 2002/08/04 06:46:12 thomas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -282,6 +282,41 @@ transformExpr(ParseState *pstate, Node *expr)
282282
rexpr);
283283
((Expr*)result)->opType=DISTINCT_EXPR;
284284
}
285+
break;
286+
caseOF:
287+
{
288+
List*telem;
289+
A_Const*n;
290+
Oidltype,rtype;
291+
boolmatched= FALSE;
292+
293+
/* Checking an expression for match to type.
294+
* Will result in a boolean constant node.
295+
*/
296+
Node*lexpr=transformExpr(pstate,
297+
a->lexpr);
298+
ltype=exprType(lexpr);
299+
foreach(telem, (List*)a->rexpr)
300+
{
301+
rtype=LookupTypeName(lfirst(telem));
302+
matched= (rtype==ltype);
303+
if (matched)break;
304+
}
305+
306+
/* Expect two forms: equals or not equals.
307+
* Flip the sense of the result for not equals.
308+
*/
309+
if (strcmp(strVal(lfirst(a->name)),"!=")==0)
310+
matched= (!matched);
311+
312+
n=makeNode(A_Const);
313+
n->val.type=T_String;
314+
n->val.val.str= (matched?"t":"f");
315+
n->typename=SystemTypeName("bool");
316+
317+
result=transformExpr(pstate, (Node*)n);
318+
}
319+
break;
285320
}
286321
break;
287322
}
@@ -589,14 +624,14 @@ transformExpr(ParseState *pstate, Node *expr)
589624
break;
590625
}
591626

592-
/*
593-
* Quietly accept node types that may be presented when we are
594-
* called on an already-transformed tree.
595-
*
596-
* Do any other node types need to be accepted? For now we are
597-
* taking a conservative approach, and only accepting node
598-
* types that are demonstrably necessary to accept.
599-
*/
627+
/*********************************************
628+
* Quietly accept node types that may be presented when we are
629+
* called on an already-transformed tree.
630+
*
631+
* Do any other node types need to be accepted? For now we are
632+
* taking a conservative approach, and only accepting node
633+
* types that are demonstrably necessary to accept.
634+
*********************************************/
600635
caseT_Expr:
601636
caseT_Var:
602637
caseT_Const:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp