CREATE FOREIGN TABLE MatViews (
	VDBName string(255) NOT NULL,
	SchemaName string(512) NOT NULL,
	Name string(1024) NOT NULL,
	TargetSchemaName string(512),
	TargetName string,
	Valid boolean,
	LoadState string(255),
	Updated timestamp,
	Cardinality integer,
	PRIMARY KEY (VDBName, SchemaName, Name)
);

CREATE FOREIGN TABLE VDBResources (
	resourcePath string(255),
	contents blob,
	PRIMARY KEY (resourcePath)
);

CREATE FOREIGN PROCEDURE isLoggable(OUT loggable boolean NOT NULL RESULT, IN level string NOT NULL DEFAULT 'DEBUG', IN context string NOT NULL DEFAULT 'org.teiid.PROCESSOR')
OPTIONS (UPDATECOUNT 0)

CREATE FOREIGN PROCEDURE logMsg(OUT logged boolean NOT NULL RESULT, IN level string NOT NULL DEFAULT 'DEBUG', IN context string NOT NULL DEFAULT 'org.teiid.PROCESSOR', IN msg object NOT NULL)
OPTIONS (UPDATECOUNT 0)

/* EXTENSION */
/* ISSUE: DVCORE-2441 */
/* FIXED BY: Roman Pedchenko */
/* DATE: 2014.10.20 */
/* ADOPTED FROM: https://issues.jboss.org/browse/TEIID-2111 */
/* REATE FOREIGN PROCEDURE refreshMatView(IN ViewName string NOT NULL, IN Invalidate boolean NOT NULL DEFAULT 'false', OUT RowsUpdated integer NOT NULL RESULT) */
CREATE FOREIGN PROCEDURE refreshMatView(OUT RowsUpdated integer NOT NULL RESULT, IN ViewName string NOT NULL, IN Invalidate boolean NOT NULL DEFAULT 'false')
/* END EXTENSION */
OPTIONS (UPDATECOUNT 0)

/* EXTENSION */
/* ISSUE: DVCORE-2441 */
/* FIXED BY: Roman Pedchenko */
/* DATE: 2014.10.20 */
/* ADOPTED FROM: https://issues.jboss.org/browse/TEIID-2111 */
/* REATE FOREIGN PROCEDURE refreshMatViewRow(IN ViewName string NOT NULL, IN Key object NOT NULL, OUT RowsUpdated integer NOT NULL RESULT) */
CREATE FOREIGN PROCEDURE refreshMatViewRow(OUT RowsUpdated integer NOT NULL RESULT, IN ViewName string NOT NULL, IN Key object NOT NULL)
/* END EXTENSION */
OPTIONS (UPDATECOUNT 0)

CREATE FOREIGN PROCEDURE setColumnStats(IN tableName string NOT NULL, IN columnName string NOT NULL, IN distinctCount long, IN nullCount long, IN max string, IN min string)
OPTIONS (UPDATECOUNT 0)

CREATE FOREIGN PROCEDURE setProperty(OUT OldValue clob(2097152) NOT NULL RESULT, IN UID string(50) NOT NULL, IN Name string NOT NULL, IN "Value" clob(2097152))
OPTIONS (UPDATECOUNT 0)

CREATE FOREIGN PROCEDURE setTableStats(IN tableName string NOT NULL, IN cardinality long NOT NULL)
OPTIONS (UPDATECOUNT 0)

