001package gudusoft.gsqlparser.stmt.sqlite; 002 003import gudusoft.gsqlparser.EDbVendor; 004import gudusoft.gsqlparser.ESqlStatementType; 005import gudusoft.gsqlparser.TCustomSqlStatement; 006import gudusoft.gsqlparser.TVisitorAbs; 007import gudusoft.gsqlparser.nodes.*; 008 009/** 010 * SQLite PRAGMA statement. 011 * 012 * <p>Three forms:</p> 013 * <ul> 014 * <li>PRAGMA pragma_name (no argument)</li> 015 * <li>PRAGMA pragma_name = value (assignment)</li> 016 * <li>PRAGMA pragma_name(value) (function-call)</li> 017 * </ul> 018 */ 019public class TPragmaStmt extends TCustomSqlStatement { 020 021 public TPragmaStmt(EDbVendor dbvendor) { 022 super(dbvendor); 023 sqlstatementtype = ESqlStatementType.sstSqlitePragma; 024 } 025 026 void buildsql() { 027 } 028 029 void clear() { 030 } 031 032 String getasprettytext() { 033 return ""; 034 } 035 036 void iterate(TVisitorAbs pvisitor) { 037 } 038 039 private TObjectName pragmaName = null; 040 041 /** 042 * Returns the PRAGMA name (may be schema-qualified, e.g., schema.pragma_name). 043 */ 044 public TObjectName getPragmaName() { 045 return pragmaName; 046 } 047 048 private TExpression pragmaValue = null; 049 050 /** 051 * Returns the PRAGMA value (for assignment or function-call forms). 052 * Returns null for no-argument form. 053 */ 054 public TExpression getPragmaValue() { 055 return pragmaValue; 056 } 057 058 public int doParseStatement(TCustomSqlStatement psql) { 059 if (rootNode == null) return -1; 060 super.doParseStatement(psql); 061 062 TDummy dummySqlNode = (TDummy) rootNode; 063 pragmaName = (TObjectName) dummySqlNode.node1; 064 if (dummySqlNode.node2 != null) { 065 pragmaValue = (TExpression) dummySqlNode.node2; 066 } 067 068 return 0; 069 } 070 071 public void accept(TParseTreeVisitor v) { 072 v.preVisit(this); 073 v.postVisit(this); 074 } 075 076 public void acceptChildren(TParseTreeVisitor v) { 077 v.preVisit(this); 078 v.postVisit(this); 079 } 080}