use of org.apache.derby.catalog.TypeDescriptor in project derby by apache.
the class DataDictionaryImpl method create_10_10_system_procedures.
/**
* <p>
* Create system procedures that are part of the SYSCS_UTIL schema, added in version 10.10.
* </p>
*
* @param tc an instance of the Transaction Controller.
* @param newlyCreatedRoutines set of routines we are creating (used to add permissions later on)
*/
void create_10_10_system_procedures(TransactionController tc, HashSet<String> newlyCreatedRoutines) throws StandardException {
UUID sysUtilUUID = getSystemUtilSchemaDescriptor().getUUID();
TypeDescriptor varchar32672Type = DataTypeDescriptor.getCatalogType(Types.VARCHAR, 32672);
// void SYSCS_UTIL.SYSCS_INVALIDATE_STORED_STATEMENTS()
{
createSystemProcedureOrFunction("SYSCS_INVALIDATE_STORED_STATEMENTS", sysUtilUUID, (String[]) null, (TypeDescriptor[]) null, 0, 0, RoutineAliasInfo.NO_SQL, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// void SYSCS_UTIL.SYSCS_REGISTER_TOOL
{
// procedure argument names
String[] arg_names = { "toolName", "register", "optionalArgs" };
// procedure argument types
TypeDescriptor[] arg_types = { varchar32672Type, DataTypeDescriptor.getCatalogType(Types.BOOLEAN), varchar32672Type };
createSystemProcedureOrFunction("SYSCS_REGISTER_TOOL", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, true, (TypeDescriptor) null, newlyCreatedRoutines, tc, "org.apache.derby.catalog.Java5SystemProcedures");
}
}
use of org.apache.derby.catalog.TypeDescriptor in project derby by apache.
the class DataDictionaryImpl method create_SYSCS_procedures.
/**
* Create system procedures
* <p>
* Used to add the system procedures to the database when
* it is created. System procedures are currently added to
* either SYSCS_UTIL or SQLJ schemas.
* <p>
*
* @param tc transaction controller to use. Counts on caller to
* commit.
* @param newlyCreatedRoutines evolving set of routines which may need to be given permissions later on
*
* @exception StandardException Standard exception policy.
*/
private final void create_SYSCS_procedures(TransactionController tc, HashSet<String> newlyCreatedRoutines) throws StandardException {
// Types used for routine parameters and return types, all nullable.
TypeDescriptor varchar32672Type = DataTypeDescriptor.getCatalogType(Types.VARCHAR, 32672);
/*
** SYSCS_UTIL routines.
*/
// used to put procedure into the SYSCS_UTIL schema
UUID sysUtilUUID = getSystemUtilSchemaDescriptor().getUUID();
// void SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(
// varchar(128), varchar(Limits.DB2_VARCHAR_MAXWIDTH))
{
// procedure argument names
String[] arg_names = { "KEY", "VALUE" };
// procedure argument types
TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, DataTypeDescriptor.getCatalogType(Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH) };
createSystemProcedureOrFunction("SYSCS_SET_DATABASE_PROPERTY", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// void SYSCS_UTIL.SYSCS_COMPRESS_TABLE(varchar(128), varchar(128), SMALLINT)
{
// procedure argument names
String[] arg_names = { "SCHEMANAME", "TABLENAME", "SEQUENTIAL" };
// procedure argument types
TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER, TypeDescriptor.SMALLINT };
createSystemProcedureOrFunction("SYSCS_COMPRESS_TABLE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// void SYSCS_UTIL.SYSCS_CHECKPOINT_DATABASE()
{
createSystemProcedureOrFunction("SYSCS_CHECKPOINT_DATABASE", sysUtilUUID, null, null, 0, 0, RoutineAliasInfo.CONTAINS_SQL, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// void SYSCS_UTIL.SYSCS_FREEZE_DATABASE()
{
createSystemProcedureOrFunction("SYSCS_FREEZE_DATABASE", sysUtilUUID, null, null, 0, 0, RoutineAliasInfo.CONTAINS_SQL, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// void SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE()
{
createSystemProcedureOrFunction("SYSCS_UNFREEZE_DATABASE", sysUtilUUID, null, null, 0, 0, RoutineAliasInfo.CONTAINS_SQL, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// void SYSCS_UTIL.SYSCS_BACKUP_DATABASE(varchar Limits.DB2_VARCHAR_MAXWIDTH)
{
// procedure argument names
String[] arg_names = { "BACKUPDIR" };
// procedure argument types
TypeDescriptor[] arg_types = { DataTypeDescriptor.getCatalogType(Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH) };
createSystemProcedureOrFunction("SYSCS_BACKUP_DATABASE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// void SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(
// varchar Limits.DB2_VARCHAR_MAXWIDTH, smallint)
{
// procedure argument names
String[] arg_names = { "BACKUPDIR", "DELETE_ARCHIVED_LOG_FILES" };
// procedure argument types
TypeDescriptor[] arg_types = { DataTypeDescriptor.getCatalogType(Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH), TypeDescriptor.SMALLINT };
createSystemProcedureOrFunction("SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// void SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE(smallint)
{
// procedure argument names
String[] arg_names = { "DELETE_ARCHIVED_LOG_FILES" };
// procedure argument types
TypeDescriptor[] arg_types = { TypeDescriptor.SMALLINT };
createSystemProcedureOrFunction("SYSCS_DISABLE_LOG_ARCHIVE_MODE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// void SYSCS_UTIL.SYSCS_SET_RUNTIMESTTISTICS(smallint)
{
// procedure argument names
String[] arg_names = { "ENABLE" };
// procedure argument types
TypeDescriptor[] arg_types = { TypeDescriptor.SMALLINT };
createSystemProcedureOrFunction("SYSCS_SET_RUNTIMESTATISTICS", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.CONTAINS_SQL, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// void SYSCS_UTIL.SYSCS_SET_STATISTICS_TIMING(smallint)
{
// procedure argument names
String[] arg_names = { "ENABLE" };
// procedure argument types
TypeDescriptor[] arg_types = { TypeDescriptor.SMALLINT };
createSystemProcedureOrFunction("SYSCS_SET_STATISTICS_TIMING", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.CONTAINS_SQL, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// SYSCS_UTIL functions
//
// TODO (mikem) -
// the following need to be functions when that is supported.
// until then calling them will not work.
// VARCHAR(Limits.DB2_VARCHAR_MAXWIDTH)
// SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY(varchar(128))
{
// procedure argument names
String[] arg_names = { "KEY" };
// procedure argument types
TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER };
createSystemProcedureOrFunction("SYSCS_GET_DATABASE_PROPERTY", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, false, false, DataTypeDescriptor.getCatalogType(Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH), newlyCreatedRoutines, tc);
}
// SMALLINT SYSCS_UTIL.SYSCS_CHECK_TABLE(varchar(128), varchar(128))
{
// procedure argument names
String[] arg_names = { "SCHEMANAME", "TABLENAME" };
// procedure argument types
TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER };
createSystemProcedureOrFunction("SYSCS_CHECK_TABLE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, false, false, TypeDescriptor.INTEGER, newlyCreatedRoutines, tc);
}
// CLOB SYSCS_UTIL.SYSCS_GET_RUNTIMESTATISTICS()
{
createSystemProcedureOrFunction("SYSCS_GET_RUNTIMESTATISTICS", sysUtilUUID, null, null, 0, 0, RoutineAliasInfo.CONTAINS_SQL, false, false, DataTypeDescriptor.getCatalogType(Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH), newlyCreatedRoutines, /*
TODO - mikem, wants to be a CLOB, but don't know how to do
that yet. Testing it with varchar for now.
DataTypeDescriptor.getCatalogType(
Types.CLOB, Limits.DB2_LOB_MAXWIDTH),
*/
tc);
}
/*
** SQLJ routine.
*/
UUID sqlJUUID = getSchemaDescriptor(SchemaDescriptor.STD_SQLJ_SCHEMA_NAME, tc, true).getUUID();
// SQLJ.INSTALL_JAR(URL VARCHAR(??), JAR VARCHAR(128), DEPLOY INT)
{
String[] arg_names = { "URL", "JAR", "DEPLOY" };
TypeDescriptor[] arg_types = { DataTypeDescriptor.getCatalogType(Types.VARCHAR, 256), CATALOG_TYPE_SYSTEM_IDENTIFIER, TypeDescriptor.INTEGER };
createSystemProcedureOrFunction("INSTALL_JAR", sqlJUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// SQLJ.REPLACE_JAR(URL VARCHAR(??), JAR VARCHAR(128))
{
String[] arg_names = { "URL", "JAR" };
TypeDescriptor[] arg_types = { DataTypeDescriptor.getCatalogType(Types.VARCHAR, 256), CATALOG_TYPE_SYSTEM_IDENTIFIER };
createSystemProcedureOrFunction("REPLACE_JAR", sqlJUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// SQLJ.REMOVE_JAR(JAR VARCHAR(128), UNDEPLOY INT)
{
String[] arg_names = { "JAR", "UNDEPLOY" };
TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, TypeDescriptor.INTEGER };
createSystemProcedureOrFunction("REMOVE_JAR", sqlJUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
/* SYSCS_EXPORT_TABLE (IN SCHEMANAME VARCHAR(128),
* IN TABLENAME VARCHAR(128), IN FILENAME VARCHAR(32672) ,
* IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1) ,
* IN CODESET VARCHAR(128))
*/
{
// procedure argument names
String[] arg_names = { "schemaName", "tableName", "fileName", " columnDelimiter", "characterDelimiter", "codeset" };
// procedure argument types
TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER, varchar32672Type, DataTypeDescriptor.getCatalogType(Types.CHAR, 1), DataTypeDescriptor.getCatalogType(Types.CHAR, 1), CATALOG_TYPE_SYSTEM_IDENTIFIER };
createSystemProcedureOrFunction("SYSCS_EXPORT_TABLE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
/* SYSCS_EXPORT_QUERY (IN SELECTSTATEMENT VARCHAR(32672),
* IN FILENAME VARCHAR(32672) ,
* IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1) ,
* IN CODESET VARCHAR(128))
*/
{
// procedure argument names
String[] arg_names = { "selectStatement", "fileName", " columnDelimiter", "characterDelimiter", "codeset" };
// procedure argument types
TypeDescriptor[] arg_types = { varchar32672Type, varchar32672Type, DataTypeDescriptor.getCatalogType(Types.CHAR, 1), DataTypeDescriptor.getCatalogType(Types.CHAR, 1), CATALOG_TYPE_SYSTEM_IDENTIFIER };
createSystemProcedureOrFunction("SYSCS_EXPORT_QUERY", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
/* SYSCS_IMPORT_TABLE(IN SCHEMANAME VARCHAR(128),
* IN TABLENAME VARCHAR(128), IN FILENAME VARCHAR(32672),
* IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1),
* IN CODESET VARCHAR(128) , IN REPLACE SMALLINT)
*/
{
// procedure argument names
String[] arg_names = { "schemaName", "tableName", "fileName", " columnDelimiter", "characterDelimiter", "codeset", "replace" };
// procedure argument types
// procedure argument types
TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER, varchar32672Type, DataTypeDescriptor.getCatalogType(Types.CHAR, 1), DataTypeDescriptor.getCatalogType(Types.CHAR, 1), CATALOG_TYPE_SYSTEM_IDENTIFIER, TypeDescriptor.SMALLINT };
createSystemProcedureOrFunction("SYSCS_IMPORT_TABLE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
/* SYSCS_IMPORT_DATA(IN SCHEMANAME VARCHAR(128),
* IN TABLENAME VARCHAR(128), IN INSERTCOLUMNLIST VARCHAR(32672),
* IN COLUMNINDEXES VARCHAR(32672), IN IN FILENAME VARCHAR(32672),
* IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1),
* IN CODESET VARCHAR(128) , IN REPLACE SMALLINT)
*/
{
// procedure argument names
String[] arg_names = { "schemaName", "tableName", "insertColumnList", "columnIndexes", "fileName", " columnDelimiter", "characterDelimiter", "codeset", "replace" };
// procedure argument types
// procedure argument types
TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER, varchar32672Type, varchar32672Type, varchar32672Type, DataTypeDescriptor.getCatalogType(Types.CHAR, 1), DataTypeDescriptor.getCatalogType(Types.CHAR, 1), CATALOG_TYPE_SYSTEM_IDENTIFIER, TypeDescriptor.SMALLINT };
createSystemProcedureOrFunction("SYSCS_IMPORT_DATA", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
/*
* SYSCS_BULK_INSERT(
* IN SCHEMANAME VARCHAR(128),
* IN TABLENAME VARCHAR(128),
* IN VTINAME VARCHAR(32672),
* IN VTIARG VARCHAR(32672))
*/
{
// procedure argument names
String[] arg_names = { "schemaName", "tableName", "vtiName", "vtiArg" };
// procedure argument types
TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER, varchar32672Type, varchar32672Type };
createSystemProcedureOrFunction("SYSCS_BULK_INSERT", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
// add 10.1 specific system procedures
create_10_1_system_procedures(tc, newlyCreatedRoutines, sysUtilUUID);
// add 10.2 specific system procedures
create_10_2_system_procedures(tc, newlyCreatedRoutines, sysUtilUUID);
// add 10.3 specific system procedures
create_10_3_system_procedures(tc, newlyCreatedRoutines);
// add 10.5 specific system procedures
create_10_5_system_procedures(tc, newlyCreatedRoutines);
// add 10.6 specific system procedures
create_10_6_system_procedures(tc, newlyCreatedRoutines);
// add 10.9 specific system procedures
create_10_9_system_procedures(tc, newlyCreatedRoutines);
// add 10.10 specific system procedures
create_10_10_system_procedures(tc, newlyCreatedRoutines);
// add 10.11 specific system procedures
create_10_11_system_procedures(tc, newlyCreatedRoutines);
// add 10.12 specific system procedures
create_10_12_system_procedures(tc, newlyCreatedRoutines);
// add 10.13 specific system procedures
create_10_13_system_procedures(tc, newlyCreatedRoutines);
}
use of org.apache.derby.catalog.TypeDescriptor in project derby by apache.
the class DataDictionaryImpl method getRoutineList.
/**
* Get the list of routines matching the schema and routine name.
* While we only support a single alias for a given name,namespace just
* return a list of zero or one item.
* If the schema is SYSFUN then do not use the system catalogs,
* but instead look up the routines from the in-memory table driven
* by the contents of SYSFUN_FUNCTIONS.
*/
public java.util.List<AliasDescriptor> getRoutineList(String schemaID, String routineName, char nameSpace) throws StandardException {
// We expect to find just a single function, since we currently
// don't support multiple routines with the same name, but use a
// list to support future extension.
List<AliasDescriptor> list = new ArrayList<AliasDescriptor>(1);
// Special in-memory table lookup for SYSFUN
if (schemaID.equals(SchemaDescriptor.SYSFUN_SCHEMA_UUID) && nameSpace == AliasInfo.ALIAS_NAME_SPACE_FUNCTION_AS_CHAR) {
for (int f = 0; f < DataDictionaryImpl.SYSFUN_FUNCTIONS.length; f++) {
String[] details = DataDictionaryImpl.SYSFUN_FUNCTIONS[f];
String name = details[0];
if (!name.equals(routineName))
continue;
AliasDescriptor ad = sysfunDescriptors[f];
if (ad == null) {
// details[1] Return type
TypeDescriptor rt = DataTypeDescriptor.getBuiltInDataTypeDescriptor(details[1]).getCatalogType();
boolean isDeterministic = Boolean.valueOf(details[SYSFUN_DETERMINISTIC_INDEX]).booleanValue();
boolean hasVarargs = Boolean.valueOf(details[SYSFUN_VARARGS_INDEX]).booleanValue();
// Determine the number of arguments (could be zero).
int paramCount = details.length - SYSFUN_FIRST_PARAMETER_INDEX;
TypeDescriptor[] pt = new TypeDescriptor[paramCount];
String[] paramNames = new String[paramCount];
int[] paramModes = new int[paramCount];
for (int i = 0; i < paramCount; i++) {
pt[i] = DataTypeDescriptor.getBuiltInDataTypeDescriptor(details[SYSFUN_FIRST_PARAMETER_INDEX + i]).getCatalogType();
// Dummy names
paramNames[i] = "P" + (i + 1);
// All parameters must be IN.
paramModes[i] = (ParameterMetaData.parameterModeIn);
}
// details[3] = java method
RoutineAliasInfo ai = new RoutineAliasInfo(details[3], paramCount, paramNames, pt, paramModes, 0, RoutineAliasInfo.PS_JAVA, RoutineAliasInfo.NO_SQL, isDeterministic, hasVarargs, false, /* hasDefinersRights */
false, rt);
// details[2] = class name
ad = new AliasDescriptor(this, uuidFactory.createUUID(), name, uuidFactory.recreateUUID(schemaID), details[2], AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR, AliasInfo.ALIAS_NAME_SPACE_FUNCTION_AS_CHAR, true, ai, null);
sysfunDescriptors[f] = ad;
}
list.add(ad);
}
return list;
}
AliasDescriptor ad = getAliasDescriptor(schemaID, routineName, nameSpace);
if (ad != null) {
list.add(ad);
}
return list;
}
use of org.apache.derby.catalog.TypeDescriptor in project derby by apache.
the class DataDictionaryImpl method create_10_13_system_procedures.
/**
* <p>
* Create system procedures that are part of the SYSCS_UTIL schema, added in version 10.13.
* </p>
*
* @param tc an instance of the Transaction Controller.
* @param newlyCreatedRoutines set of routines we are creating (used to add permissions later on)
*/
void create_10_13_system_procedures(TransactionController tc, HashSet<String> newlyCreatedRoutines) throws StandardException {
UUID sysUtilUUID = getSystemUtilSchemaDescriptor().getUUID();
TypeDescriptor varchar32672Type = DataTypeDescriptor.getCatalogType(Types.VARCHAR, 32672);
/* SYSCS_IMPORT_TABLE_BULK(IN SCHEMANAME VARCHAR(128),
* IN TABLENAME VARCHAR(128), IN FILENAME VARCHAR(32672),
* IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1),
* IN CODESET VARCHAR(128) , IN REPLACE SMALLINT
* IN SKIP SMALLINT )
*/
{
// procedure argument names
String[] arg_names = { "schemaName", "tableName", "fileName", " columnDelimiter", "characterDelimiter", "codeset", "replace", "skip" };
// procedure argument types
TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER, varchar32672Type, DataTypeDescriptor.getCatalogType(Types.CHAR, 1), DataTypeDescriptor.getCatalogType(Types.CHAR, 1), CATALOG_TYPE_SYSTEM_IDENTIFIER, TypeDescriptor.SMALLINT, TypeDescriptor.SMALLINT };
createSystemProcedureOrFunction("SYSCS_IMPORT_TABLE_BULK", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
/* SYSCS_IMPORT_DATA_BULK(IN SCHEMANAME VARCHAR(128),
* IN TABLENAME VARCHAR(128), IN INSERTCOLUMNLIST VARCHAR(32672),
* IN COLUMNINDEXES VARCHAR(32672), IN IN FILENAME VARCHAR(32672),
* IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1),
* IN CODESET VARCHAR(128) , IN REPLACE SMALLINT
* IN SKIP SMALLINT)
*/
{
// procedure argument names
String[] arg_names = { "schemaName", "tableName", "insertColumnList", "columnIndexes", "fileName", " columnDelimiter", "characterDelimiter", "codeset", "replace", "skip" };
// procedure argument types
// procedure argument types
TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER, varchar32672Type, varchar32672Type, varchar32672Type, DataTypeDescriptor.getCatalogType(Types.CHAR, 1), DataTypeDescriptor.getCatalogType(Types.CHAR, 1), CATALOG_TYPE_SYSTEM_IDENTIFIER, TypeDescriptor.SMALLINT, TypeDescriptor.SMALLINT };
createSystemProcedureOrFunction("SYSCS_IMPORT_DATA_BULK", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
}
}
use of org.apache.derby.catalog.TypeDescriptor in project derby by apache.
the class SYSCOLUMNSRowFactory method makeRow.
private ExecRow makeRow(TupleDescriptor td, int columnCount) throws StandardException {
ExecRow row;
String colName = null;
String defaultID = null;
String tabID = null;
Integer colID = null;
TypeDescriptor typeDesc = null;
Object defaultSerializable = null;
long autoincStart = 0;
long autoincInc = 0;
long autoincValue = 0;
boolean autoincCycle = false;
// The SYSCOLUMNS table's autoinc related columns change with different
// values depending on what happened to the autoinc column, ie is the
// user adding an autoincrement column, or is user changing the existing
// autoincrement column to change it's increment value or to change it's
// start value? Following variable is used to keep track of what happened
// to the autoincrement column.
long autoinc_create_or_modify_Start_Increment = -1;
if (td != null) {
ColumnDescriptor column = (ColumnDescriptor) td;
/* Lots of info in the column's type descriptor */
typeDesc = column.getType().getCatalogType();
tabID = column.getReferencingUUID().toString();
colName = column.getColumnName();
colID = column.getPosition();
autoincStart = column.getAutoincStart();
autoincInc = column.getAutoincInc();
autoincValue = column.getAutoincValue();
autoinc_create_or_modify_Start_Increment = column.getAutoinc_create_or_modify_Start_Increment();
autoincCycle = column.getAutoincCycle();
if (column.getDefaultInfo() != null) {
defaultSerializable = column.getDefaultInfo();
} else {
defaultSerializable = column.getDefaultValue();
}
if (column.getDefaultUUID() != null) {
defaultID = column.getDefaultUUID().toString();
}
}
/* Insert info into syscolumns */
/* RESOLVE - It would be nice to require less knowledge about syscolumns
* and have this be more table driven.
* RESOLVE - We'd like to store the DataTypeDescriptor in a column.
*/
/* Build the row to insert */
row = getExecutionFactory().getValueRow(columnCount);
/* 1st column is REFERENCEID (UUID - char(36)) */
row.setColumn(SYSCOLUMNS_REFERENCEID, new SQLChar(tabID));
/* 2nd column is COLUMNNAME (varchar(128)) */
row.setColumn(SYSCOLUMNS_COLUMNNAME, new SQLVarchar(colName));
/* 3rd column is COLUMNNUMBER (int) */
row.setColumn(SYSCOLUMNS_COLUMNNUMBER, new SQLInteger(colID));
/* 4th column is COLUMNDATATYPE */
row.setColumn(SYSCOLUMNS_COLUMNDATATYPE, new UserType(typeDesc));
/* 5th column is COLUMNDEFAULT */
row.setColumn(SYSCOLUMNS_COLUMNDEFAULT, new UserType(defaultSerializable));
/* 6th column is DEFAULTID (UUID - char(36)) */
row.setColumn(SYSCOLUMNS_COLUMNDEFAULTID, new SQLChar(defaultID));
if ((autoinc_create_or_modify_Start_Increment == ColumnDefinitionNode.CREATE_AUTOINCREMENT) || (autoinc_create_or_modify_Start_Increment == ColumnDefinitionNode.MODIFY_AUTOINCREMENT_INC_VALUE) || (autoinc_create_or_modify_Start_Increment == ColumnDefinitionNode.MODIFY_AUTOINCREMENT_ALWAYS_VS_DEFAULT)) {
// user is adding an autoinc column
// or is changing the increment value of autoinc column
// or is changing an autoinc column between ALWAYS and DEFAULT.
// This code also gets run when ALTER TABLE DROP COLUMN
// is used to drop a column other than the autoinc
// column, and the autoinc column gets removed from
// SYSCOLUMNS and immediately re-added with a different
// column position (to account for the dropped column).
// In this case, the autoincValue may have a
// different value than the autoincStart.
row.setColumn(SYSCOLUMNS_AUTOINCREMENTVALUE, new SQLLongint(autoincValue));
row.setColumn(SYSCOLUMNS_AUTOINCREMENTSTART, new SQLLongint(autoincStart));
row.setColumn(SYSCOLUMNS_AUTOINCREMENTINC, new SQLLongint(autoincInc));
if (row.nColumns() >= 10) {
// This column is present only if the data dictionary version is
// 10.14 or higher.
row.setColumn(SYSCOLUMNS_AUTOINCREMENTINCCYCLE, new SQLBoolean(autoincCycle));
}
} else if (autoinc_create_or_modify_Start_Increment == ColumnDefinitionNode.MODIFY_AUTOINCREMENT_RESTART_VALUE) {
// user asked for restart with a new value, so don't change increment by and original start
// with values in the SYSCOLUMNS table. Just record the RESTART WITH value as the
// next value to be generated in the SYSCOLUMNS table
ColumnDescriptor column = (ColumnDescriptor) td;
row.setColumn(SYSCOLUMNS_AUTOINCREMENTVALUE, new SQLLongint(autoincStart));
row.setColumn(SYSCOLUMNS_AUTOINCREMENTSTART, new SQLLongint(autoincStart));
row.setColumn(SYSCOLUMNS_AUTOINCREMENTINC, new SQLLongint(column.getTableDescriptor().getColumnDescriptor(colName).getAutoincInc()));
if (row.nColumns() >= 10) {
// This column is present only if the data dictionary version is
// 10.14 or higher.
row.setColumn(SYSCOLUMNS_AUTOINCREMENTINCCYCLE, new SQLBoolean(autoincCycle));
}
} else if (autoinc_create_or_modify_Start_Increment == ColumnDefinitionNode.MODIFY_AUTOINCREMENT_CYCLE_VALUE) {
ColumnDescriptor column = (ColumnDescriptor) td;
row.setColumn(SYSCOLUMNS_AUTOINCREMENTVALUE, new SQLLongint(column.getTableDescriptor().getColumnDescriptor(colName).getAutoincValue()));
row.setColumn(SYSCOLUMNS_AUTOINCREMENTSTART, new SQLLongint(column.getTableDescriptor().getColumnDescriptor(colName).getAutoincStart()));
row.setColumn(SYSCOLUMNS_AUTOINCREMENTINC, new SQLLongint(column.getTableDescriptor().getColumnDescriptor(colName).getAutoincInc()));
if (row.nColumns() >= 10) {
// This column is present only if the data dictionary version is
// 10.14 or higher.
row.setColumn(SYSCOLUMNS_AUTOINCREMENTINCCYCLE, new SQLBoolean(autoincCycle));
}
} else {
row.setColumn(SYSCOLUMNS_AUTOINCREMENTVALUE, new SQLLongint());
row.setColumn(SYSCOLUMNS_AUTOINCREMENTSTART, new SQLLongint());
row.setColumn(SYSCOLUMNS_AUTOINCREMENTINC, new SQLLongint());
if (row.nColumns() >= 10) {
// This column is present only if the data dictionary version is
// 10.14 or higher.
row.setColumn(SYSCOLUMNS_AUTOINCREMENTINCCYCLE, new SQLBoolean(autoincCycle));
}
}
return row;
}
Aggregations