diff --git a/src/bin/gs_guc/cluster_guc.conf b/src/bin/gs_guc/cluster_guc.conf index dee2e5922b3649d3836c8cd07038e44471adddfb..b13edb54a2afb54538ae25efddb7894caeea914a 100755 --- a/src/bin/gs_guc/cluster_guc.conf +++ b/src/bin/gs_guc/cluster_guc.conf @@ -145,6 +145,7 @@ constraint_exclusion|enum|partition,on,off,true,false,yes,no,1,0|NULL|NULL| enable_union_all_subquery_orderby|bool|0,0|NULL|NULL| enable_ignore_case_in_dquotes|bool|0,0|NULL|NULL| enable_pltype_name_check|bool|0,0|NULL|NULL| +enable_a_compatible_array|bool|0,0|NULL|NULL| instr_unique_sql_track_type|enum|all,top|NULL|NULL| transform_to_numeric_operators|bool|0,0|NULL|NULL| convert_string_to_digit|bool|0,0|NULL|Please don't modify this parameter which will change the type conversion rule and may lead to unpredictable behavior!| diff --git a/src/common/backend/catalog/builtin_funcs.ini b/src/common/backend/catalog/builtin_funcs.ini index f119e3548f71c8d6fce3f2c50de7c559b19d6a03..720c68bd485453f3ec6578371390057a8b8767ff 100644 --- a/src/common/backend/catalog/builtin_funcs.ini +++ b/src/common/backend/catalog/builtin_funcs.ini @@ -246,6 +246,11 @@ "array_deleteidx", 1, AddBuiltinFunc(_0(6015), _1("array_deleteidx"), _2(2), _3(true), _4(false), _5(array_deleteidx), _6(2277), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(2, 2277, 23), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("array_deleteidx"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false)) ), + AddFuncGroup( + "array_deleteidx_db_a", 2, + AddBuiltinFunc(_0(8890), _1("array_deleteidx_db_a"), _2(2), _3(true), _4(false), _5(array_deleteidx_db_a), _6(2277), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(2, 2277, 23), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("array_deleteidx_db_a"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(false), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)), + AddBuiltinFunc(_0(8891), _1("array_multi_deleteidx_db_a"), _2(3), _3(true), _4(false), _5(array_multi_deleteidx_db_a), _6(2277), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(3, 2277, 23, 23), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("array_multi_deleteidx_db_a"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(false), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) + ), AddFuncGroup( "array_dims", 1, AddBuiltinFunc(_0(747), _1("array_dims"), _2(1), _3(true), _4(false), _5(array_dims), _6(25), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 2277), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("array_dims"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("array dimensions"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) @@ -303,6 +308,11 @@ "array_integer_deleteidx", 1, AddBuiltinFunc(_0(7887), _1("array_integer_deleteidx"), _2(2), _3(true), _4(false), _5(array_integer_deleteidx), _6(2277), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(2, 2277, 23), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("array_integer_deleteidx"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) ), + AddFuncGroup( + "array_integer_deleteidx_db_a", 2, + AddBuiltinFunc(_0(8892), _1("array_integer_deleteidx_db_a"), _2(2), _3(true), _4(false), _5(array_integer_deleteidx_db_a), _6(2277), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(2, 2277, 23), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("array_integer_deleteidx_db_a"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(false), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)), + AddBuiltinFunc(_0(8893), _1("array_integer_multi_deleteidx_db_a"), _2(3), _3(true), _4(false), _5(array_integer_multi_deleteidx_db_a), _6(2277), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(3, 2277, 23, 23), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("array_integer_multi_deleteidx_db_a"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(false), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) + ), AddFuncGroup( "array_integer_exists", 1, AddBuiltinFunc(_0(7888), _1("array_integer_exists"), _2(2), _3(false), _4(false), _5(array_integer_exists), _6(16), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(2, 2277, 23), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("array_integer_exists"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) @@ -429,6 +439,11 @@ "array_varchar_deleteidx", 1, AddBuiltinFunc(_0(7886), _1("array_varchar_deleteidx"), _2(2), _3(true), _4(false), _5(array_varchar_deleteidx), _6(2277), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(2, 2277, 1043), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("array_varchar_deleteidx"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) ), + AddFuncGroup( + "array_varchar_deleteidx_db_a", 2, + AddBuiltinFunc(_0(8894), _1("array_varchar_deleteidx_db_a"), _2(2), _3(true), _4(false), _5(array_varchar_deleteidx_db_a), _6(2277), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(2, 2277, 1043), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("array_varchar_deleteidx_db_a"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(false), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)), + AddBuiltinFunc(_0(8895), _1("array_varchar_multi_deleteidx_db_a"), _2(2), _3(true), _4(false), _5(array_varchar_multi_deleteidx_db_a), _6(2277), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(3, 2277, 1043, 1043), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("array_varchar_multi_deleteidx_db_a"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(false), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) + ), AddFuncGroup( "array_varchar_exists", 1, AddBuiltinFunc(_0(7882), _1("array_varchar_exists"), _2(2), _3(false), _4(false), _5(array_varchar_exists), _6(16), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(2, 2277, 1043), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("array_varchar_exists"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) diff --git a/src/common/backend/utils/adt/arrayfuncs.cpp b/src/common/backend/utils/adt/arrayfuncs.cpp index d6bcdf3e3bf100eb5fe204b32c2f09fdf5bf5961..dba6342e9bcbddf051824e59901e8387dd3f49b7 100644 --- a/src/common/backend/utils/adt/arrayfuncs.cpp +++ b/src/common/backend/utils/adt/arrayfuncs.cpp @@ -97,6 +97,7 @@ static ArrayType* create_array_envelope(int ndims, int* dimv, const int* lbv, in static ArrayType* array_fill_internal( ArrayType* dims, ArrayType* lbs, Datum value, bool isnull, Oid elmtype, FunctionCallInfo fcinfo); static ArrayType* array_deleteidx_internal(ArrayType *v, int delIndex); +static ArrayType* array_deleteidx_internal_db_a(ArrayType *v, int delIndex1, int delIndex2, bool multi_args); static void checkEnv(); /* @@ -1791,7 +1792,7 @@ Datum array_varchar_exists(PG_FUNCTION_ARGS) if (u_sess->SPI_cxt.cur_tableof_index == NULL || u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array_varchar_exists must be call in procedure"))); + errmsg("array_varchar_exists cannot be executed when tableOfIndex is not initialised."))); } /* transfer varchar format */ @@ -1826,7 +1827,7 @@ Datum array_integer_exists(PG_FUNCTION_ARGS) if (u_sess->SPI_cxt.cur_tableof_index == NULL || u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array_integer_exists must be call in procedure"))); + errmsg("array_integer_exists cannot be executed when tableOfIndex is not initialised."))); } bool result = array_index_exists_internal(v, @@ -1972,7 +1973,7 @@ Datum array_varchar_next(PG_FUNCTION_ARGS) if (u_sess->SPI_cxt.cur_tableof_index == NULL || u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array_varchar_next must be call in procedure"))); + errmsg("array_varchar_next cannot be executed when tableOfIndex is not initialised."))); } /* transfer varchar format */ @@ -2023,7 +2024,7 @@ Datum array_varchar_prior(PG_FUNCTION_ARGS) if (u_sess->SPI_cxt.cur_tableof_index == NULL || u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array_varchar_prior must be call in procedure"))); + errmsg("array_varchar_prior cannot be executed when tableOfIndex is not initialised."))); } /* transfer varchar format */ bool isTran = false; @@ -2069,7 +2070,7 @@ Datum array_varchar_first(PG_FUNCTION_ARGS) if (u_sess->SPI_cxt.cur_tableof_index == NULL || u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array_varchar_first must be call in procedure"))); + errmsg("array_varchar_first cannot be executed when tableOfIndex is not initialised."))); } /* turn varchar index */ HTAB* table_index = u_sess->SPI_cxt.cur_tableof_index->tableOfIndex; @@ -2117,7 +2118,7 @@ Datum array_integer_next(PG_FUNCTION_ARGS) if (u_sess->SPI_cxt.cur_tableof_index == NULL || u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array_integer_next must be call in procedure"))); + errmsg("array_integer_next cannot be executed when tableOfIndex is not initialised."))); } /* turn integer index */ HTAB* table_index = u_sess->SPI_cxt.cur_tableof_index->tableOfIndex; @@ -2175,7 +2176,7 @@ Datum array_integer_prior(PG_FUNCTION_ARGS) if (u_sess->SPI_cxt.cur_tableof_index == NULL || u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array_integer_prior must be call in procedure"))); + errmsg("array_integer_prior cannot be executed when tableOfIndex is not initialised."))); } /* turn varchar index */ HTAB* table_index = u_sess->SPI_cxt.cur_tableof_index->tableOfIndex; @@ -2229,7 +2230,7 @@ Datum array_integer_first(PG_FUNCTION_ARGS) if (u_sess->SPI_cxt.cur_tableof_index == NULL || u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array_integer_first must be call in procedure"))); + errmsg("array_integer_first cannot be executed when tableOfIndex is not initialised."))); } HTAB* table_index = u_sess->SPI_cxt.cur_tableof_index->tableOfIndex; @@ -2274,7 +2275,7 @@ Datum array_integer_last(PG_FUNCTION_ARGS) if (u_sess->SPI_cxt.cur_tableof_index == NULL || u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array_integer_last must be call in procedure"))); + errmsg("array_integer_last cannot be executed when tableOfIndex is not initialised."))); } HTAB* table_index = u_sess->SPI_cxt.cur_tableof_index->tableOfIndex; @@ -2300,7 +2301,7 @@ Datum array_varchar_last(PG_FUNCTION_ARGS) if (u_sess->SPI_cxt.cur_tableof_index == NULL || u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array_varchar_last must be call in procedure"))); + errmsg("array_varchar_last cannot be executed when tableOfIndex is not initialised."))); } /* turn varchar index */ HTAB* table_index = u_sess->SPI_cxt.cur_tableof_index->tableOfIndex; @@ -2312,6 +2313,18 @@ Datum array_varchar_last(PG_FUNCTION_ARGS) } } +void del_array_idx_in_hash(HTAB* hashp, int delIdx) +{ + HASH_SEQ_STATUS status; + hash_seq_init(&status, hashp); + TableOfIndexEntry* entry; + while (entry = ((TableOfIndexEntry*)hash_seq_search(&status))) { + if (delIdx > 0 && entry->index > delIdx) { + entry->index = entry->index - 1; + } + } +} + static ArrayType* array_index_delete_internal(ArrayType* v, HTAB* table_index, Oid tableOfIndexType, Datum index_datum) { TableOfIndexKey key; @@ -2326,7 +2339,7 @@ static ArrayType* array_index_delete_internal(ArrayType* v, HTAB* table_index, O ArrayType* array = array_deleteidx_internal(v, index); bool found = false; (void)hash_search(table_index, (const void*)&key, HASH_REMOVE, &found); - + del_array_idx_in_hash(table_index, index); /* for nest table, need delete inner vars */ if (var != NULL && var->tableOfIndex != NULL) { HASH_SEQ_STATUS hashSeq; @@ -2341,6 +2354,60 @@ static ArrayType* array_index_delete_internal(ArrayType* v, HTAB* table_index, O return array; } +static ArrayType* array_index_delete_internal_db_a(ArrayType* v, HTAB* table_index, Oid tableOfIndexType, Datum index_datum, Datum index_datum2, bool multi_args) +{ + TableOfIndexKey key; + key.exprtypeid = tableOfIndexType; + key.exprdatum = index_datum; + TableOfIndexKey key2; + key2.exprtypeid = tableOfIndexType; + key2.exprdatum = index_datum2; + PLpgSQL_var* var = NULL; + PLpgSQL_var* var2 = NULL; + ArrayType* array = NULL; + bool found = false; + int index = 0; + int index2 = 0; + index = getTableOfIndexByDatumValue(key, table_index, &var); + if (index < 0) { + return v; + } + if (multi_args) { + index2 = getTableOfIndexByDatumValue(key2, table_index, &var2); + if (index2 < 0 || index2 < index) { + return v; + } + if (tableOfIndexType == VARCHAROID) { + array = array_deleteidx_internal_db_a(v, index, -1, false); + array = array_deleteidx_internal_db_a(v, index2, -1, false); + } else { + array = array_deleteidx_internal_db_a(v, index, index2, true); + } + } else { + array = array_deleteidx_internal_db_a(v, index, -1, false); + } + + (void)hash_search(table_index, (const void*)&key, HASH_REMOVE, &found); + + /* for nest table, need delete inner vars */ + if (var != NULL && var->tableOfIndex != NULL) { + HASH_SEQ_STATUS hashSeq; + hash_seq_init(&hashSeq, var->tableOfIndex); + TableOfIndexEntry* srcEntry = NULL; + while ((srcEntry = (TableOfIndexEntry*)hash_seq_search(&hashSeq)) != NULL) { + var->value = (Datum)array_index_delete_internal_db_a( + DatumGetArrayTypeP(var->value), + var->tableOfIndex, + var->tableOfIndexType, + srcEntry->key.exprdatum, + NULL, + false); + } + } + + return array; +} + Datum array_integer_deleteidx(PG_FUNCTION_ARGS) { checkEnv(); @@ -2357,7 +2424,7 @@ Datum array_integer_deleteidx(PG_FUNCTION_ARGS) if (u_sess->SPI_cxt.cur_tableof_index == NULL || u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array_integer_deleteidx must be call in procedure"))); + errmsg("array_integer_deleteidx cannot be executed when tableOfIndex is not initialised."))); } ArrayType* array = array_index_delete_internal(v, u_sess->SPI_cxt.cur_tableof_index->tableOfIndex, @@ -2366,6 +2433,53 @@ Datum array_integer_deleteidx(PG_FUNCTION_ARGS) PG_RETURN_ARRAYTYPE_P(array); } +static ArrayType* array_integer_deleteidx_db_a_inner(ArrayType* v, Datum index_datum, Datum index_datum2, bool is_multi) +{ + if (u_sess->SPI_cxt.cur_tableof_index == NULL || + u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("array_integer_multi_deleteidx_db_a cannot be executed when tableOfIndex is not initialised."))); + } + + ArrayType* array = array_index_delete_internal_db_a(v, + u_sess->SPI_cxt.cur_tableof_index->tableOfIndex, + u_sess->SPI_cxt.cur_tableof_index->tableOfIndexType, + index_datum, index_datum2, is_multi); + return array; +} + +Datum array_integer_deleteidx_db_a(PG_FUNCTION_ARGS) +{ + checkEnv(); + if (PG_ARGISNULL(0)) { + PG_RETURN_NULL(); + } + ArrayType* v = PG_GETARG_ARRAYTYPE_P(0); + /* Sanity check: does it look like an array at all */ + if (ARR_NDIM(v) <= 0 || ARR_NDIM(v) > MAXDIM) { + PG_RETURN_ARRAYTYPE_P(v); + } + Datum index_datum = PG_GETARG_DATUM(1); + ArrayType* array = array_integer_deleteidx_db_a_inner(v, index_datum, (Datum)0, false); + PG_RETURN_ARRAYTYPE_P(array); +} + +Datum array_integer_multi_deleteidx_db_a(PG_FUNCTION_ARGS) +{ + checkEnv(); + if (PG_ARGISNULL(0)) { + PG_RETURN_NULL(); + } + ArrayType* v = PG_GETARG_ARRAYTYPE_P(0); + /* Sanity check: does it look like an array at all */ + if (ARR_NDIM(v) <= 0 || ARR_NDIM(v) > MAXDIM) { + PG_RETURN_ARRAYTYPE_P(v); + } + Datum index_datum = PG_GETARG_DATUM(1); + Datum index_datum2 = PG_GETARG_DATUM(2); + ArrayType* array = array_integer_deleteidx_db_a_inner(v, index_datum, index_datum2, true); + PG_RETURN_ARRAYTYPE_P(array); +} Datum array_varchar_deleteidx(PG_FUNCTION_ARGS) { @@ -2383,7 +2497,7 @@ Datum array_varchar_deleteidx(PG_FUNCTION_ARGS) if (u_sess->SPI_cxt.cur_tableof_index == NULL || u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array_varchar_deleteidx must be call in procedure"))); + errmsg("array_varchar_deleteidx cannot be executed when tableOfIndex is not initialised."))); } /* transfer varchar format */ bool isTran = false; @@ -2401,6 +2515,71 @@ Datum array_varchar_deleteidx(PG_FUNCTION_ARGS) PG_RETURN_ARRAYTYPE_P(array); } +static ArrayType* array_varchar_deleteidx_db_a_inner(ArrayType* v, Datum index_datum, Datum index_datum2, bool is_multi) +{ + bool isTran1 = false; + bool isTran2 = false; + + if (u_sess->SPI_cxt.cur_tableof_index == NULL || + u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("array_varchar_deleteidx_db_a cannot be executed when tableOfIndex is not initialised."))); + } + /* transfer varchar format */ + if (VARATT_IS_1B(index_datum)) { + index_datum = transVaratt1BTo4B(index_datum); + isTran1 = true; + } + if (is_multi && VARATT_IS_1B(index_datum2)) { + index_datum2 = transVaratt1BTo4B(index_datum2); + isTran2 = true; + } + ArrayType* array = array_index_delete_internal_db_a(v, + u_sess->SPI_cxt.cur_tableof_index->tableOfIndex, + u_sess->SPI_cxt.cur_tableof_index->tableOfIndexType, + index_datum, index_datum2, is_multi); + if (isTran1) { + pfree(DatumGetPointer(index_datum)); + } + if (isTran2) { + pfree(DatumGetPointer(index_datum2)); + } + return array; +} + +Datum array_varchar_deleteidx_db_a(PG_FUNCTION_ARGS) +{ + checkEnv(); + if (PG_ARGISNULL(0)) { + PG_RETURN_NULL(); + } + ArrayType* v = PG_GETARG_ARRAYTYPE_P(0); + /* Sanity check: does it look like an array at all */ + if (ARR_NDIM(v) <= 0 || ARR_NDIM(v) > MAXDIM) { + PG_RETURN_ARRAYTYPE_P(v); + } + Datum index_datum = PG_GETARG_DATUM(1); + ArrayType* array = array_varchar_deleteidx_db_a_inner(v, index_datum, (Datum)0, false); + PG_RETURN_ARRAYTYPE_P(array); +} + +Datum array_varchar_multi_deleteidx_db_a(PG_FUNCTION_ARGS) +{ + checkEnv(); + if (PG_ARGISNULL(0)) { + PG_RETURN_NULL(); + } + ArrayType* v = PG_GETARG_ARRAYTYPE_P(0); + /* Sanity check: does it look like an array at all */ + if (ARR_NDIM(v) <= 0 || ARR_NDIM(v) > MAXDIM) { + PG_RETURN_ARRAYTYPE_P(v); + } + Datum index_datum = PG_GETARG_DATUM(1); + Datum index_datum2 = PG_GETARG_DATUM(2); + ArrayType* array = array_varchar_deleteidx_db_a_inner(v, index_datum, index_datum2, true); + PG_RETURN_ARRAYTYPE_P(array); +} + /* * array_prior : * returns previous index of current index @@ -2479,6 +2658,44 @@ Datum array_extendnull(PG_FUNCTION_ARGS) PG_RETURN_ARRAYTYPE_P(array); } +static ArrayType* array_deleteidx_internal_db_a(ArrayType *v, int delIndex1, int delIndex2, bool multi_args) +{ + Oid element_type; + Datum newelem = (Datum)0; + int16 typlen; + bool typbyval = false; + char typalign; + int *dimv = NULL; + int *lb = NULL; + int lower; + int upper; + int length; + int i = 0; + int drop = 0; + + if (ARR_NDIM(v) <= 0 || ARR_NDIM(v) > MAXDIM) { + return v; + } + + dimv = ARR_DIMS(v); + length = dimv[0]; + lb = ARR_LBOUND(v); + lower = lb[0]; + upper = lower + length - 1; + + element_type = ARR_ELEMTYPE(v); + get_typlenbyvalalign(element_type, &typlen, &typbyval, &typalign); + + for (i = lower; i <= upper; i++) { + bool isDelIdx = multi_args ? (i >= delIndex1 && i <= delIndex2) : i == delIndex1; + if (isDelIdx) { + drop = i; + v = array_set(v, 1, &drop, newelem, true, -1, typlen, typbyval, typalign); + } + } + return v; +} + static ArrayType* array_deleteidx_internal(ArrayType *v, int delIndex) { ArrayType *array = v; @@ -2566,6 +2783,25 @@ Datum array_delete(PG_FUNCTION_ARGS) PG_RETURN_ARRAYTYPE_P(array); } +Datum array_deleteidx_db_a(PG_FUNCTION_ARGS) +{ + ArrayType* v = PG_GETARG_ARRAYTYPE_P(0); + int delIndex = PG_GETARG_INT32(1); + ArrayType* array = array_deleteidx_internal_db_a(v, delIndex, -1, false); + + PG_RETURN_ARRAYTYPE_P(array); +} + +Datum array_multi_deleteidx_db_a(PG_FUNCTION_ARGS) +{ + ArrayType* v = PG_GETARG_ARRAYTYPE_P(0); + int delIndex1 = PG_GETARG_INT32(1); + int delIndex2 = PG_GETARG_INT32(2); + ArrayType* array = array_deleteidx_internal_db_a(v, delIndex1, delIndex2, true); + + PG_RETURN_ARRAYTYPE_P(array); +} + static void deleteTableOfIndexElement(HTAB* tableOfIndex) { if (tableOfIndex == NULL) { @@ -2591,7 +2827,7 @@ Datum array_indexby_delete(PG_FUNCTION_ARGS) if (u_sess->SPI_cxt.cur_tableof_index == NULL || u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array_indexby_delete must be call in procedure"))); + errmsg("array_indexby_delete cannot be executed when tableOfIndex is not initialised."))); } deleteTableOfIndexElement(u_sess->SPI_cxt.cur_tableof_index->tableOfIndex); diff --git a/src/common/backend/utils/init/globals.cpp b/src/common/backend/utils/init/globals.cpp index 57daef93064b577a6070aff6f54a211e0bd0e153..99d1a880d843bf2e4a12c6b2a10d2f3d637004c8 100644 --- a/src/common/backend/utils/init/globals.cpp +++ b/src/common/backend/utils/init/globals.cpp @@ -77,7 +77,7 @@ bool will_shutdown = false; * ********************************************/ -const uint32 GRAND_VERSION_NUM = 93044; +const uint32 GRAND_VERSION_NUM = 93045; /******************************************** * 2.VERSION NUM FOR EACH FEATURE diff --git a/src/common/backend/utils/misc/guc/guc_sql.cpp b/src/common/backend/utils/misc/guc/guc_sql.cpp index b470c38d83a1d667f7f0e557269bf3c3c8b47341..6ec48f2433c669bd791e74f52795fbb79f12a6a0 100755 --- a/src/common/backend/utils/misc/guc/guc_sql.cpp +++ b/src/common/backend/utils/misc/guc/guc_sql.cpp @@ -1844,6 +1844,17 @@ static void InitSqlConfigureNamesBool() NULL, NULL, NULL}, + {{"enable_a_compatible_array", + PGC_USERSET, + NODE_ALL, + QUERY_TUNING_METHOD, + gettext_noop("Enable Compatible array with A database."), + NULL}, + &u_sess->attr.attr_sql.enable_a_compatible_array, + false, + NULL, + NULL, + NULL}, {{"enable_streaming", PGC_POSTMASTER, NODE_DISTRIBUTE, diff --git a/src/common/backend/utils/misc/postgresql_single.conf.sample b/src/common/backend/utils/misc/postgresql_single.conf.sample index eb4031afebc734b678bbc8d2dc3af2175e9c28c8..a5ece13488c9d93e03793eac7a5eb2ea37ef21d5 100644 --- a/src/common/backend/utils/misc/postgresql_single.conf.sample +++ b/src/common/backend/utils/misc/postgresql_single.conf.sample @@ -830,6 +830,7 @@ job_queue_processes = 10 # Number of concurrent jobs, optional: [0..1000] #enable_cachedplan_mgr=on #enable_ignore_case_in_dquotes=off #enable_pltype_name_check=off +#enable_a_compatible_array=off #------------------------------------------------------------------------------ # SHARED STORAGE OPTIONS #------------------------------------------------------------------------------ diff --git a/src/common/pl/plpgsql/src/gram.y b/src/common/pl/plpgsql/src/gram.y index d88a71f6996e57523f95e7ceb567907ef60f6ec5..3dc9b6ef67f221ae9ffb3cd0bf6015d4c9833efb 100755 --- a/src/common/pl/plpgsql/src/gram.y +++ b/src/common/pl/plpgsql/src/gram.y @@ -291,6 +291,10 @@ static void yylex_object_type_selfparam(char** fieldnames, static void CheckParallelCursorOpr(PLpgSQL_stmt_fetch* fetch); static void HandleSubprogram(); static void HandleBlockLevel(); +static void append_array_deleteidx_num(StringInfo sqlBuf, List* idents, int tok, Oid indexType); +static void append_array_deleteidx(StringInfo sqlBuf); +static void append_array_integer_delete(StringInfo sqlBuf); +static void append_array_varchar_delete(StringInfo sqlBuf); %} %expect 0 @@ -5891,130 +5895,14 @@ stmt_execsql : K_ALTER $$ = NULL; yyerror("syntax error"); } else { - if (tok1 == '-') { - if (indexType == VARCHAROID) { - yyerror("syntax error"); - } - - int tok3 = yylex(); - if (tok3 != ICONST && tok3 != T_WORD && tok3 != T_DATUM) { - yyerror("syntax error"); - } - - if (ICONST == tok3) { - if (indexType == INT4OID) { - appendStringInfo(&sqlBuf, "array_integer_delete("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "\'-%d\')", yylval.ival); - } else { - appendStringInfo(&sqlBuf, "array_deleteidx("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "-%d)", yylval.ival); - } - } else if (T_WORD == tok3) { - if (indexType == INT4OID) { - appendStringInfo(&sqlBuf, "array_integer_delete("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "\'-%s\')", yylval.word.ident); - } else { - appendStringInfo(&sqlBuf, "array_deleteidx("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "-%s)", yylval.word.ident); - } - - } else { - char *datName = NameOfDatum(&yylval.wdatum); - if (indexType == INT4OID) { - appendStringInfo(&sqlBuf, "array_integer_delete("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "\'-%s\')", datName); - } else { - appendStringInfo(&sqlBuf, "array_deleteidx("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "-%s)", datName); - } - - pfree_ext(datName); - } - } else { - if (ICONST == tok1) { - if (indexType == VARCHAROID) { - appendStringInfo(&sqlBuf, "array_varchar_delete("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "\'%d\')", yylval.ival); - } else if (indexType == INT4OID) { - appendStringInfo(&sqlBuf, "array_integer_delete("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "\'%d\')", yylval.ival); - } else { - appendStringInfo(&sqlBuf, "array_deleteidx("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "%d)", yylval.ival); - } - } else if (SCONST == tok1) { - if (indexType == VARCHAROID) { - appendStringInfo(&sqlBuf, "array_varchar_delete("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "\'%s\')", yylval.str); - } else if (indexType == INT4OID) { - appendStringInfo(&sqlBuf, "array_integer_delete("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "\'%s\')", yylval.str); - } else { - appendStringInfo(&sqlBuf, "array_deleteidx("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "%s)", yylval.str); - } - - } else if (T_WORD == tok1) { - if (indexType == VARCHAROID) { - appendStringInfo(&sqlBuf, "array_varchar_delete("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "\'%s\')", yylval.word.ident); - } else if (indexType == INT4OID) { - appendStringInfo(&sqlBuf, "array_integer_delete("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "\'%s\')", yylval.word.ident); - } else { - appendStringInfo(&sqlBuf, "array_deleteidx("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "%s)", yylval.word.ident); - } - - } else { - char *datName = NameOfDatum(&yylval.wdatum); - if (indexType == VARCHAROID) { - appendStringInfo(&sqlBuf, "array_varchar_delete("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "\'%s\')", datName); - } else if (indexType == INT4OID) { - appendStringInfo(&sqlBuf, "array_integer_delete("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "\'%s\')", datName); - } else { - appendStringInfo(&sqlBuf, "array_deleteidx("); - CastArrayNameToArrayFunc(&sqlBuf, idents); - appendStringInfo(&sqlBuf, "%s)", datName); - } - - pfree_ext(datName); - } - } - - int tok2 = yylex(); - if (tok2 != ')') { + append_array_deleteidx_num(&sqlBuf, idents, tok1, indexType); + int tok3 = yylex(); + if (tok3 != ';') { plpgsql_push_back_token(tok); $$ = NULL; yyerror("syntax error"); } else { - int tok3 = yylex(); - if (tok3 != ';') { - plpgsql_push_back_token(tok); - $$ = NULL; - yyerror("syntax error"); - } else { - $$ = make_callfunc_stmt(sqlBuf.data, @1, false, false, NULL, dno); - } + $$ = make_callfunc_stmt(sqlBuf.data, @1, false, false, NULL, dno); } } } else { @@ -7541,9 +7429,15 @@ make_callfunc_stmt(const char *sqlstart, int location, bool is_assign, bool eate bool multi_func = false; const char *varray_delete = "array_delete(\""; const char *varray_indexby_delete = "array_indexby_delete(\""; - const char *varray_deleteidx = "array_deleteidx(\""; - const char *varray_deletevarchar = "array_varchar_delete(\""; - const char *varray_deleteinteger = "array_integer_delete(\""; + const char *varray_deleteidx = u_sess->attr.attr_sql.sql_compatibility == A_FORMAT && + u_sess->attr.attr_sql.enable_a_compatible_array ? + "array_deleteidx_db_a(\"" : "array_deleteidx(\""; + const char *varray_deletevarchar = u_sess->attr.attr_sql.sql_compatibility == A_FORMAT && + u_sess->attr.attr_sql.enable_a_compatible_array ? + "array_varchar_deleteidx_db_a(\"" : "array_varchar_deleteidx(\""; + const char *varray_deleteinteger = u_sess->attr.attr_sql.sql_compatibility == A_FORMAT && + u_sess->attr.attr_sql.enable_a_compatible_array ? + "array_integer_deleteidx_db_a(\"" : "array_integer_deleteidx(\""; const char *varray_extend= "array_extendnull(\""; const char *varray_trim = "array_trim(\""; @@ -15775,3 +15669,49 @@ static void HandleBlockLevel() { if(u_sess->plsql_cxt.curr_compile_context->plpgsql_curr_compile_package == NULL) u_sess->plsql_cxt.block_level++; } + +static void append_array_deleteidx_num(StringInfo sqlBuf, List* idents, int tok, Oid indexType) { + int loc = yylloc; + int endloc = 0; + if (indexType == VARCHAROID) { + append_array_varchar_delete(sqlBuf); + } else if (indexType == INT4OID) { + append_array_integer_delete(sqlBuf); + } else { + append_array_deleteidx(sqlBuf); + } + CastArrayNameToArrayFunc(sqlBuf, idents); + while (tok != ';') { + tok = yylex(); + endloc = yylloc; + } + plpgsql_append_source_text(sqlBuf, loc, endloc); + plpgsql_push_back_token(tok); +} + +static void append_array_deleteidx(StringInfo sqlBuf) { + if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT && + u_sess->attr.attr_sql.enable_a_compatible_array) { + appendStringInfo(sqlBuf, "array_deleteidx_db_a("); + } else { + appendStringInfo(sqlBuf, "array_deleteidx("); + } +} + +static void append_array_integer_delete(StringInfo sqlBuf) { + if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT && + u_sess->attr.attr_sql.enable_a_compatible_array) { + appendStringInfo(sqlBuf, "array_integer_deleteidx_db_a("); + } else { + appendStringInfo(sqlBuf, "array_integer_deleteidx("); + } +} + +static void append_array_varchar_delete(StringInfo sqlBuf) { + if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT && + u_sess->attr.attr_sql.enable_a_compatible_array) { + appendStringInfo(sqlBuf, "array_varchar_deleteidx_db_a("); + } else { + appendStringInfo(sqlBuf, "array_varchar_deleteidx("); + } +} \ No newline at end of file diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_93_045.sql b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_93_045.sql new file mode 100644 index 0000000000000000000000000000000000000000..8dd12304769d22617dd1137d1c5fcd943988a7b7 --- /dev/null +++ b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_93_045.sql @@ -0,0 +1,6 @@ +DROP FUNCTION IF EXISTS pg_catalog.array_deleteidx_db_a(anyarray, integer) CASCADE; +DROP FUNCTION IF EXISTS pg_catalog.array_deleteidx_db_a(anyarray, integer, integer) CASCADE; +DROP FUNCTION IF EXISTS pg_catalog.array_integer_deleteidx_db_a(anyarray, integer) CASCADE; +DROP FUNCTION IF EXISTS pg_catalog.array_integer_deleteidx_db_a(anyarray, integer, integer) CASCADE; +DROP FUNCTION IF EXISTS pg_catalog.array_varchar_deleteidx_db_a(anyarray, character varying) CASCADE; +DROP FUNCTION IF EXISTS pg_catalog.array_varchar_deleteidx_db_a(anyarray, character varying, character varying) CASCADE; \ No newline at end of file diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_93_045.sql b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_93_045.sql new file mode 100644 index 0000000000000000000000000000000000000000..8dd12304769d22617dd1137d1c5fcd943988a7b7 --- /dev/null +++ b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_93_045.sql @@ -0,0 +1,6 @@ +DROP FUNCTION IF EXISTS pg_catalog.array_deleteidx_db_a(anyarray, integer) CASCADE; +DROP FUNCTION IF EXISTS pg_catalog.array_deleteidx_db_a(anyarray, integer, integer) CASCADE; +DROP FUNCTION IF EXISTS pg_catalog.array_integer_deleteidx_db_a(anyarray, integer) CASCADE; +DROP FUNCTION IF EXISTS pg_catalog.array_integer_deleteidx_db_a(anyarray, integer, integer) CASCADE; +DROP FUNCTION IF EXISTS pg_catalog.array_varchar_deleteidx_db_a(anyarray, character varying) CASCADE; +DROP FUNCTION IF EXISTS pg_catalog.array_varchar_deleteidx_db_a(anyarray, character varying, character varying) CASCADE; \ No newline at end of file diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_93_045.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_93_045.sql new file mode 100644 index 0000000000000000000000000000000000000000..29758df5d14bc13a480e4d007392de475d70fc00 --- /dev/null +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_93_045.sql @@ -0,0 +1,47 @@ +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8890; +CREATE FUNCTION pg_catalog.array_deleteidx_db_a(anyarray, integer) + RETURNS anyarray + LANGUAGE internal + IMMUTABLE STRICT NOT FENCED NOT SHIPPABLE +AS $function$array_deleteidx_db_a$function$; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8891; +CREATE FUNCTION pg_catalog.array_deleteidx_db_a(anyarray, integer, integer) + RETURNS anyarray + LANGUAGE internal + IMMUTABLE STRICT NOT FENCED NOT SHIPPABLE +AS $function$array_multi_deleteidx_db_a$function$; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8892; +CREATE FUNCTION pg_catalog.array_integer_deleteidx_db_a(anyarray, integer) + RETURNS anyarray + LANGUAGE internal + IMMUTABLE STRICT NOT FENCED NOT SHIPPABLE +AS $function$array_integer_deleteidx_db_a$function$; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8893; +CREATE FUNCTION pg_catalog.array_integer_deleteidx_db_a(anyarray, integer, integer) + RETURNS anyarray + LANGUAGE internal + IMMUTABLE STRICT NOT FENCED NOT SHIPPABLE +AS $function$array_integer_multi_deleteidx_db_a$function$; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8894; +CREATE FUNCTION pg_catalog.array_varchar_deleteidx_db_a(anyarray, character varying) + RETURNS anyarray + LANGUAGE internal + IMMUTABLE STRICT NOT FENCED NOT SHIPPABLE +AS $function$array_varchar_deleteidx_db_a$function$; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8895; +CREATE FUNCTION pg_catalog.array_varchar_deleteidx_db_a(anyarray, character varying, character varying) + RETURNS anyarray + LANGUAGE internal + IMMUTABLE STRICT NOT FENCED NOT SHIPPABLE +AS $function$array_varchar_multi_deleteidx_db_a$function$; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0; \ No newline at end of file diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_93_045.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_93_045.sql new file mode 100644 index 0000000000000000000000000000000000000000..29758df5d14bc13a480e4d007392de475d70fc00 --- /dev/null +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_93_045.sql @@ -0,0 +1,47 @@ +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8890; +CREATE FUNCTION pg_catalog.array_deleteidx_db_a(anyarray, integer) + RETURNS anyarray + LANGUAGE internal + IMMUTABLE STRICT NOT FENCED NOT SHIPPABLE +AS $function$array_deleteidx_db_a$function$; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8891; +CREATE FUNCTION pg_catalog.array_deleteidx_db_a(anyarray, integer, integer) + RETURNS anyarray + LANGUAGE internal + IMMUTABLE STRICT NOT FENCED NOT SHIPPABLE +AS $function$array_multi_deleteidx_db_a$function$; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8892; +CREATE FUNCTION pg_catalog.array_integer_deleteidx_db_a(anyarray, integer) + RETURNS anyarray + LANGUAGE internal + IMMUTABLE STRICT NOT FENCED NOT SHIPPABLE +AS $function$array_integer_deleteidx_db_a$function$; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8893; +CREATE FUNCTION pg_catalog.array_integer_deleteidx_db_a(anyarray, integer, integer) + RETURNS anyarray + LANGUAGE internal + IMMUTABLE STRICT NOT FENCED NOT SHIPPABLE +AS $function$array_integer_multi_deleteidx_db_a$function$; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8894; +CREATE FUNCTION pg_catalog.array_varchar_deleteidx_db_a(anyarray, character varying) + RETURNS anyarray + LANGUAGE internal + IMMUTABLE STRICT NOT FENCED NOT SHIPPABLE +AS $function$array_varchar_deleteidx_db_a$function$; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8895; +CREATE FUNCTION pg_catalog.array_varchar_deleteidx_db_a(anyarray, character varying, character varying) + RETURNS anyarray + LANGUAGE internal + IMMUTABLE STRICT NOT FENCED NOT SHIPPABLE +AS $function$array_varchar_multi_deleteidx_db_a$function$; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0; \ No newline at end of file diff --git a/src/include/knl/knl_guc/knl_session_attr_sql.h b/src/include/knl/knl_guc/knl_session_attr_sql.h index bcb9a2a010a2913f1a30bbd59b32950968c616cf..14eb321ff9116b42195588871a1766bbb9b7d020 100644 --- a/src/include/knl/knl_guc/knl_session_attr_sql.h +++ b/src/include/knl/knl_guc/knl_session_attr_sql.h @@ -260,6 +260,7 @@ typedef struct knl_session_attr_sql { char* db4ai_snapshot_version_separator; bool enable_ignore_case_in_dquotes; bool enable_pltype_name_check; + bool enable_a_compatible_array; int pldebugger_timeout; bool partition_page_estimation; bool enable_opfusion_reuse; diff --git a/src/include/utils/array.h b/src/include/utils/array.h index d392f7f4989067f65b035c1c2deaae42315a8677..248675491e2f2f4181076471f2eae04cdb29a57b 100644 --- a/src/include/utils/array.h +++ b/src/include/utils/array.h @@ -200,6 +200,8 @@ extern Datum array_prior(PG_FUNCTION_ARGS); extern Datum array_trim(PG_FUNCTION_ARGS); extern Datum array_delete(PG_FUNCTION_ARGS); extern Datum array_deleteidx(PG_FUNCTION_ARGS); +extern Datum array_multi_deleteidx_db_a(PG_FUNCTION_ARGS); +extern Datum array_deleteidx_db_a(PG_FUNCTION_ARGS); extern Datum array_extendnull(PG_FUNCTION_ARGS); extern Datum array_larger(PG_FUNCTION_ARGS); extern Datum array_smaller(PG_FUNCTION_ARGS); diff --git a/src/test/regress/expected/array_compatible_a.out b/src/test/regress/expected/array_compatible_a.out new file mode 100644 index 0000000000000000000000000000000000000000..c746ee95b6a916b0abe62c5cd0ec37aa578ab8cf --- /dev/null +++ b/src/test/regress/expected/array_compatible_a.out @@ -0,0 +1,1367 @@ +set enable_a_compatible_array = on; +CREATE OR REPLACE TYPE num_type IS TABLE OF NUMBER; +CREATE OR REPLACE TYPE int_type IS TABLE OF INTEGER; +CREATE OR REPLACE TYPE char_type IS TABLE OF VARCHAR(20); +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +DECLARE + TYPE n1 IS varray(20) OF NUMBER; + nt n1 := n1(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +DECLARE + TYPE n1 IS varray(20) OF NUMBER index by integer; + nt n1 := n1(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: syntax error at or near "index" +LINE 1: DECLARE TYPE n1 IS varray(20) OF NUMBER index by integer; + ^ +QUERY: DECLARE TYPE n1 IS varray(20) OF NUMBER index by integer; + nt n1 := n1(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 11 +NOTICE: +NOTICE: +NOTICE: 44 +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 11 +NOTICE: +NOTICE: +NOTICE: 44 +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: +NOTICE: two +NOTICE: three +NOTICE: four +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: one +NOTICE: +NOTICE: +NOTICE: four +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('1'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('2','3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 11 +NOTICE: +NOTICE: +NOTICE: 44 +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('1'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('2','3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 11 +NOTICE: +NOTICE: +NOTICE: 44 +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE('1'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: +NOTICE: two +NOTICE: three +NOTICE: four +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE('2','3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: one +NOTICE: +NOTICE: +NOTICE: four +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + idx int := 1; +BEGIN + nt.DELETE(idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, end_idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 11 +NOTICE: +NOTICE: +NOTICE: 44 +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, 3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 11 +NOTICE: +NOTICE: +NOTICE: 44 +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, '3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 11 +NOTICE: +NOTICE: +NOTICE: 44 +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + idx int := 1; +BEGIN + nt.DELETE(idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, end_idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 11 +NOTICE: +NOTICE: +NOTICE: 44 +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, 3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 11 +NOTICE: +NOTICE: +NOTICE: 44 +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, '3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 11 +NOTICE: +NOTICE: +NOTICE: 44 +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + idx int := 1; +BEGIN + nt.DELETE(idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: +NOTICE: two +NOTICE: three +NOTICE: four +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(3-1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: one +NOTICE: +NOTICE: three +NOTICE: four +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, end_idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: one +NOTICE: +NOTICE: +NOTICE: four +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(3-1, 5-2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: one +NOTICE: +NOTICE: +NOTICE: four +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, 3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: one +NOTICE: +NOTICE: +NOTICE: four +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, '3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: one +NOTICE: +NOTICE: +NOTICE: four +declare + type ta is table of varchar(32) index by integer; + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt(1) := 'red'; + nt(2) := 'orange'; + nt(3) := 'yellow'; + nt(4) := 'green'; + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: red +NOTICE: +NOTICE: yellow +NOTICE: green +declare + type ta is table of varchar(32) index by integer; + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt(1) := 'red'; + nt(2) := 'orange'; + nt(3) := 'yellow'; + nt(4) := 'green'; + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: red +NOTICE: +NOTICE: +NOTICE: green +declare + type ta is table of varchar(32) index by varchar; + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt('1') := 'red'; + nt('2') := 'orange'; + nt('3') := 'yellow'; + nt('4') := 'green'; + nt.DELETE('2'); + raise notice '%',nt('1'); + raise notice '%',nt('2'); + raise notice '%',nt('3'); + raise notice '%',nt('4'); +END; +/ +NOTICE: red +NOTICE: +NOTICE: yellow +NOTICE: green +declare + type ta is table of varchar(32) index by varchar(32); + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt('311') := 'yellow'; + nt('a11') := 'red'; + nt('o2') := 'orange'; + nt('aaa') := 'aadw'; + nt('4aw') := 'green'; + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); + nt.DELETE('311', '4aw'); + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); +END; +/ +NOTICE: yellow +NOTICE: red +NOTICE: orange +NOTICE: aadw +NOTICE: green +NOTICE: +NOTICE: red +NOTICE: orange +NOTICE: aadw +NOTICE: +declare + type ta is table of varchar(32) index by varchar(32); + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt('311') := 'yellow'; + nt('a11') := 'red'; + nt('o2') := 'orange'; + nt('aaa') := 'aadw'; + nt('4aw') := 'green'; + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); + nt.DELETE('311'); + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); +END; +/ +NOTICE: yellow +NOTICE: red +NOTICE: orange +NOTICE: aadw +NOTICE: green +NOTICE: +NOTICE: red +NOTICE: orange +NOTICE: aadw +NOTICE: green +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is varray(20) of NUMBER; + type nest_type is varray(20) of n1; + nt nest_type; + -- nt nest_type := nest_type(num_type(11, 22), num_type(33, 44), num_type(55, 66)); +BEGIN + nt(1):=n1(1,2); + nt(2):=n1(33, 44); + nt(3):=n1(55, 66); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); +END; +/ +call proc1(); +NOTICE: {1,2} +NOTICE: {33,44} +NOTICE: {55,66} +NOTICE: {1,2} +NOTICE: +NOTICE: {55,66} + proc1 +------- + +(1 row) + +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is varray(20) of NUMBER; + type nest_type is varray(20) of n1; + nt nest_type; +BEGIN + nt(1):=n1(1,2); + nt(2):=n1(33, 44); + nt(3):=n1(55, 66); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); +END; +/ +call proc1(); +NOTICE: {1,2} +NOTICE: {33,44} +NOTICE: {55,66} +NOTICE: {1,2} +NOTICE: +NOTICE: {55,66} + proc1 +------- + +(1 row) + +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is table of NUMBER; + type nest_type is table of n1; + nt nest_type; +BEGIN + nt(1):=n1(1,2); + nt(2):=n1(33, 44); + nt(3):=n1(55, 66); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); +END; +/ +call proc1(); +NOTICE: {1,2} +NOTICE: {33,44} +NOTICE: {55,66} +NOTICE: {1,2} +NOTICE: +NOTICE: {55,66} + proc1 +------- + +(1 row) + +set enable_a_compatible_array = off; +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +NOTICE: 55 +DECLARE + TYPE n1 IS varray(20) OF NUMBER; + nt n1 := n1(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +NOTICE: 55 +DECLARE + TYPE n1 IS varray(20) OF NUMBER index by integer; + nt n1 := n1(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: syntax error at or near "index" +LINE 1: DECLARE TYPE n1 IS varray(20) OF NUMBER index by integer; + ^ +QUERY: DECLARE TYPE n1 IS varray(20) OF NUMBER index by integer; + nt n1 := n1(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(numeric[], integer, integer) does not exist +LINE 1: SELECT array_deleteidx("nt", 2,3) + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", 2,3) +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 3 at assignment +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +NOTICE: 55 +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(integer[], integer, integer) does not exist +LINE 1: SELECT array_deleteidx("nt", 2,3) + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", 2,3) +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 3 at assignment +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: two +NOTICE: three +NOTICE: four +NOTICE: five +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(character varying[], integer, integer) does not exist +LINE 1: SELECT array_deleteidx("nt", 2,3) + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", 2,3) +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 3 at assignment +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('1'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +NOTICE: 55 +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('2','3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(numeric[], unknown, unknown) does not exist +LINE 1: SELECT array_deleteidx("nt", '2','3') + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", '2','3') +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 3 at assignment +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('1'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +NOTICE: 55 +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('2','3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(integer[], unknown, unknown) does not exist +LINE 1: SELECT array_deleteidx("nt", '2','3') + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", '2','3') +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 3 at assignment +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE('1'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: two +NOTICE: three +NOTICE: four +NOTICE: five +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE('2','3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(character varying[], unknown, unknown) does not exist +LINE 1: SELECT array_deleteidx("nt", '2','3') + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", '2','3') +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 3 at assignment +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + idx int := 1; +BEGIN + nt.DELETE(idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +NOTICE: 55 +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, end_idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(numeric[], integer, integer) does not exist +LINE 1: SELECT array_deleteidx("nt", start_idx, end_idx) + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", start_idx, end_idx) +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 5 at assignment +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, 3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(numeric[], integer, integer) does not exist +LINE 1: SELECT array_deleteidx("nt", start_idx, 3) + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", start_idx, 3) +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 5 at assignment +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, '3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(numeric[], integer, unknown) does not exist +LINE 1: SELECT array_deleteidx("nt", start_idx, '3') + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", start_idx, '3') +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 5 at assignment +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + idx int := 1; +BEGIN + nt.DELETE(idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: 22 +NOTICE: 33 +NOTICE: 44 +NOTICE: 55 +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, end_idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(integer[], integer, integer) does not exist +LINE 1: SELECT array_deleteidx("nt", start_idx, end_idx) + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", start_idx, end_idx) +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 5 at assignment +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, 3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(integer[], integer, integer) does not exist +LINE 1: SELECT array_deleteidx("nt", start_idx, 3) + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", start_idx, 3) +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 5 at assignment +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, '3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(integer[], integer, unknown) does not exist +LINE 1: SELECT array_deleteidx("nt", start_idx, '3') + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", start_idx, '3') +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 5 at assignment +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + idx int := 1; +BEGIN + nt.DELETE(idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: two +NOTICE: three +NOTICE: four +NOTICE: five +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(3-1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: one +NOTICE: three +NOTICE: four +NOTICE: five +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, end_idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(character varying[], integer, integer) does not exist +LINE 1: SELECT array_deleteidx("nt", start_idx, end_idx) + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", start_idx, end_idx) +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 5 at assignment +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(3-1, 5-2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(character varying[], integer, integer) does not exist +LINE 1: SELECT array_deleteidx("nt", 3-1, 5-2) + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", 3-1, 5-2) +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 3 at assignment +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, 3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(character varying[], integer, integer) does not exist +LINE 1: SELECT array_deleteidx("nt", start_idx, 3) + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", start_idx, 3) +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 5 at assignment +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, '3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_deleteidx(character varying[], integer, unknown) does not exist +LINE 1: SELECT array_deleteidx("nt", start_idx, '3') + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_deleteidx("nt", start_idx, '3') +CONTEXT: referenced column: array_deleteidx +PL/pgSQL function inline_code_block line 5 at assignment +declare + type ta is table of varchar(32) index by integer; + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt(1) := 'red'; + nt(2) := 'orange'; + nt(3) := 'yellow'; + nt(4) := 'green'; + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +NOTICE: red +NOTICE: +NOTICE: yellow +NOTICE: green +declare + type ta is table of varchar(32) index by integer; + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt(1) := 'red'; + nt(2) := 'orange'; + nt(3) := 'yellow'; + nt(4) := 'green'; + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ +ERROR: function array_integer_deleteidx(character varying[], integer, integer) does not exist +LINE 1: SELECT array_integer_deleteidx("nt", 2,3) + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_integer_deleteidx("nt", 2,3) +CONTEXT: referenced column: array_integer_deleteidx +PL/pgSQL function inline_code_block line 9 at assignment +declare + type ta is table of varchar(32) index by varchar; + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt('1') := 'red'; + nt('2') := 'orange'; + nt('3') := 'yellow'; + nt('4') := 'green'; + nt.DELETE('2'); + raise notice '%',nt('1'); + raise notice '%',nt('2'); + raise notice '%',nt('3'); + raise notice '%',nt('4'); +END; +/ +NOTICE: red +NOTICE: +NOTICE: yellow +NOTICE: green +declare + type ta is table of varchar(32) index by varchar(32); + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt('311') := 'yellow'; + nt('a11') := 'red'; + nt('o2') := 'orange'; + nt('aaa') := 'aadw'; + nt('4aw') := 'green'; + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); + nt.DELETE('311', '4aw'); + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); +END; +/ +NOTICE: yellow +NOTICE: red +NOTICE: orange +NOTICE: aadw +NOTICE: green +NOTICE: yellow +NOTICE: red +NOTICE: orange +NOTICE: aadw +NOTICE: green +ERROR: function array_varchar_deleteidx(character varying[], unknown, unknown) does not exist +LINE 1: SELECT array_varchar_deleteidx("nt", '311', '4aw') + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +QUERY: SELECT array_varchar_deleteidx("nt", '311', '4aw') +CONTEXT: referenced column: array_varchar_deleteidx +PL/pgSQL function inline_code_block line 15 at assignment +declare + type ta is table of varchar(32) index by varchar(32); + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt('311') := 'yellow'; + nt('a11') := 'red'; + nt('o2') := 'orange'; + nt('aaa') := 'aadw'; + nt('4aw') := 'green'; + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); + nt.DELETE('311'); + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); +END; +/ +NOTICE: yellow +NOTICE: red +NOTICE: orange +NOTICE: aadw +NOTICE: green +NOTICE: +NOTICE: red +NOTICE: orange +NOTICE: aadw +NOTICE: green +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is table of INTEGER; + type nest_type is table of n1; + nt nest_type := nest_type(n1(11, 22), n1(33, 44), n1(55, 66)); +BEGIN + raise notice '%',nt(1)(2); + raise notice '%',nt(2)(1); + raise notice '%',nt(3)(2); + nt.DELETE(2); + raise notice '%',nt(1)(1); + raise notice '%',nt(2)(2); + raise notice '%',nt(3)(1); +END; +/ +call proc1(); +NOTICE: 22 +NOTICE: 33 +NOTICE: 66 +ERROR: array_integer_deleteidx cannot be executed when tableOfIndex is not initialised. +CONTEXT: PL/pgSQL function proc1() line 9 at assignment +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is varray(20) of INTEGER; + type nest_type is varray(20) of n1; + nt nest_type; +BEGIN + nt(1):=n1(1,2); + nt(2):=n1(33, 44); + nt(3):=n1(55, 66); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); +END; +/ +call proc1(); +NOTICE: {1,2} +NOTICE: {33,44} +NOTICE: {55,66} +NOTICE: {1,2} +NOTICE: +NOTICE: {55,66} + proc1 +------- + +(1 row) + +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is varray(20) of NUMBER; + type nest_type is varray(20) of n1; + nt nest_type; +BEGIN + nt(1):=n1(1,2); + nt(2):=n1(33, 44); + nt(3):=n1(55, 66); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); +END; +/ +call proc1(); +NOTICE: {1,2} +NOTICE: {33,44} +NOTICE: {55,66} +NOTICE: {1,2} +NOTICE: +NOTICE: {55,66} + proc1 +------- + +(1 row) + +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is table of INTEGER; + type nest_type is table of n1; + nt nest_type; +BEGIN + nt(1):=n1(1,2); + nt(2):=n1(33, 44); + nt(3):=n1(55, 66); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); +END; +/ +call proc1(); +NOTICE: {1,2} +NOTICE: {33,44} +NOTICE: {55,66} +NOTICE: {1,2} +NOTICE: +NOTICE: {55,66} + proc1 +------- + +(1 row) + +DROP TYPE num_type; +DROP TYPE int_type; +DROP TYPE char_type; +DROP PROCEDURE proc1; diff --git a/src/test/regress/expected/arrayinterface_single.out b/src/test/regress/expected/arrayinterface_single.out index f7954f60b7701616c82606d4864288ca46766681..8819dad59a3829de1ccf929ce27791c5edfd5fa0 100644 --- a/src/test/regress/expected/arrayinterface_single.out +++ b/src/test/regress/expected/arrayinterface_single.out @@ -13,40 +13,40 @@ create schema plpgsql_array_interface; set current_schema = plpgsql_array_interface; -- must be call in procedure -- select array_varchar_exists(array['1', '2'], '3'); -ERROR: array_varchar_exists must be call in procedure +ERROR: array_varchar_exists cannot be executed when tableOfIndex is not initialised. CONTEXT: referenced column: array_varchar_exists select array_varchar_next(array['1','2'], '3'); -ERROR: array_varchar_next must be call in procedure +ERROR: array_varchar_next cannot be executed when tableOfIndex is not initialised. CONTEXT: referenced column: array_varchar_next select array_varchar_prior(array['1','2'], '3'); -ERROR: array_varchar_prior must be call in procedure +ERROR: array_varchar_prior cannot be executed when tableOfIndex is not initialised. CONTEXT: referenced column: array_varchar_prior select array_varchar_first(array['1','2']); -ERROR: array_varchar_first must be call in procedure +ERROR: array_varchar_first cannot be executed when tableOfIndex is not initialised. CONTEXT: referenced column: array_varchar_first select array_varchar_last(array['1','2']); -ERROR: array_varchar_last must be call in procedure +ERROR: array_varchar_last cannot be executed when tableOfIndex is not initialised. CONTEXT: referenced column: array_varchar_last select array_varchar_deleteidx(array['1','2'], '3'); -ERROR: array_varchar_deleteidx must be call in procedure +ERROR: array_varchar_deleteidx cannot be executed when tableOfIndex is not initialised. CONTEXT: referenced column: array_varchar_deleteidx select array_integer_exists(array[1, 2], 3); -ERROR: array_integer_exists must be call in procedure +ERROR: array_integer_exists cannot be executed when tableOfIndex is not initialised. CONTEXT: referenced column: array_integer_exists select array_integer_next(array[1, 2], 3); -ERROR: array_integer_next must be call in procedure +ERROR: array_integer_next cannot be executed when tableOfIndex is not initialised. CONTEXT: referenced column: array_integer_next select array_integer_prior(array[1, 2], 3); -ERROR: array_integer_prior must be call in procedure +ERROR: array_integer_prior cannot be executed when tableOfIndex is not initialised. CONTEXT: referenced column: array_integer_prior select array_integer_first(array[1, 2]); -ERROR: array_integer_first must be call in procedure +ERROR: array_integer_first cannot be executed when tableOfIndex is not initialised. CONTEXT: referenced column: array_integer_first select array_integer_last(array[1, 2]); -ERROR: array_integer_last must be call in procedure +ERROR: array_integer_last cannot be executed when tableOfIndex is not initialised. CONTEXT: referenced column: array_integer_last select array_integer_deleteidx(array[1, 2], 3); -ERROR: array_integer_deleteidx must be call in procedure +ERROR: array_integer_deleteidx cannot be executed when tableOfIndex is not initialised. CONTEXT: referenced column: array_integer_deleteidx -- test array interface count -- create or replace procedure array_interface_p1() diff --git a/src/test/regress/parallel_schedule0A b/src/test/regress/parallel_schedule0A index 66a206767fcf504c5f1c32b258d93b4dd9876a9c..472fdb5b552f24e35e023e23f27cc6b5eb4d8394 100644 --- a/src/test/regress/parallel_schedule0A +++ b/src/test/regress/parallel_schedule0A @@ -168,7 +168,7 @@ test: single_node_inet single_node_macaddr single_node_tstypes single_node_comme #test: single_node_regex test: single_node_regex_temp test_regexp test: single_node_oidjoins single_node_type_sanity - +test: array_compatible_a # ---------- # These four each depend on the previous one # ---------- diff --git a/src/test/regress/sql/array_compatible_a.sql b/src/test/regress/sql/array_compatible_a.sql new file mode 100644 index 0000000000000000000000000000000000000000..870a94f49737b117d85566d1a89b250263c06818 --- /dev/null +++ b/src/test/regress/sql/array_compatible_a.sql @@ -0,0 +1,1012 @@ +set enable_a_compatible_array = on; + +CREATE OR REPLACE TYPE num_type IS TABLE OF NUMBER; +CREATE OR REPLACE TYPE int_type IS TABLE OF INTEGER; +CREATE OR REPLACE TYPE char_type IS TABLE OF VARCHAR(20); + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + TYPE n1 IS varray(20) OF NUMBER; + nt n1 := n1(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + TYPE n1 IS varray(20) OF NUMBER index by integer; + nt n1 := n1(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('1'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('2','3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('1'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('2','3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE('1'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE('2','3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + idx int := 1; +BEGIN + nt.DELETE(idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, end_idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, 3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, '3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + idx int := 1; +BEGIN + nt.DELETE(idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, end_idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, 3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, '3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + idx int := 1; +BEGIN + nt.DELETE(idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(3-1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, end_idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(3-1, 5-2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, 3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, '3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +declare + type ta is table of varchar(32) index by integer; + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt(1) := 'red'; + nt(2) := 'orange'; + nt(3) := 'yellow'; + nt(4) := 'green'; + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +declare + type ta is table of varchar(32) index by integer; + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt(1) := 'red'; + nt(2) := 'orange'; + nt(3) := 'yellow'; + nt(4) := 'green'; + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +declare + type ta is table of varchar(32) index by varchar; + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt('1') := 'red'; + nt('2') := 'orange'; + nt('3') := 'yellow'; + nt('4') := 'green'; + nt.DELETE('2'); + raise notice '%',nt('1'); + raise notice '%',nt('2'); + raise notice '%',nt('3'); + raise notice '%',nt('4'); +END; +/ + +declare + type ta is table of varchar(32) index by varchar(32); + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt('311') := 'yellow'; + nt('a11') := 'red'; + nt('o2') := 'orange'; + nt('aaa') := 'aadw'; + nt('4aw') := 'green'; + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); + nt.DELETE('311', '4aw'); + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); +END; +/ + +declare + type ta is table of varchar(32) index by varchar(32); + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt('311') := 'yellow'; + nt('a11') := 'red'; + nt('o2') := 'orange'; + nt('aaa') := 'aadw'; + nt('4aw') := 'green'; + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); + nt.DELETE('311'); + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); +END; +/ + +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is varray(20) of NUMBER; + type nest_type is varray(20) of n1; + nt nest_type; + -- nt nest_type := nest_type(num_type(11, 22), num_type(33, 44), num_type(55, 66)); +BEGIN + nt(1):=n1(1,2); + nt(2):=n1(33, 44); + nt(3):=n1(55, 66); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); +END; +/ +call proc1(); + + +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is varray(20) of NUMBER; + type nest_type is varray(20) of n1; + nt nest_type; +BEGIN + nt(1):=n1(1,2); + nt(2):=n1(33, 44); + nt(3):=n1(55, 66); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); +END; +/ +call proc1(); + +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is table of NUMBER; + type nest_type is table of n1; + nt nest_type; +BEGIN + nt(1):=n1(1,2); + nt(2):=n1(33, 44); + nt(3):=n1(55, 66); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); +END; +/ +call proc1(); + +set enable_a_compatible_array = off; + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + TYPE n1 IS varray(20) OF NUMBER; + nt n1 := n1(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + TYPE n1 IS varray(20) OF NUMBER index by integer; + nt n1 := n1(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('1'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('2','3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('1'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); +BEGIN + nt.DELETE('2','3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE('1'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE('2','3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + idx int := 1; +BEGIN + nt.DELETE(idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, end_idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, 3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt num_type := num_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, '3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + idx int := 1; +BEGIN + nt.DELETE(idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, end_idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, 3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt int_type := int_type(11, 22, 33, 44, 55, 66); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, '3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + idx int := 1; +BEGIN + nt.DELETE(idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(3-1); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, end_idx); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); +BEGIN + nt.DELETE(3-1, 5-2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, 3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +DECLARE + nt char_type := char_type('one', 'two', 'three', 'four', 'five', 'six'); + start_idx int := 2; + end_idx int := 3; +BEGIN + nt.DELETE(start_idx, '3'); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +declare + type ta is table of varchar(32) index by integer; + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt(1) := 'red'; + nt(2) := 'orange'; + nt(3) := 'yellow'; + nt(4) := 'green'; + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +declare + type ta is table of varchar(32) index by integer; + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt(1) := 'red'; + nt(2) := 'orange'; + nt(3) := 'yellow'; + nt(4) := 'green'; + nt.DELETE(2,3); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + raise notice '%',nt(4); +END; +/ + +declare + type ta is table of varchar(32) index by varchar; + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt('1') := 'red'; + nt('2') := 'orange'; + nt('3') := 'yellow'; + nt('4') := 'green'; + nt.DELETE('2'); + raise notice '%',nt('1'); + raise notice '%',nt('2'); + raise notice '%',nt('3'); + raise notice '%',nt('4'); +END; +/ + +declare + type ta is table of varchar(32) index by varchar(32); + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt('311') := 'yellow'; + nt('a11') := 'red'; + nt('o2') := 'orange'; + nt('aaa') := 'aadw'; + nt('4aw') := 'green'; + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); + nt.DELETE('311', '4aw'); + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); +END; +/ + +declare + type ta is table of varchar(32) index by varchar(32); + nt ta; +begin + -- nt := array['red','orange','yellow','green']; + nt('311') := 'yellow'; + nt('a11') := 'red'; + nt('o2') := 'orange'; + nt('aaa') := 'aadw'; + nt('4aw') := 'green'; + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); + nt.DELETE('311'); + raise notice '%',nt('311'); + raise notice '%',nt('a11'); + raise notice '%',nt('o2'); + raise notice '%',nt('aaa'); + raise notice '%',nt('4aw'); +END; +/ + +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is table of INTEGER; + type nest_type is table of n1; + nt nest_type := nest_type(n1(11, 22), n1(33, 44), n1(55, 66)); +BEGIN + raise notice '%',nt(1)(2); + raise notice '%',nt(2)(1); + raise notice '%',nt(3)(2); + nt.DELETE(2); + raise notice '%',nt(1)(1); + raise notice '%',nt(2)(2); + raise notice '%',nt(3)(1); +END; +/ +call proc1(); + +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is varray(20) of INTEGER; + type nest_type is varray(20) of n1; + nt nest_type; +BEGIN + nt(1):=n1(1,2); + nt(2):=n1(33, 44); + nt(3):=n1(55, 66); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); +END; +/ +call proc1(); + + +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is varray(20) of NUMBER; + type nest_type is varray(20) of n1; + nt nest_type; +BEGIN + nt(1):=n1(1,2); + nt(2):=n1(33, 44); + nt(3):=n1(55, 66); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); +END; +/ +call proc1(); + +CREATE or REPLACE PROCEDURE proc1 AS +DECLARE + type n1 is table of INTEGER; + type nest_type is table of n1; + nt nest_type; +BEGIN + nt(1):=n1(1,2); + nt(2):=n1(33, 44); + nt(3):=n1(55, 66); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); + nt.DELETE(2); + raise notice '%',nt(1); + raise notice '%',nt(2); + raise notice '%',nt(3); +END; +/ +call proc1(); + +DROP TYPE num_type; +DROP TYPE int_type; +DROP TYPE char_type; +DROP PROCEDURE proc1; \ No newline at end of file