From f75ff65c0027041b95647acdb86abf0dc1158f55 Mon Sep 17 00:00:00 2001
From: "D. Richard Hipp" <drh@hwaci.com>
Date: Mon, 3 Dec 2018 01:47:41 +0000
Subject: [PATCH 0562/1009] Fix a parser bug in the use of parentheses around
 table-valued functions.

https://github.com/mackyle/sqlite/commit/f75ff65c0027041b95647acdb86abf0dc1158f55

---
 src/parse.y         |  6 ++++++
 1 files changed, 6 insertions(+), 0 deletion(-)

diff --git a/src/parse.y b/src/parse.y
index b150c73..3bb28ab 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -664,6 +664,12 @@ seltablist(A) ::= stl_prefix(A) nm(Y) dbnm(D) LP exprlist(E) RP as(Z)
         pNew->zName = pOld->zName;
         pNew->zDatabase = pOld->zDatabase;
         pNew->pSelect = pOld->pSelect;
+        if( pOld->fg.isTabFunc ){
+          pNew->u1.pFuncArg = pOld->u1.pFuncArg;
+          pOld->u1.pFuncArg = 0;
+          pOld->fg.isTabFunc = 0;
+          pNew->fg.isTabFunc = 1;
+        }
         pOld->zName = pOld->zDatabase = 0;
         pOld->pSelect = 0;
       }
-- 
1.8.3.1

