2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
2022-02-04 19:05:19 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
ID: gtcs.ref_integ_drop_pk_constraint
|
|
|
|
TITLE: Constraint of PRIMARY KEY should not be avail for DROP if there is FK that depends on it
|
|
|
|
DESCRIPTION:
|
|
|
|
Original test see in:
|
|
|
|
https://github.com/FirebirdSQL/fbtcs/blob/master/GTCS/tests/REF_INT.2.ISQL.script
|
|
|
|
FBTEST: functional.gtcs.ref_integ_drop_pk_constraint
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
import pytest
|
2022-02-04 19:05:19 +01:00
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-02-04 19:05:19 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-02-04 19:05:19 +01:00
|
|
|
act = python_act('db')
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-02-04 19:05:19 +01:00
|
|
|
expected_stderr = """
|
|
|
|
Statement failed, SQLSTATE = 27000
|
|
|
|
unsuccessful metadata update
|
|
|
|
-DROP INDEX DEPT_KEY failed
|
|
|
|
-action cancelled by trigger (1) to preserve data integrity
|
|
|
|
-Cannot delete index used by an Integrity Constraint
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-02-04 19:05:19 +01:00
|
|
|
Statement failed, SQLSTATE = 23000
|
|
|
|
violation of PRIMARY or UNIQUE KEY constraint "DEPT_KEY" on table "DEPARTMENT"
|
|
|
|
-Problematic key value is ("DEPT_NO" = '1')
|
|
|
|
"""
|
|
|
|
|
|
|
|
expected_stdout = """
|
|
|
|
Records affected: 0
|
|
|
|
"""
|
|
|
|
|
|
|
|
@pytest.mark.skip('FIXME: Not IMPLEMENTED')
|
|
|
|
@pytest.mark.version('>=3.0')
|
|
|
|
def test_1(act: Action):
|
|
|
|
pytest.fail("Not IMPLEMENTED")
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
# test_script_1
|
|
|
|
#---
|
2022-02-04 19:05:19 +01:00
|
|
|
#
|
2021-04-26 20:07:00 +02:00
|
|
|
# import os
|
|
|
|
# import sys
|
|
|
|
# import subprocess
|
2022-02-04 19:05:19 +01:00
|
|
|
#
|
2021-04-26 20:07:00 +02:00
|
|
|
# os.environ["ISC_USER"] = user_name
|
|
|
|
# os.environ["ISC_PASSWORD"] = user_password
|
2022-02-04 19:05:19 +01:00
|
|
|
#
|
2021-04-26 20:07:00 +02:00
|
|
|
# db_conn.close()
|
2022-02-04 19:05:19 +01:00
|
|
|
#
|
2021-04-26 20:07:00 +02:00
|
|
|
# with open( os.path.join(context['files_location'],'gtcs-ref-integ.sql'), 'r') as f:
|
|
|
|
# sql_init = f.read()
|
2022-02-04 19:05:19 +01:00
|
|
|
#
|
2021-04-26 20:07:00 +02:00
|
|
|
# sql_addi='''
|
|
|
|
# drop index dept_key;
|
|
|
|
# -- Check that PK index still in use: following must FAIL:
|
|
|
|
# set count on;
|
|
|
|
# insert into department( dept_no, dept_name) values (1, 'k1');
|
|
|
|
# '''
|
2022-02-04 19:05:19 +01:00
|
|
|
#
|
2021-04-26 20:07:00 +02:00
|
|
|
# runProgram('isql', [ dsn], os.linesep.join( (sql_init, sql_addi) ) )
|
|
|
|
#---
|