def setUp(self):
        tap_oracle.dump_catalog = do_not_dump_catalog
        full_table.UPDATE_BOOKMARK_PERIOD = 1000

        with get_test_connection() as conn:
            cur = conn.cursor()
            cur.execute("""
                begin
                    rdsadmin.rdsadmin_util.set_configuration(
                        name  => 'archivelog retention hours',
                        value => '24');
                end;
            """)

            cur.execute("""
                begin
                   rdsadmin.rdsadmin_util.alter_supplemental_logging(
                      p_action => 'ADD');
                end;
            """)

            result = cur.execute("select log_mode from v$database").fetchall()
            self.assertEqual(result[0][0], "ARCHIVELOG")

            table_spec = {
                "columns": [{
                    "name": "id",
                    "type": "integer",
                    "primary_key": True,
                    "identity": True
                }, {
                    "name": '"our_date"',
                    "type": "DATE"
                }, {
                    "name": '"our_ts"',
                    "type": "TIMESTAMP"
                }, {
                    "name": '"our_ts_tz_edt"',
                    "type": "TIMESTAMP WITH TIME ZONE"
                }, {
                    "name": '"our_ts_tz_utc"',
                    "type": "TIMESTAMP WITH TIME ZONE"
                }, {
                    "name": '"our_ts_tz_local"',
                    "type": "TIMESTAMP WITH LOCAL TIME ZONE"
                }],
                "name":
                "CHICKEN"
            }
            ensure_test_table(table_spec)
Ejemplo n.º 2
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": 'our_money_pk',
             "type": "money",
             "primary_key": True
         }, {
             "name": 'our_money',
             "type": "money"
         }],
         "name":
         TestHStoreTable.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 3
0
    def setUp(self):
        tap_oracle.dump_catalog = do_not_dump_catalog
        full_table.UPDATE_BOOKMARK_PERIOD = 1000

        with get_test_connection() as conn:

            cur = conn.cursor()
            table_spec = {"columns": [{"name": "id", "type" : "integer",       "primary_key" : True, "identity" : True},
                                      {"name": '"none_column"',                "type" : "integer"},
                                      {"name": "no_sync",                      "type" : "integer"},
                                      {"name": "bad_column",                   "type" : "long"},

                                      {"name" : '"size_number_4_0"',      "type" : "number(4,0)"},
                                      {"name" : '"size_number_*_0"',      "type" : "number(*,0)"},
                                      {"name" : '"size_number_10_-1"',    "type" : "number(10,-1)"},
                                      {"name" : '"size_number_integer"',  "type" : "integer"},
                                      {"name" : '"size_number_int"',      "type" : "int"},
                                      {"name" : '"size_number_smallint"', "type" : "smallint"},

                                      {"name" : '"our_number_10_2"',           "type" : "number(10,2)"},
                                      {"name" : '"our_number_38_4"',           "type" : "number(38,4)"},

                                      {"name" : '"our_float"',                 "type" : "float" },
                                      {"name" : '"our_double_precision"',      "type" : "double precision"},
                                      {"name" : '"our_real"',                  "type" : "real"},
                                      {"name" : '"our_nan"',                   "type" : "binary_float"},
                                      {"name" : '"our_+_infinity"',            "type" : "binary_float"},
                                      {"name" : '"our_-_infinity"',            "type" : "binary_float"},
                                      {"name" : '"our_binary_float"',          "type" : "binary_float"},
                                      {"name" : '"our_binary_double"',         "type" : "binary_double"},

                                      {"name" : '"our_date"',                   "type" : "DATE"},
                                      {"name" : '"our_ts"',                     "type" : "TIMESTAMP"},
                                      {"name" : '"our_ts_tz_edt"',              "type" : "TIMESTAMP WITH TIME ZONE"},
                                      {"name" : '"our_ts_tz_utc"',              "type" : "TIMESTAMP WITH TIME ZONE"},
                                      {"name" : '"our_ts_tz_local"',            "type" : "TIMESTAMP WITH LOCAL TIME ZONE"},

                                      {"name" : '"name-char-explicit-byte"',     "type": "char(250 byte)"},
                                      {"name" : '"name-char-explicit-char"',     "type": "char(250 char)"},
                                      {"name" : 'name_nchar',                   "type": "nchar(123)"},
                                      {"name" : '"name-nvarchar2"',              "type": "nvarchar2(234)"},

                                      {"name" : '"name-varchar-explicit-byte"',  "type": "varchar(250 byte)"},
                                      {"name" : '"name-varchar-explicit-char"',  "type": "varchar(251 char)"},

                                      {"name" : '"name-varchar2-explicit-byte"', "type": "varchar2(250 byte)"},
                                      {"name" : '"name-varchar2-explicit-char"', "type": "varchar2(251 char)"}
            ],
                          "name" : "CHICKEN"}
            ensure_test_table(table_spec)
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": 'our_pk',
             "type": "uuid",
             "primary_key": True
         }, {
             "name": 'our_uuid',
             "type": "uuid"
         }],
         "name":
         TestUUIDTables.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 5
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": 'our_int_array_pk',
             "type": "integer[]",
             "primary_key": True
         }, {
             "name": 'our_string_array',
             "type": "varchar[]"
         }],
         "name":
         TestHStoreTable.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 6
0
 def setUp(self):
     table_spec = {
         "columns": [
             {
                 "name": "id",
                 "type": "integer",
                 "primary_key": True,
                 "identity": True
             },
             #NLS_LENGTH_SEMANTICS = byte
             {
                 "name": '"name-char-explicit-byte"',
                 "type": "char(250 byte)"
             },
             {
                 "name": '"name-char-explicit-char"',
                 "type": "char(250 char)"
             },
             {
                 "name": '"name-nchar"',
                 "type": "nchar(123)"
             },
             {
                 "name": '"name-nvarchar2"',
                 "type": "nvarchar2(234)"
             },
             {
                 "name": '"name-varchar-explicit-byte"',
                 "type": "varchar(250 byte)"
             },
             {
                 "name": '"name-varchar-explicit-char"',
                 "type": "varchar(251 char)"
             },
             {
                 "name": '"name-varchar2-explicit-byte"',
                 "type": "varchar2(250 byte)"
             },
             {
                 "name": '"name-varchar2-explicit-char"',
                 "type": "varchar2(251 char)"
             }
         ],
         "name":
         "CHICKEN"
     }
     ensure_test_table(table_spec)
     tap_oracle.dump_catalog = do_not_dump_catalog
     full_table.UPDATE_BOOKMARK_PERIOD = 1000
Ejemplo n.º 7
0
    def setUp(self):
        with get_test_connection('postgres') as conn:
            with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur:
                cur.execute('DROP MATERIALIZED VIEW IF EXISTS "LIKE CHICKEN TIMES"')
        table_spec = {"columns": [{"name" : 'our_int_array_pk',          "type" : "integer[]", "primary_key" : True },
                                  {"name" : 'our_text_array',            "type" : "text[]" }],
                      "name" : TestArraysLikeTable.table_name}
        ensure_test_table(table_spec)

        with get_test_connection('postgres') as conn:
            with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur:
                 create_sql = "CREATE MATERIALIZED VIEW {} AS SELECT * FROM {}\n".format(quote_ident(TestArraysLikeTable.like_table_name, cur),
                                                                                         quote_ident(TestArraysLikeTable.table_name, cur))


                 cur.execute(create_sql)
Ejemplo n.º 8
0
 def setUp(self):
     table_spec = {
         "columns": [
             {
                 "name": "our_secrets",
                 "type": "json"
             },
             {
                 "name": "our_secrets_b",
                 "type": "jsonb"
             },
         ],
         "name":
         TestJsonTables.table_name,
     }
     ensure_test_table(table_spec)
Ejemplo n.º 9
0
 def setUp(self):
     table_spec = {
         "columns": [
             {
                 "name": "our_bool",
                 "type": "boolean"
             },
             {
                 "name": "our_bit",
                 "type": "bit"
             },
         ],
         "name":
         TestBoolsAndBits.table_name,
     }
     ensure_test_table(table_spec)
Ejemplo n.º 10
0
    def setUp(self):
        with get_test_connection() as conn:
            cur = conn.cursor()
            table_spec_1 = {"columns": [{"name": "id", "type" : "integer",       "primary_key" : True, "identity" : True},
                                        {"name" : 'name', "type": "varchar2(250)"},
                                        {"name" : 'colour', "type": "varchar2(250)"}],
                          "name" : "CHICKEN"}
            ensure_test_table(table_spec_1)

            table_spec_2 = {"columns": [{"name": "id", "type" : "integer",       "primary_key" : True, "identity" : True},
                                        {"name" : 'name', "type": "varchar2(250)"},
                                        {"name" : 'colour', "type": "varchar2(250)"}],
                            "name" : "COW"}
            ensure_test_table(table_spec_2)
            ensure_supplemental_logging()
            full_table.UPDATE_BOOKMARK_PERIOD = 1000
    def setUp(self):
        table_spec_1 = {
            "columns": [
                {
                    "name": "id",
                    "type": "serial",
                    "primary_key": True
                },
                {
                    "name": "name",
                    "type": "character varying"
                },
                {
                    "name": "colour",
                    "type": "character varying"
                },
            ],
            "name":
            "COW",
        }
        ensure_test_table(table_spec_1)

        table_spec_2 = {
            "columns": [
                {
                    "name": "id",
                    "type": "serial",
                    "primary_key": True
                },
                {
                    "name": "name",
                    "type": "character varying"
                },
                {
                    "name": "colour",
                    "type": "character varying"
                },
            ],
            "name":
            "CHICKEN",
        }
        ensure_test_table(table_spec_2)

        global COW_RECORD_COUNT
        COW_RECORD_COUNT = 0
        global CAUGHT_MESSAGES
        CAUGHT_MESSAGES.clear()
Ejemplo n.º 12
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": 'our_decimal',
             "type": "numeric",
             "primary_key": True
         }, {
             "name": 'our_decimal_10_2',
             "type": "decimal(10,2)"
         }, {
             "name": 'our_decimal_38_4',
             "type": "decimal(38,4)"
         }],
         "name":
         TestDecimalPK.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 13
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": 'our_float',
             "type": "float",
             "primary_key": True
         }, {
             "name": 'our_real',
             "type": "real"
         }, {
             "name": 'our_double',
             "type": "double precision"
         }],
         "name":
         TestFloatTablePK.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 14
0
    def setUp(self):
        table_spec = {
            "columns": [
                {"name": "our_pk", "type": "hstore", "primary_key": True},
                {"name": "our_hstore", "type": "hstore"},
            ],
            "name": TestHStoreTable.table_name,
        }
        with get_test_connection() as conn:
            cur = conn.cursor()
            cur.execute(
                """ SELECT installed_version FROM pg_available_extensions WHERE name = 'hstore' """
            )
            if cur.fetchone()[0] is None:
                cur.execute(""" CREATE EXTENSION hstore; """)

        ensure_test_table(table_spec)
Ejemplo n.º 15
0
    def setUp(self):
        table_spec = {
            "columns": [
                {"name": "id", "type": "integer", "serial": True},
                {"name": "size integer", "type": "integer", "quoted": True},
                {"name": "size smallint", "type": "smallint", "quoted": True},
                {"name": "size bigint", "type": "bigint", "quoted": True},
            ],
            "name": TestColumnGrants.table_name,
        }
        ensure_test_table(table_spec)

        with get_test_connection() as conn:
            cur = conn.cursor()

            sql = """
           DO
           $$BEGIN
           IF EXISTS (SELECT FROM pg_roles WHERE rolname = '{}') THEN
               EXECUTE 'REVOKE CONNECT ON DATABASE "postgres" FROM {}';
           END IF;
           END$$;
           """.format(
                self.user, self.user
            )
            LOGGER.info(sql)
            cur.execute(sql)

            sql = """ DROP USER IF EXISTS {} """.format(self.user)
            LOGGER.info(sql)
            cur.execute(sql)

            sql = """ CREATE USER {} WITH PASSWORD '{}' """.format(self.user, self.password)
            LOGGER.info(sql)
            cur.execute(sql)

            sql = """ GRANT CONNECT ON DATABASE "postgres" TO {}""".format(self.user)
            LOGGER.info("running sql: {}".format(sql))
            cur.execute(sql)

            sql = """ GRANT SELECT ("id") ON "{}" TO {}""".format(
                TestColumnGrants.table_name, self.user
            )
            LOGGER.info("running sql: {}".format(sql))
            cur.execute(sql)
    def setUp(self):
        table_spec_1 = {
            "columns": [{
                "name": "id",
                "type": "integer",
                "primary_key": True,
                "identity": True
            }, {
                "name": 'name',
                "type": "nvarchar2(100)"
            }, {
                "name": 'colour',
                "type": "nvarchar2(100)"
            }],
            "name":
            'COW'
        }
        ensure_test_table(table_spec_1)

        table_spec_2 = {
            "columns": [{
                "name": "id",
                "type": "integer",
                "primary_key": True,
                "identity": True
            }, {
                "name": 'name',
                "type": "nvarchar2(100)"
            }, {
                "name": 'colour',
                "type": "nvarchar2(100)"
            }],
            "name":
            'CHICKEN'
        }
        ensure_test_table(table_spec_2)

        global COW_RECORD_COUNT
        COW_RECORD_COUNT = 0
        global CAUGHT_MESSAGES
        CAUGHT_MESSAGES.clear()
        tap_oracle.dump_catalog = do_not_dump_catalog
        full_table.UPDATE_BOOKMARK_PERIOD = 1
Ejemplo n.º 17
0
    def setUp(self):
        tap_oracle.dump_catalog = do_not_dump_catalog
        full_table.UPDATE_BOOKMARK_PERIOD = 1000
        with get_test_connection() as conn:
            cur = conn.cursor()
            table_spec = {
                "columns": [{
                    "name": "interval_column",
                    "type": "INTERVAL DAY TO SECOND",
                    "primary_key": True
                }, {
                    "name": "age",
                    "type": "integer"
                }],
                "name":
                "CHICKEN"
            }

            ensure_test_table(table_spec)
Ejemplo n.º 18
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": '"our_number"',
             "type": "number",
             "primary_key": True
         }, {
             "name": '"our_number_10_2"',
             "type": "number(10,2)"
         }, {
             "name": '"our_number_38_4"',
             "type": "number(38,4)"
         }],
         "name":
         "CHICKEN"
     }
     ensure_test_table(table_spec)
     tap_oracle.dump_catalog = do_not_dump_catalog
     full_table.UPDATE_BOOKMARK_PERIOD = 1000
Ejemplo n.º 19
0
    def setUp(self):
        table_spec = {
            "columns": [{
                "name": "id",
                "type": "integer",
                "serial": True
            }, {
                "name": 'size integer',
                "type": "integer",
                "quoted": True
            }, {
                "name": 'size smallint',
                "type": "smallint",
                "quoted": True
            }, {
                "name": 'size bigint',
                "type": "bigint",
                "quoted": True
            }],
            "name":
            TestColumnGrants.table_name
        }
        ensure_test_table(table_spec)

        with get_test_connection(superuser=True) as conn:
            cur = conn.cursor()

            sql = """ DROP USER IF EXISTS {} """.format(
                self.user, self.password)
            LOGGER.info(sql)
            cur.execute(sql)

            sql = """ CREATE USER {} WITH PASSWORD '{}' """.format(
                self.user, self.password)
            LOGGER.info(sql)
            cur.execute(sql)

            sql = """ GRANT SELECT ("id") ON "{}" TO {}""".format(
                TestColumnGrants.table_name, self.user)
            LOGGER.info("running sql: {}".format(sql))
            cur.execute(sql)
 def setUp(self):
     table_spec_1 = {
         "columns": [{
             "name": "id",
             "type": "serial",
             "primary_key": True
         }, {
             "name": 'name',
             "type": "character varying"
         }, {
             "name": 'colour',
             "type": "character varying"
         }],
         "name":
         'COW'
     }
     ensure_test_table(table_spec_1)
     global COW_RECORD_COUNT
     COW_RECORD_COUNT = 0
     global CAUGHT_MESSAGES
     CAUGHT_MESSAGES.clear()
Ejemplo n.º 21
0
    def setUp(self):
        table_spec = {"columns": [{"name": "interval_col",   "type": "INTERVAL"},
                                  {"name": "bit_string_col", "type": "bit(5)"},
                                  {"name": "bytea_col",      "type": "bytea"},
                                  {"name": "point_col",      "type": "point"},
                                  {"name": "line_col",      "type": "line"},
                                  {"name": "lseg_col",      "type": "lseg"},
                                  {"name": "box_col",      "type": "box"},
                                  {"name": "polygon_col",      "type": "polygon"},
                                  {"name": "circle_col",      "type": "circle"},
                                  {"name": "xml_col",      "type": "xml"},
                                  {"name": "composite_col",      "type": "person_composite"},
                                  {"name": "int_range_col",      "type": "int4range"},
        ],
                      "name": Unsupported.table_name}
        with get_test_connection() as conn:
            cur = conn.cursor()
            cur.execute("""     DROP TYPE IF EXISTS person_composite CASCADE """)
            cur.execute("""     CREATE TYPE person_composite AS (age int, name text) """)

        ensure_test_table(table_spec)
Ejemplo n.º 22
0
    def setUp(self):
        table_spec = {
            "columns": [{
                "name": 'our_mood_enum_pk',
                "type": "mood_enum",
                "primary_key": True
            }, {
                "name": 'our_mood_enum',
                "type": "mood_enum"
            }],
            "name":
            TestHStoreTable.table_name
        }
        with get_test_connection() as conn:
            cur = conn.cursor()
            cur.execute("""     DROP TYPE IF EXISTS mood_enum CASCADE """)
            cur.execute(
                """     CREATE TYPE mood_enum AS ENUM ('sad', 'ok', 'happy'); """
            )

        ensure_test_table(table_spec)
Ejemplo n.º 23
0
    def setUp(self):
        tap_oracle.dump_catalog = do_not_dump_catalog
        full_table.UPDATE_BOOKMARK_PERIOD = 1000

        with get_test_connection() as conn:
            cur = conn.cursor()
            cur.execute("""
                begin
                    rdsadmin.rdsadmin_util.set_configuration(
                        name  => 'archivelog retention hours',
                        value => '24');
                end;
            """)

            cur.execute("""
                begin
                   rdsadmin.rdsadmin_util.alter_supplemental_logging(
                      p_action => 'ADD');
                end;
            """)

            result = cur.execute("select log_mode from v$database").fetchall()
            self.assertEqual(result[0][0], "ARCHIVELOG")



        table_spec = {"columns": [{"name" : "id",                            "type" : "integer", "primary_key" : True, "identity" : True},
                                  {"name" : '"name-char-explicit-byte"',     "type": "char(250 byte)"},
                                  {"name" : '"name-char-explicit-char"',     "type": "char(250 char)"},
                                  {"name" : 'name_nchar',                   "type": "nchar(123)"},
                                  {"name" : '"name-nvarchar2"',              "type": "nvarchar2(234)"},

                                  {"name" : '"name-varchar-explicit-byte"',  "type": "varchar(250 byte)"},
                                  {"name" : '"name-varchar-explicit-char"',  "type": "varchar(251 char)"},

                                  {"name" : '"name-varchar2-explicit-byte"', "type": "varchar2(250 byte)"},
                                  {"name" : '"name-varchar2-explicit-char"', "type": "varchar2(251 char)"}],
                      "name" : "CHICKEN"}

        ensure_test_table(table_spec)
Ejemplo n.º 24
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": '"our_date"',
             "type": "DATE",
             "primary_key": True
         }, {
             "name": '"our_ts"',
             "type": "TIMESTAMP"
         }, {
             "name": '"our_ts_tz"',
             "type": "TIMESTAMP WITH TIME ZONE"
         }, {
             "name": '"our_ts_tz_local"',
             "type": "TIMESTAMP WITH LOCAL TIME ZONE"
         }],
         "name":
         "CHICKEN"
     }
     ensure_test_table(table_spec)
     tap_oracle.dump_catalog = do_not_dump_catalog
     full_table.UPDATE_BOOKMARK_PERIOD = 1000
Ejemplo n.º 25
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": 'our_date',
             "type": "DATE",
             "primary_key": True
         }, {
             "name": 'our_ts',
             "type": "TIMESTAMP"
         }, {
             "name": 'our_ts_tz',
             "type": "TIMESTAMP WITH TIME ZONE"
         }, {
             "name": 'our_time',
             "type": "TIME"
         }, {
             "name": 'our_time_tz',
             "type": "TIME WITH TIME ZONE"
         }],
         "name":
         TestDatesTablePK.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 26
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": "id",
             "type": "integer",
             "serial": True
         }, {
             "name": 'size integer',
             "type": "integer",
             "quoted": True
         }, {
             "name": 'size smallint',
             "type": "smallint",
             "quoted": True
         }, {
             "name": 'size bigint',
             "type": "bigint",
             "quoted": True
         }],
         "name":
         TestIntegerTable.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 27
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": "id",
             "type": "integer",
             "primary_key": True,
             "serial": True
         }, {
             "name": '"character-varying_name"',
             "type": "character varying"
         }, {
             "name": '"varchar-name"',
             "type": "varchar(28)"
         }, {
             "name": 'char_name',
             "type": "char(10)"
         }, {
             "name": '"text-name"',
             "type": "text"
         }],
         "name":
         TestStringTableWithPK.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 28
0
    def setUp(self):
        tap_oracle.dump_catalog = do_not_dump_catalog
        full_table.UPDATE_BOOKMARK_PERIOD = 1000
        with get_test_connection() as conn:
            cur = conn.cursor()
            cur.execute("""
                begin
                    rdsadmin.rdsadmin_util.set_configuration(
                        name  => 'archivelog retention hours',
                        value => '24');
                end;
            """)

            cur.execute("""
                begin
                   rdsadmin.rdsadmin_util.alter_supplemental_logging(
                      p_action => 'ADD');
                end;
            """)

            result = cur.execute("select log_mode from v$database").fetchall()
            self.assertEqual(result[0][0], "ARCHIVELOG")

        table_spec = {
            "columns": [
                {
                    "name": '"our_float"',
                    "type": "float",
                    "primary_key": True,
                    "identity": True
                },
                {
                    "name": '"our_double_precision"',
                    "type": "double precision"
                },
                {
                    "name": '"our_real"',
                    "type": "real"
                },
                {
                    "name": '"our_nan"',
                    "type": "binary_float"
                },
                {
                    "name": '"our_+_infinity"',
                    "type": "binary_float"
                },
                {
                    "name": '"our_-_infinity"',
                    "type": "binary_float"
                },

                #only ones that support NaN/+Inf/-Inf
                {
                    "name": '"our_binary_float"',
                    "type": "binary_float"
                },
                {
                    "name": '"our_binary_double"',
                    "type": "binary_double"
                }
            ],
            "name":
            "CHICKEN"
        }

        ensure_test_table(table_spec)