6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00

More python tests

This commit is contained in:
Pavel Císař 2021-11-11 18:01:08 +01:00
parent b1aff1ccdf
commit 095dd3a5af
16 changed files with 1417 additions and 385 deletions

View File

@ -15,7 +15,7 @@
# qmid:
import pytest
from firebird.qa import db_factory, python_act, Action
from firebird.qa import db_factory, python_act, Action, user_factory, User
# version: 3.0
# resources: None
@ -171,6 +171,9 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
user_1 = user_factory(name="Nebuchadnezzar2_King_of_Babylon",
password="Nebu_King_of_Babylon")
expected_stdout_1 = """
SEC$USER_NAME NEBUCHADNEZZAR2_KING_OF_BABYLON
SEC$FIRST_NAME Nebuchadnezzar3_King_of_Babylon
@ -179,22 +182,16 @@ SEC$LAST_NAME Nebuchadnezzar5_King_of_Babylon
"""
@pytest.mark.version('>=3.0')
def test_1(act_1: Action):
with act_1.connect_server() as srv:
check_login = "Nebuchadnezzar2_King_of_Babylon"
srv.user.add(user_name=check_login, password="Nebu_King_of_Babylon")
srv.user.update(user_name=check_login,
first_name="Nebuchadnezzar3_King_of_Babylon",
middle_name="Nebuchadnezzar4_King_of_Babylon",
last_name="Nebuchadnezzar5_King_of_Babylon")
#
act_1.script = f"""set list on;
def test_1(act_1: Action, user_1: User):
user_1.update(first_name="Nebuchadnezzar3_King_of_Babylon",
middle_name="Nebuchadnezzar4_King_of_Babylon",
last_name="Nebuchadnezzar5_King_of_Babylon")
#
act_1.script = f"""set list on;
select sec$user_name, sec$first_name, sec$middle_name, sec$last_name from sec$users
where upper(sec$user_name) = upper('{check_login}');
commit;
drop user {check_login};
where upper(sec$user_name) = upper('{user_1.name}');
"""
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_stdout == act_1.clean_expected_stdout
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -17,7 +17,7 @@
# qmid: bugs.core_1148
import pytest
from firebird.qa import db_factory, python_act, Action, temp_user, User
from firebird.qa import db_factory, python_act, Action, user_factory, User
from firebird.driver import DatabaseError
# version: 2.5
@ -95,7 +95,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
user_1 = temp_user(name='TMP$C1148', password='QweRtyUi')
user_1 = user_factory(name='TMP$C1148', password='QweRtyUi')
@pytest.mark.version('>=2.5')
def test_1(act_1: Action, user_1: User):

View File

@ -9,7 +9,8 @@
# qmid: bugs.core_1249
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
from firebird.driver import ShutdownMode, ShutdownMethod, DatabaseError
# version: 2.0.2
# resources: None
@ -51,16 +52,16 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
#
# # 'substitutions': [('^.*shutdown','shutdown')]
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
expected_stdout_1 = """
OK: operation not allowed.
Exception DOES contain text about shutdown.
"""
act_1 = python_act('db_1', substitutions=substitutions_1)
@pytest.mark.version('>=2.0.2')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
with act_1.connect_server() as srv, act_1.db.connect() as con:
srv.database.shutdown(database=str(act_1.db.db_path), mode=ShutdownMode.FULL,
method=ShutdownMethod.FORCED, timeout=0)
c = con.cursor()
with pytest.raises(DatabaseError, match='.*shutdown'):
c.execute('select 1 from rdb$database')
#
srv.database.bring_online(database=str(act_1.db.db_path))

View File

@ -9,12 +9,12 @@
# qmid: bugs.core_1263
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0
# resources: None
substitutions_1 = [('^((?!invalid switch specified).)*$', ''), ('invalid switch specified.*', 'invalid switch specified'), ('.*gsec is deprecated.*', '')]
substitutions_1 = []
init_script_1 = """"""
@ -32,20 +32,32 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# """
# runProgram('gsec',['-user',user_name,'-pas',user_password],commands)
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stderr_1 = """
GSEC> invalid switch specified in interactive mode
GSEC> invalid switch specified in interactive mode
GSEC> invalid switch specified in interactive mode
GSEC> invalid switch specified in interactive mode
GSEC> invalid switch specified in interactive mode
GSEC> invalid switch specified
"""
GSEC> invalid switch specified in interactive mode
GSEC> invalid switch specified in interactive mode
GSEC> invalid switch specified in interactive mode
GSEC> invalid switch specified in interactive mode
GSEC> invalid switch specified in interactive mode
GSEC> invalid switch specified
error in switch specifications
GSEC>
"""
@pytest.mark.version('>=3.0')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
commands = """add BADPARAM -pa PWD
add BADPARAM -pas PWD
add BADPARAM -password PWD
add BADPARAM -user USR
add BADPARAM -database DB
add BADPARAM -trusted
quit
"""
act_1.expected_stderr = expected_stderr_1
act_1.gsec(input=commands)
assert act_1.clean_expected_stderr == act_1.clean_stderr

View File

@ -9,7 +9,7 @@
# qmid: bugs.core_1286
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 2.5.2
# resources: None
@ -33,7 +33,8 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# runProgram('isql',[dsn,'-pag','0','-user',user_name,'-pas',user_password],script)
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
R
@ -41,9 +42,17 @@ expected_stdout_1 = """
1
"""
test_script_1 = """
set heading on;
select 1 as r from rdb$fields rows 1;
-- Crash of ISQL (not server) is reproduced when make connect by ISQL of WI-V2.5.1.26351.
-- After ISQL crash firebird.log contains: INET/inet_error: read errno = 10054
"""
@pytest.mark.version('>=2.5.2')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
act_1.expected_stdout = expected_stdout_1
act_1.isql(switches=['-pag', '0'], input=test_script_1)
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -9,16 +9,664 @@
# qmid: bugs.core_1291
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 2.1
# resources: None
substitutions_1 = [('Use CONNECT or CREATE DATABASE to specify a database', ''), ('SQL> ', ''), ('CON> ', '')]
substitutions_1 = [('Use CONNECT or CREATE DATABASE to specify a database', ''),
('SQL> ', ''), ('CON> ', '')]
init_script_1 = """"""
db_1 = db_factory(init=init_script_1)
test_script_1 = """
SET SQL DIALECT 3;
SET NAMES WIN1251;
CREATE DATABASE '%s' DEFAULT CHARACTER SET WIN1251;
CREATE DOMAIN DMN_BOOL AS
SMALLINT
DEFAULT 0;
CREATE DOMAIN DMN_PRICE AS
DOUBLE PRECISION
DEFAULT 0
CHECK (Value >= 0);
CREATE DOMAIN DMN_DOCNAME AS
VARCHAR(20) CHARACTER SET WIN1251;
CREATE TABLE TBL_CONST_FLOAT (
NAME VARCHAR(20) CHARACTER SET WIN1251 NOT NULL,
VAL DOUBLE PRECISION,
COMMENT VARCHAR(128) CHARACTER SET WIN1251
);
CREATE TABLE TBL_EXPORTENTRY (
ID_EXPORTGROUPENTRY INTEGER NOT NULL,
ID_EXPORTFIELDDOC INTEGER NOT NULL,
ACCOUNTCREDIT INTEGER DEFAULT 0 NOT NULL,
ACCOUNTDEBIT INTEGER DEFAULT 0 NOT NULL
);
CREATE TABLE TBL_INDOC_TEMP (
ID_INDOC_TEMP INTEGER NOT NULL,
ID_POINT INTEGER NOT NULL,
ID_ITEM INTEGER NOT NULL,
ID_INDOC INTEGER NOT NULL,
SERNO VARCHAR(20) CHARACTER SET WIN1251,
POINTMUL DOUBLE PRECISION NOT NULL,
VOLUME DMN_PRICE NOT NULL /* DMN_PRICE = DOUBLE PRECISION DEFAULT 0 CHECK (Value >= 0) */,
PRICEDOC DMN_PRICE /* DMN_PRICE = DOUBLE PRECISION DEFAULT 0 CHECK (Value >= 0) */,
PRICERUB DMN_PRICE /* DMN_PRICE = DOUBLE PRECISION DEFAULT 0 CHECK (Value >= 0) */,
PRICECUR DMN_PRICE /* DMN_PRICE = DOUBLE PRECISION DEFAULT 0 CHECK (Value >= 0) */,
PRICECALCDOC DMN_PRICE NOT NULL /* DMN_PRICE = DOUBLE PRECISION DEFAULT 0 CHECK (Value >= 0) */,
PRICECALCRUB DMN_PRICE NOT NULL /* DMN_PRICE = DOUBLE PRECISION DEFAULT 0 CHECK (Value >= 0) */,
PRICECALCCUR DMN_PRICE NOT NULL /* DMN_PRICE = DOUBLE PRECISION DEFAULT 0 CHECK (Value >= 0) */,
NDS DMN_PRICE /* DMN_PRICE = DOUBLE PRECISION DEFAULT 0 CHECK (Value >= 0) */,
F_CANSALE DMN_BOOL NOT NULL /* DMN_BOOL = SMALLINT DEFAULT 0 */,
PASPORT VARCHAR(64) CHARACTER SET WIN1251,
PASPORTCREATEDATE TIMESTAMP,
PASPORTEXPIREDATE TIMESTAMP,
REGISTRATION VARCHAR(64) CHARACTER SET WIN1251,
PROTOCOL VARCHAR(64) CHARACTER SET WIN1251,
SERTIFICAT VARCHAR(128) CHARACTER SET WIN1251,
ID_CERTCENTER INTEGER DEFAULT 0,
ITEMCREATEDATE TIMESTAMP,
ITEMEXPIREDATE TIMESTAMP,
ID_PARENT_OUTDOC_TEMP INTEGER DEFAULT 0,
SUMMDOC COMPUTED BY (Volume*PriceDoc),
SUMMRUB COMPUTED BY (Volume*PriceRub),
SUMMCUR COMPUTED BY (Volume*PriceCur),
SUMMCALCDOC COMPUTED BY (Volume*PriceCalcDoc),
SUMMCALCRUB COMPUTED BY (Volume*PriceCalcRub),
SUMMCALCCUR COMPUTED BY (Volume*PriceCalcCur),
SUMMNDSDOC COMPUTED BY (NDS*SummCalcDoc/100),
SUMMNDSRUB COMPUTED BY (NDS*SummCalcRub/100),
SUMMNDSCUR COMPUTED BY (NDS*SummCalcCur/100),
SUMMWITHNDSDOC COMPUTED BY (SummCalcDoc+SummNDSDoc),
SUMMWITHNDSRUB COMPUTED BY (SummCalcRub+SummNDSRub),
SUMMWITHNDSCUR COMPUTED BY (SummCalcCur+SummNDSCur),
PRICEDOC_IN DOUBLE PRECISION DEFAULT 0,
EXPIREPERCENT COMPUTED BY (Cast(100 * (ItemExpireDate - CURRENT_TIMESTAMP) / (ItemExpireDate - ItemCreateDate) as Integer))
);
CREATE TABLE TBL_OUTDOC_TEMP (
ID_OUTDOC_TEMP INTEGER NOT NULL,
ID_OUTDOC INTEGER NOT NULL,
ID_ITEMSALE INTEGER,
ID_ITEM INTEGER,
ID_POINT INTEGER NOT NULL,
VOLUME DOUBLE PRECISION DEFAULT 0 NOT NULL,
PRICEDOC DOUBLE PRECISION DEFAULT 0 NOT NULL,
NDS DOUBLE PRECISION DEFAULT 0 NOT NULL,
BUILDERPERCENT DOUBLE PRECISION DEFAULT 0 NOT NULL,
SUMMDOC DOUBLE PRECISION DEFAULT 0,
SUMMNDSDOC DOUBLE PRECISION DEFAULT 0,
SUMMWITHNDSDOC DOUBLE PRECISION DEFAULT 0,
BUILDERPRICE COMPUTED BY (PriceDoc*100/(100+BuilderPercent))
);
CREATE TABLE TBL_ITEMSALE (
ID_ITEMSALE INTEGER NOT NULL,
ID_STORE INTEGER NOT NULL,
ID_ITEM INTEGER NOT NULL,
ID_FIRSTINDOC_TEMP INTEGER NOT NULL,
F_ALOWSALE DMN_BOOL /* DMN_BOOL = SMALLINT DEFAULT 0 */,
VOLUME DMN_PRICE NOT NULL /* DMN_PRICE = DOUBLE PRECISION DEFAULT 0 CHECK (Value >= 0) */,
SALEPRICERUB DOUBLE PRECISION DEFAULT 0 NOT NULL,
SALEPRICECUR DOUBLE PRECISION DEFAULT 0 NOT NULL,
F_IMPORTED DMN_BOOL NOT NULL /* DMN_BOOL = SMALLINT DEFAULT 0 */,
V_VOLUME DOUBLE PRECISION DEFAULT 0,
V_MASS DOUBLE PRECISION DEFAULT 0
);
CREATE TABLE TBL_INDOC (
ID_INDOC INTEGER NOT NULL,
ID_STORE INTEGER NOT NULL,
ID_FIRM INTEGER NOT NULL,
ID_SELFFIRM INTEGER NOT NULL,
ID_CUR INTEGER NOT NULL,
DOCTYPE INTEGER NOT NULL,
DOCNAME DMN_DOCNAME /* DMN_DOCNAME = VARCHAR(20) */,
DATECREATE TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
DATEDOC TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
DATELASTEDIT TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
DATESTORE TIMESTAMP,
ID_USERCREATE INTEGER NOT NULL,
ID_USERLOCK INTEGER,
F_FINISHED DMN_BOOL /* DMN_BOOL = SMALLINT DEFAULT 0 */,
F_STORE DMN_BOOL /* DMN_BOOL = SMALLINT DEFAULT 0 */,
F_SPECIAL DMN_BOOL /* DMN_BOOL = SMALLINT DEFAULT 0 */,
ADDENDUM VARCHAR(128) CHARACTER SET WIN1251,
COMMENT VARCHAR(128) CHARACTER SET WIN1251,
COURSE DOUBLE PRECISION NOT NULL,
ID_PARENT_OUTDOC INTEGER DEFAULT 0 NOT NULL,
PRICEDOC_IN_IMPORTED SMALLINT DEFAULT 0 NOT NULL
);
SET TERM ^ ;
CREATE PROCEDURE PRC_EXPSUMM_8_10 (
ID_EXPORTFIELDDOC INTEGER,
ID_OUTDOC INTEGER,
NDSDIV DOUBLE PRECISION)
RETURNS (
SUMMRUS DOUBLE PRECISION,
SUMMDOC DOUBLE PRECISION)
AS
begin
IF (id_exportfielddoc=130) THEN BEGIN
SELECT SUM(A.PriceRub*B.Volume/A.PointMul), SUM(A.PriceDoc*B.Volume/A.PointMul) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=131) THEN BEGIN
SELECT SUM(A.PriceCalcRub*B.Volume/A.PointMul), SUM(A.PriceCalcDoc*B.Volume/A.PointMul) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=132) THEN BEGIN
SELECT SUM(A.SummDoc), SUM(A.SummDoc) FROM TBL_OUTDOC_TEMP A,
TBL_ITEMSALE B,
TBL_INDOC_TEMP C,
TBL_INDOC D
WHERE A.ID_OUTDOC=:id_outdoc and b.id_itemsale=a.id_itemsale and c.id_indoc_temp=b.id_firstindoc_temp and
d.id_indoc=c.id_indoc and d.doctype = 6 and a.nds>0 and a.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=133) THEN BEGIN
SELECT SUM(A.NDS*A.PriceRub*B.Volume/(A.PointMul*100)), SUM(A.NDS*A.PriceDoc*B.Volume/(A.PointMul*100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=134) THEN BEGIN
SELECT SUM(A.NDS*A.PriceCalcRub*B.Volume/(A.PointMul*100)), SUM(A.NDS*A.PriceCalcDoc*B.Volume/(A.PointMul*100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=135) THEN BEGIN
SELECT SUM(A.SummNDSDoc), SUM(A.SummNDSDoc) FROM TBL_OUTDOC_TEMP A,
TBL_ITEMSALE B,
TBL_INDOC_TEMP C,
TBL_INDOC D
WHERE A.ID_OUTDOC=:id_outdoc and b.id_itemsale=a.id_itemsale and c.id_indoc_temp=b.id_firstindoc_temp and
d.id_indoc=c.id_indoc and d.doctype = 6 and a.nds>0 and a.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=136) THEN BEGIN
SELECT SUM((A.PriceRub*B.Volume/A.PointMul)*(1+A.NDS/100)), SUM((A.PriceDoc*B.Volume/A.PointMul)*(1+A.NDS/100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=137) THEN BEGIN
SELECT SUM((A.PriceCalcRub*B.Volume/A.PointMul)*(1+A.NDS/100)), SUM((A.PriceCalcDoc*B.Volume/A.PointMul)*(1+A.NDS/100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=138) THEN BEGIN
SELECT SUM(A.SummWithNDSDoc), SUM(A.SummWithNDSDoc) FROM TBL_OUTDOC_TEMP A,
TBL_ITEMSALE B,
TBL_INDOC_TEMP C,
TBL_INDOC D
WHERE A.ID_OUTDOC=:id_outdoc and b.id_itemsale=a.id_itemsale and c.id_indoc_temp=b.id_firstindoc_temp and
d.id_indoc=c.id_indoc and d.doctype = 6 and a.nds>0 and a.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=139) THEN BEGIN
SELECT SUM((A.PriceCalcRub-A.PriceRub)*B.Volume/A.PointMul), SUM((A.PriceCalcDoc-A.PriceDoc)*B.Volume/A.PointMul) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=140) THEN BEGIN
SELECT SUM(B.SummDoc-(A.PriceRub*B.Volume/A.PointMul)), SUM(B.SummDoc-(A.PriceDoc*B.Volume/A.PointMul)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=141) THEN BEGIN
SELECT SUM(A.NDS*(A.PriceCalcRub-A.PriceRub)*B.Volume/(A.PointMul*100)), SUM(A.NDS*(A.PriceCalcDoc-A.PriceDoc)*B.Volume/(A.PointMul*100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=142) THEN BEGIN
SELECT SUM(B.SummNDSDoc-A.NDS*A.PriceRub*B.Volume/(A.PointMul*100)), SUM(B.SummNDSDoc-A.NDS*A.PriceDoc*B.Volume/(A.PointMul*100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=143) THEN BEGIN
SELECT SUM(((A.PriceCalcRub-A.PriceRub)*B.Volume/A.PointMul)*(1+A.NDS/100)), SUM(((A.PriceCalcDoc-A.PriceDoc)*B.Volume/A.PointMul)*(1+A.NDS/100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds<:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=144) THEN BEGIN
SELECT SUM(B.SummWithNDSDoc-(A.PriceRub*B.Volume/A.PointMul)*(1+A.NDS/100)), SUM(B.SummWithNDSDoc-(A.PriceDoc*B.Volume/A.PointMul)*(1+A.NDS/100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds<:NDSDiv
INTO :summrus, :summdoc;
END
SUSPEND;
END
^
CREATE PROCEDURE PRC_EXPSUMM_8_20 (
ID_EXPORTFIELDDOC INTEGER,
ID_OUTDOC INTEGER,
NDSDIV DOUBLE PRECISION)
RETURNS (
SUMMRUS DOUBLE PRECISION,
SUMMDOC DOUBLE PRECISION)
AS
begin
IF (id_exportfielddoc=145) THEN BEGIN
SELECT SUM(A.PriceRub*B.Volume/A.PointMul), SUM(A.PriceDoc*B.Volume/A.PointMul) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=146) THEN BEGIN
SELECT SUM(A.PriceCalcRub*B.Volume/A.PointMul), SUM(A.PriceCalcDoc*B.Volume/A.PointMul) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=147) THEN BEGIN
SELECT SUM(A.SummDoc), SUM(A.SummDoc) FROM TBL_OUTDOC_TEMP A,
TBL_ITEMSALE B,
TBL_INDOC_TEMP C,
TBL_INDOC D
WHERE A.ID_OUTDOC=:id_outdoc and b.id_itemsale=a.id_itemsale and c.id_indoc_temp=b.id_firstindoc_temp and
d.id_indoc=c.id_indoc and d.doctype = 6 and a.nds>0 and a.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=148) THEN BEGIN
SELECT SUM(A.NDS*A.PriceRub*B.Volume/(A.PointMul*100)), SUM(A.NDS*A.PriceDoc*B.Volume/(A.PointMul*100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=149) THEN BEGIN
SELECT SUM(A.NDS*A.PriceCalcRub*B.Volume/(A.PointMul*100)), SUM(A.NDS*A.PriceCalcDoc*B.Volume/(A.PointMul*100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=150) THEN BEGIN
SELECT SUM(A.SummNDSDoc), SUM(A.SummNDSDoc) FROM TBL_OUTDOC_TEMP A,
TBL_ITEMSALE B,
TBL_INDOC_TEMP C,
TBL_INDOC D
WHERE A.ID_OUTDOC=:id_outdoc and b.id_itemsale=a.id_itemsale and c.id_indoc_temp=b.id_firstindoc_temp and
d.id_indoc=c.id_indoc and d.doctype = 6 and a.nds>0 and a.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=151) THEN BEGIN
SELECT SUM((A.PriceRub*B.Volume/A.PointMul)*(1+A.NDS/100)), SUM((A.PriceDoc*B.Volume/A.PointMul)*(1+A.NDS/100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=152) THEN BEGIN
SELECT SUM((A.PriceCalcRub*B.Volume/A.PointMul)*(1+A.NDS/100)), SUM((A.PriceCalcDoc*B.Volume/A.PointMul)*(1+A.NDS/100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=153) THEN BEGIN
SELECT SUM(A.SummWithNDSDoc), SUM(A.SummWithNDSDoc) FROM TBL_OUTDOC_TEMP A,
TBL_ITEMSALE B,
TBL_INDOC_TEMP C,
TBL_INDOC D
WHERE A.ID_OUTDOC=:id_outdoc and b.id_itemsale=a.id_itemsale and c.id_indoc_temp=b.id_firstindoc_temp and
d.id_indoc=c.id_indoc and d.doctype = 6 and a.nds>0 and a.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=154) THEN BEGIN
SELECT SUM((A.PriceCalcRub-A.PriceRub)*B.Volume/A.PointMul), SUM((A.PriceCalcDoc-A.PriceDoc)*B.Volume/A.PointMul) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=155) THEN BEGIN
SELECT SUM(B.SummDoc-(A.PriceRub*B.Volume/A.PointMul)), SUM(B.SummDoc-(A.PriceDoc*B.Volume/A.PointMul)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=156) THEN BEGIN
SELECT SUM(A.NDS*(A.PriceCalcRub-A.PriceRub)*B.Volume/(A.PointMul*100)), SUM(A.NDS*(A.PriceCalcDoc-A.PriceDoc)*B.Volume/(A.PointMul*100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=157) THEN BEGIN
SELECT SUM(B.SummNDSDoc-A.NDS*A.PriceRub*B.Volume/(A.PointMul*100)), SUM(B.SummNDSDoc-A.NDS*A.PriceDoc*B.Volume/(A.PointMul*100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=158) THEN BEGIN
SELECT SUM(((A.PriceCalcRub-A.PriceRub)*B.Volume/A.PointMul)*(1+A.NDS/100)), SUM(((A.PriceCalcDoc-A.PriceDoc)*B.Volume/A.PointMul)*(1+A.NDS/100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=159) THEN BEGIN
SELECT SUM(B.SummWithNDSDoc-(A.PriceRub*B.Volume/A.PointMul)*(1+A.NDS/100)), SUM(B.SummWithNDSDoc-(A.PriceDoc*B.Volume/A.PointMul)*(1+A.NDS/100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds>0 and b.nds>=:NDSDiv
INTO :summrus, :summdoc;
END
SUSPEND;
END
^
CREATE PROCEDURE PRC_EXPSUMM_8(
ID_INDOC INTEGER,
ID_OUTDOC INTEGER,
ID_GROUP INTEGER)
RETURNS (
ACCOUNTCREDIT INTEGER,
ACCOUNTDEBIT INTEGER,
SUMMRUS DOUBLE PRECISION,
SUMMDOC DOUBLE PRECISION)
AS
DECLARE VARIABLE NDSDiv DOUBLE PRECISION;
DECLARE VARIABLE ID_ExportFieldDoc Integer;
begin
SELECT Val FROM TBL_Const_Float
WHERE Name='NDSDiv'
INTO :NDSDiv;
FOR SELECT id_exportfielddoc, accountcredit, accountdebit FROM tbl_exportentry
WHERE id_exportgroupentry=:id_group
INTO :id_exportfielddoc, :accountcredit, :accountdebit
DO BEGIN
IF ((AccountCredit<>0) or (AccountDebit<>0)) THEN BEGIN
IF (id_exportfielddoc=110) THEN BEGIN
SELECT SUM(A.PriceRub*B.Volume/A.PointMul), SUM(A.PriceDoc*B.Volume/A.PointMul) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=111) THEN BEGIN
SELECT SUM(A.PriceCalcRub*B.Volume/A.PointMul), SUM(A.PriceCalcDoc*B.Volume/A.PointMul) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=112) THEN BEGIN
SELECT SUM(A.SummDoc), SUM(A.SummDoc) FROM TBL_OUTDOC_TEMP A,
TBL_ITEMSALE B,
TBL_INDOC_TEMP C,
TBL_INDOC D
WHERE A.ID_OUTDOC=:id_outdoc and b.id_itemsale=a.id_itemsale and c.id_indoc_temp=b.id_firstindoc_temp and
d.id_indoc=c.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=113) THEN BEGIN
SELECT SUM(A.NDS*A.PriceRub*B.Volume/(A.PointMul*100)), SUM(A.NDS*A.PriceDoc*B.Volume/(A.PointMul*100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=114) THEN BEGIN
SELECT SUM(A.NDS*A.PriceCalcRub*B.Volume/(A.PointMul*100)), SUM(A.NDS*A.PriceCalcDoc*B.Volume/(A.PointMul*100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=115) THEN BEGIN
SELECT SUM(A.SummNDSDoc), SUM(A.SummNDSDoc) FROM TBL_OUTDOC_TEMP A,
TBL_ITEMSALE B,
TBL_INDOC_TEMP C,
TBL_INDOC D
WHERE A.ID_OUTDOC=:id_outdoc and b.id_itemsale=a.id_itemsale and c.id_indoc_temp=b.id_firstindoc_temp and
d.id_indoc=c.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=116) THEN BEGIN
SELECT SUM((A.PriceRub*B.Volume/A.PointMul)*(1+A.NDS/100)), SUM((A.PriceDoc*B.Volume/A.PointMul)*(1+A.NDS/100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=117) THEN BEGIN
SELECT SUM((A.PriceCalcRub*B.Volume/A.PointMul)*(1+A.NDS/100)), SUM((A.PriceCalcDoc*B.Volume/A.PointMul)*(1+A.NDS/100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=118) THEN BEGIN
SELECT SUM(A.SummWithNDSDoc), SUM(A.SummWithNDSDoc) FROM TBL_OUTDOC_TEMP A,
TBL_ITEMSALE B,
TBL_INDOC_TEMP C,
TBL_INDOC D
WHERE A.ID_OUTDOC=:id_outdoc and b.id_itemsale=a.id_itemsale and c.id_indoc_temp=b.id_firstindoc_temp and
d.id_indoc=c.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=119) THEN BEGIN
SELECT SUM((A.PriceCalcRub-A.PriceRub)*B.Volume/A.PointMul), SUM((A.PriceCalcDoc-A.PriceDoc)*B.Volume/A.PointMul) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=120) THEN BEGIN
SELECT SUM(B.SummDoc-(A.PriceRub*B.Volume/A.PointMul)), SUM(B.SummDoc-(A.PriceDoc*B.Volume/A.PointMul)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=121) THEN BEGIN
SELECT SUM(A.NDS*(A.PriceCalcRub-A.PriceRub)*B.Volume/(A.PointMul*100)), SUM(A.NDS*(A.PriceCalcDoc-A.PriceDoc)*B.Volume/(A.PointMul*100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=122) THEN BEGIN
SELECT SUM(B.SummNDSDoc-A.NDS*A.PriceRub*B.Volume/(A.PointMul*100)), SUM(B.SummNDSDoc-A.NDS*A.PriceDoc*B.Volume/(A.PointMul*100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=123) THEN BEGIN
SELECT SUM(((A.PriceCalcRub-A.PriceRub)*B.Volume/A.PointMul)*(1+A.NDS/100)), SUM(((A.PriceCalcDoc-A.PriceDoc)*B.Volume/A.PointMul)*(1+A.NDS/100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=124) THEN BEGIN
SELECT SUM(B.SummWithNDSDoc-(A.PriceRub*B.Volume/A.PointMul)*(1+A.NDS/100)), SUM(B.SummWithNDSDoc-(A.PriceDoc*B.Volume/A.PointMul)*(1+A.NDS/100)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=125) THEN BEGIN
SELECT SUM(A.PriceRub*B.Volume/A.PointMul), SUM(A.PriceDoc*B.Volume/A.PointMul) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds=0
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=126) THEN BEGIN
SELECT SUM(A.PriceCalcRub*B.Volume/A.PointMul), SUM(A.PriceCalcDoc*B.Volume/A.PointMul) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds=0
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=127) THEN BEGIN
SELECT SUM(A.SummDoc), SUM(A.SummDoc) FROM TBL_OUTDOC_TEMP A,
TBL_ITEMSALE B,
TBL_INDOC_TEMP C,
TBL_INDOC D
WHERE A.ID_OUTDOC=:id_outdoc and b.id_itemsale=a.id_itemsale and c.id_indoc_temp=b.id_firstindoc_temp and
d.id_indoc=c.id_indoc and d.doctype = 6 and a.nds=0
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=128) THEN BEGIN
SELECT SUM((A.PriceCalcRub-A.PriceRub)*B.Volume/A.PointMul), SUM((A.PriceCalcDoc-A.PriceDoc)*B.Volume/A.PointMul) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds=0
INTO :summrus, :summdoc;
END
IF (id_exportfielddoc=129) THEN BEGIN
SELECT SUM(B.SummDoc-(A.PriceRub*B.Volume/A.PointMul)), SUM(B.SummDoc-(A.PriceDoc*B.Volume/A.PointMul)) FROM TBL_INDOC_TEMP A,
TBL_OUTDOC_TEMP B,
TBL_ITEMSALE C,
TBL_INDOC D
WHERE b.id_outdoc=:id_outdoc and b.id_itemsale=c.id_itemsale and c.id_firstindoc_temp=a.id_indoc_temp and
d.id_indoc=a.id_indoc and d.doctype = 6 and b.nds=0
INTO :summrus, :summdoc;
END
IF ((id_exportfielddoc>129)and(id_exportfielddoc<145)) THEN BEGIN
execute procedure prc_expsumm_8_10 ( id_exportfielddoc, id_outdoc, NDSDiv ) returning_values( summrus, summdoc );
END
IF ((id_exportfielddoc>144)and(id_exportfielddoc<160)) THEN BEGIN
execute procedure prc_expsumm_8_20 ( id_exportfielddoc, id_outdoc, NDSDiv ) returning_values( summrus, summdoc );
END
IF ((SummRus>0) or (SummDoc>0)) THEN SUSPEND;
END
END
END
^
SET TERM ; ^
COMMIT WORK;
SHOW PROCEDURE PRC_EXPSUMM_8;
EXIT;
"""
db_1 = db_factory(do_not_create=True)
# test_script_1
#---
@ -38,7 +686,8 @@ db_1 = db_factory(init=init_script_1)
#
# runProgram('isql',['-user',user_name,'-pas',user_password],script)
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """Procedure text:
=============================================================================
@ -256,8 +905,10 @@ SUMMDOC OUTPUT DOUBLE PRECISION
"""
@pytest.mark.version('>=2.1')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
act_1.expected_stdout = expected_stdout_1
act_1.isql(switches=['-user', act_1.db.user, '-password', act_1.db.password],
input=test_script_1 % act_1.db.dsn, connect_db=False, charset='WIN1251')
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -9,7 +9,7 @@
# qmid: bugs.core_1315
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 2.1
# resources: None
@ -34,7 +34,8 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# cur.execute(statement,[None])
# printData(cur)
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """COALESCE
-----------
@ -46,8 +47,16 @@ COALESCE
"""
@pytest.mark.version('>=2.1')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, capsys):
with act_1.db.connect() as con:
c = con.cursor()
statement = c.prepare('select coalesce(?,1) from RDB$DATABASE')
c.execute(statement,[2])
act_1.print_data(c)
c.execute(statement,[None])
act_1.print_data(c)
act_1.stdout = capsys.readouterr().out
act_1.expected_stdout = expected_stdout_1
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -19,7 +19,8 @@
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action, temp_file
from pathlib import Path
# version: 2.5
# resources: None
@ -134,16 +135,54 @@ db_1 = db_factory(charset='WIN1251', sql_dialect=3, init=init_script_1)
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
RDB$PROCEDURE_NAME SP_TEST
Records affected: 1
"""
tmp_file_1 = temp_file('non_ascii_ddl.sql')
sql_txt = '''set bail on;
set term ^ ;
create procedure sp_test (
p_tablename varchar(30) ,
p_idname varchar(30) ,
p_seqname varchar(30) ,
p_isusefunc smallint
)
returns (
column_value bigint
)
as
declare variable l_maxid bigint;
begin
/*
-- Находим разрыв в значениях ПК таблицы
-- если разрыв отсутствует то дергаем секвенс
-- p_IsUseFunc=1 - дергать секвенс ч/з ф-цию GetSeqValue
*/
end ^
set term ;^
commit;
set list on;
set count on;
select pr.rdb$procedure_name
from rdb$procedures pr
where pr.rdb$procedure_source containing '1'
and pr.rdb$procedure_name = upper('sp_test');
'''
@pytest.mark.version('>=2.5')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, tmp_file_1: Path):
tmp_file_1.write_bytes(sql_txt.encode('cp1251'))
act_1.expected_stdout = expected_stdout_1
act_1.isql(switches=['-q'], input_file=tmp_file_1, charset='win1251', io_enc='cp1251')
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -19,7 +19,8 @@
# qmid: bugs.core_1378
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action, temp_file
from pathlib import Path
# version: 2.5.9
# resources: None
@ -147,7 +148,55 @@ db_1 = db_factory(charset='WIN1251', sql_dialect=3, init=init_script_1)
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
tmp_file_1 = temp_file('non_ascii_ddl.sql')
sql_txt = '''
set bail on;
create collation "вид прописи" for win1251 from pxw_cyrl pad space case insensitive accent insensitive;
commit;
create domain "значение числа" as int;
create domain "число прописью" as varchar(8191) character set win1251 collate "вид прописи";
commit;
create table test( id "значение числа", txt "число прописью");
commit;
set term ^;
create procedure sp_test ( i_number "значение числа") returns( o_text "число прописью") as
begin
suspend;
end
^
set term ;^
commit;
--set blob all;
--select rdb$procedure_source as rdb_source_blob_id from rdb$procedures where rdb$procedure_name = upper('sp_test');
set list on;
select rdb$procedure_name from rdb$procedures where rdb$procedure_name = upper('sp_test');
select
p.rdb$parameter_name
,p.rdb$field_source
,f.rdb$field_type
,f.rdb$field_sub_type
,f.rdb$field_length
,f.rdb$character_length
,f.rdb$character_set_id
,f.rdb$collation_id
,c.rdb$character_set_name
,s.rdb$collation_name
from rdb$procedure_parameters p
left join rdb$fields f on p.rdb$field_source = f.rdb$field_name
left join rdb$character_sets c on f.rdb$character_set_id = c.rdb$character_set_id
left join rdb$collations s on
f.rdb$collation_id = s.rdb$collation_id
and c.rdb$character_set_id = s.rdb$character_set_id
where rdb$procedure_name = upper('sp_test');
'''
expected_stdout_1 = """
RDB$PROCEDURE_NAME SP_TEST
@ -174,8 +223,10 @@ expected_stdout_1 = """
"""
@pytest.mark.version('>=2.5.9')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, tmp_file_1: Path):
tmp_file_1.write_bytes(sql_txt.encode('cp1251'))
act_1.expected_stdout = expected_stdout_1
act_1.isql(switches=['-q'], input_file=tmp_file_1, charset='win1251', io_enc='cp1251')
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -8,7 +8,7 @@
# with request to establish connection using charset = ISO8859_1.
#
# *** NOTE ***
# Script that must be executed by ISQL does NOT contain any nnon-ascii characters.
# Script that must be executed by ISQL does NOT contain any non-ascii characters.
# Query with diacritical symbols was moved into view V_TEST which is created in init_script
# using charset ***UTF-8*** (otherwise is seems to be unable to run this test on Linux).
#
@ -36,18 +36,18 @@ init_script_1 = """
create or alter view v_test as
select
iif( _iso8859_1 'Ja ' collate coll_es like _iso8859_1 '% a%' collate coll_es, 1, 0) result_for_es_ci_ai
iif( _iso8859_1 'Ja ' collate coll_es like _iso8859_1 '% a%' collate coll_es, 1, 0) result_for_es_ci_ai
,iif( _iso8859_1 'ka ' collate coll_fr like _iso8859_1 '% a%' collate coll_fr, 1, 0) result_for_fr_ci_ai
from rdb$database
UNION ALL -- added comparison to pattern with diactiric mark:
select
iif( _iso8859_1 '' collate coll_es like _iso8859_1 '% à %' collate coll_es, 1, 0) result_for_es_ci_ai
iif( _iso8859_1 '' collate coll_es like _iso8859_1 '% à %' collate coll_es, 1, 0) result_for_es_ci_ai
,iif( _iso8859_1 '' collate coll_fr like _iso8859_1 '% à %' collate coll_fr, 1, 0) result_for_fr_ci_ai
from rdb$database
;
"""
db_1 = db_factory(charset='ISO8859_1', sql_dialect=3, init=init_script_1)
db_1 = db_factory(charset='UTF8', sql_dialect=3, init=init_script_1)
# test_script_1
#---
@ -64,7 +64,14 @@ db_1 = db_factory(charset='ISO8859_1', sql_dialect=3, init=init_script_1)
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
test_script_1 = """
set list on;
show collation;
select * from v_test;
"""
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1, charset='ISO8859_1')
expected_stdout_1 = """
COLL_ES, CHARACTER SET ISO8859_1, FROM EXTERNAL ('ES_ES_CI_AI'), 'SPECIALS-FIRST=1'
@ -76,8 +83,9 @@ expected_stdout_1 = """
"""
@pytest.mark.version('>=2.1.7')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -30,7 +30,8 @@
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
from firebird.driver import DbInfoCode
# version: 2.5
# resources: None
@ -85,18 +86,34 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# cur.close()
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
expected_stdout_1 = """
Number of indexed reads: 1
Number of indexed reads: 1
Number of indexed reads: 1
Number of indexed reads: 1
"""
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """Number of indexed reads: 1
Number of indexed reads: 1
Number of indexed reads: 1
Number of indexed reads: 1
"""
@pytest.mark.version('>=2.5')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, capsys):
with act_1.db.connect() as con:
c = con.cursor()
c.execute("select rdb$relation_id from rdb$relations where trim(rdb$relation_name)=upper('test')")
test_rel = c.fetchone()[0]
#
sql_set=['select min(x) from test',
'select x from test order by x rows 1',
'select max(y) from test',
'select y from test order by y desc rows 1']
previous_idx_counter = 0
for cmd in sql_set:
c.execute(cmd).fetchone()
counts = con.info.get_info(DbInfoCode.READ_IDX_COUNT)
for k, cumulative_idx_counter in counts.items():
if k == test_rel:
print('Number of indexed reads:', cumulative_idx_counter - previous_idx_counter)
previous_idx_counter = cumulative_idx_counter
#
output = capsys.readouterr()
assert output.out == expected_stdout_1

View File

@ -172,7 +172,7 @@ init_script_1 = """
commit;
"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
db_1 = db_factory(sql_dialect=3, init=init_script_1, charset='UTF8')
# test_script_1
#---
@ -197,7 +197,18 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
test_script_1 = """
set list on;
-- Test: following statement should pass OK, w/o exceptions:
select min(t.descr) as has_no_upper_case_equiv
-- PREVIOUSLY we use here: "upper(c) has_no_upper_case_equiv" // can be run on Windows only
from c1251 t
group by upper(t.c)
having count(*) <> 2 ;
"""
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1, charset='WIN1251')
expected_stdout_1 = """
HAS_NO_UPPER_CASE_EQUIV LOW 9 SINGLE QUOTE
@ -234,8 +245,9 @@ expected_stdout_1 = """
"""
@pytest.mark.version('>=2.1.7')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -30,7 +30,8 @@
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
from firebird.driver import DatabaseError
# version: 2.5
# resources: None
@ -50,7 +51,8 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# print( e[0] )
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
Error while executing SQL statement:
@ -59,8 +61,9 @@ expected_stdout_1 = """
"""
@pytest.mark.version('>=2.5')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
with act_1.db.connect() as con:
with pytest.raises(DatabaseError, match='.*-Unexpected end of command.*'):
con.execute_immediate('')

View File

@ -43,7 +43,7 @@ from firebird.qa import db_factory, isql_act, Action
# version: 2.1
# resources: None
substitutions_1 = []
substitutions_1 = [('RDB$TRIGGER_SOURCE.*', 'RDB$TRIGGER_SOURCE <VALUE>')]
init_script_1 = """
-- ### ONCE AGAIN ###
@ -66,7 +66,7 @@ init_script_1 = """
commit;
"""
db_1 = db_factory(charset='WIN1251', sql_dialect=3, init=init_script_1)
db_1 = db_factory(charset='UTF8', sql_dialect=3, init=init_script_1)
# test_script_1
#---
@ -148,12 +148,60 @@ db_1 = db_factory(charset='WIN1251', sql_dialect=3, init=init_script_1)
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
test_script_1 = """
set blob all;
set list on;
-- Ticket:
-- select * from rdb$triggers where rdb$trigger_source like 'CHECK%%' ==> "Cannot transliterate character between character sets."
-- select * from rdb$triggers where rdb$trigger_source starting 'CHECK' ==> works fine.
select rdb$trigger_name, rdb$trigger_source
from rdb$triggers
where rdb$trigger_source like 'check%%'
order by cast(replace(rdb$trigger_name, 'CHECK_', '') as int);
"""
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1, charset='WIN1251')
expected_stdout_1 = """
RDB$TRIGGER_NAME CHECK_1
RDB$TRIGGER_SOURCE 0:b
check (bugtype in ('зрабіць', 'трэба зрабіць', 'недахоп', 'памылка', 'катастрофа'))
RDB$TRIGGER_NAME CHECK_2
RDB$TRIGGER_SOURCE 0:e
check (bugtype in ('зрабіць', 'трэба зрабіць', 'недахоп', 'памылка', 'катастрофа'))
RDB$TRIGGER_NAME CHECK_3
RDB$TRIGGER_SOURCE 0:11
check (bugfrequency in ('ніколі', 'зрэдку', 'часам', 'часта', 'заўсёды', 'не прыкладаецца'))
RDB$TRIGGER_NAME CHECK_4
RDB$TRIGGER_SOURCE 0:14
check (bugfrequency in ('ніколі', 'зрэдку', 'часам', 'часта', 'заўсёды', 'не прыкладаецца'))
RDB$TRIGGER_NAME CHECK_5
RDB$TRIGGER_SOURCE 0:17
check (decision in ('адкрыта', 'зроблена', 'састарэла', 'адхілена', 'часткова', 'выдалена'))
RDB$TRIGGER_NAME CHECK_6
RDB$TRIGGER_SOURCE 0:1a
check (decision in ('адкрыта', 'зроблена', 'састарэла', 'адхілена', 'часткова', 'выдалена'))
RDB$TRIGGER_NAME CHECK_7
RDB$TRIGGER_SOURCE 0:1d
check ((decision = 'адкрыта' and fixerkey is null and decisiondate is null) or (decision <> 'адкрыта' and not fixerkey is null and not decisiondate is null))
RDB$TRIGGER_NAME CHECK_8
RDB$TRIGGER_SOURCE 0:20
check ((decision = 'адкрыта' and fixerkey is null and decisiondate is null) or (decision <> 'адкрыта' and not fixerkey is null and not decisiondate is null))
"""
@pytest.mark.version('>=2.1')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -13,7 +13,7 @@
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action, user_factory, User
# version: 2.5
# resources: None
@ -21,32 +21,6 @@ from firebird.qa import db_factory, isql_act, Action
substitutions_1 = []
init_script_1 = """
-- Drop old account if it remains from prevoius run:
set term ^;
execute block as
begin
begin
execute statement 'drop user tmp$c1642_alan' with autonomous transaction;
when any do begin end
end
begin
execute statement 'drop user tmp$c1642_john' with autonomous transaction;
when any do begin end
end
begin
execute statement 'drop user tmp$c1642_mick' with autonomous transaction;
when any do begin end
end
end
^
set term ;^
commit;
create user tmp$c1642_alan password '123';
create user tmp$c1642_john password '456';
create user tmp$c1642_mick password '789';
commit;
create or alter view v_my_attach as
select current_user as who_am_i, iif(current_connection - mon$attachment_id = 0, 'OK.', 'BAD') as my_attach_id
from mon$attachments;
@ -91,7 +65,8 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# db_conn.commit()
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
TMP$C1642_ALAN OK.
@ -99,9 +74,23 @@ expected_stdout_1 = """
TMP$C1642_MICK OK.
"""
user_1 = user_factory(name='tmp$c1642_alan', password='123')
user_2 = user_factory(name='tmp$c1642_john', password = '456')
user_3 = user_factory(name='tmp$c1642_mick', password = '789')
@pytest.mark.version('>=2.5')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, user_1: User, user_2: User, user_3: User, capsys):
act_1.expected_stdout = expected_stdout_1
for user in [user_1, user_2, user_3]:
with act_1.db.connect(user=user.name, password=user.password) as con:
c = con.cursor()
c.execute('select who_am_i, my_attach_id from v_my_attach')
for row in c:
print(row[0], row[1])
act_1.stdout = capsys.readouterr().out
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -33,14 +33,175 @@
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
from firebird.driver import SrvRestoreFlag, SrvRepairFlag
from io import BytesIO
from difflib import unified_diff
# version: 3.0.6
# resources: None
substitutions_1 = [('[ \t]+', ' ')]
init_script_1 = """"""
init_script_1 = """
set bail on;
create or alter procedure sp_init as begin end;
create or alter procedure sp_main as begin end;
create or alter procedure sp_worker as begin end;
create or alter function fn_init returns int as begin end;
create or alter function fn_main returns int as begin end;
create or alter function fn_worker returns int as begin end;
create table test(id int primary key, x int, y int);
create index test_x on test(x);
create descending index test_y on test(y);
commit;
insert into test(id, x, y) select row_number()over(), rand()*5, rand()*100 from rdb$types;
commit;
create or alter view v_init as
select count(*) as cnt from test group by x
rows 1
;
create or alter view v_worker as
select count(*) as cnt
from test
group by y
plan (TEST ORDER TEST_Y)
union all
select cnt from v_init
;
commit;
set term ^;
execute block as
begin
rdb$set_context('USER_SESSION','INITIAL_DDL', '1');
end
^
create or alter procedure sp_init as
declare c int;
begin
select count(*) from test group by x
rows 1
into c
;
end
^
create or alter procedure sp_main as
begin
execute procedure sp_worker;
end
^
create or alter procedure sp_worker as
declare c int;
begin
select sum(cnt)
from (
select count(*) as cnt
from test group by x
plan (TEST ORDER TEST_X)
union all
select cnt from v_worker
)
into c
;
end
^
create or alter function fn_init returns int as
begin
return ( select count(*) from test );
end
^
create or alter function fn_worker returns int as
begin
return (
select sum(cnt)
from (
select count(*) as cnt
from test group by x
plan (TEST ORDER TEST_X)
union all
select cnt from v_worker
)
);
end
^
create or alter function fn_main returns int as
begin
return fn_worker();
end
^
create or alter package pg_test as
begin
function pg_fn_worker returns int;
procedure pg_sp_worker;
end
^
recreate package body pg_test as
begin
function pg_fn_worker returns int as
begin
return (
select sum(cnt)
from (
select count(*) as cnt
from test group by x
plan (TEST ORDER TEST_X)
union all
select cnt from v_worker
)
);
end
procedure pg_sp_worker as
declare c int;
begin
select sum(cnt)
from (
select count(*) as cnt
from test group by x
plan (TEST ORDER TEST_X)
union all
select cnt from v_worker
)
into c
;
end
end
^
create or alter trigger trg_attach active on connect position 0 as
declare c int;
begin
if ( rdb$get_context('USER_SESSION','INITIAL_DDL') is null ) then
begin
select sum(cnt)
from (
select count(*) as cnt
from test group by x
plan (TEST ORDER TEST_X)
union all
select cnt from v_worker
)
into c;
end
end
^
set term ;^
commit;
"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
@ -389,16 +550,41 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
expected_stdout_1 = """
+ Validation started
+ Validation finished: 0 errors, 0 warnings, 0 fixed
"""
act_1 = python_act('db_1', substitutions=substitutions_1)
@pytest.mark.version('>=3.0.6')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
# Extract metadata from initial DB
act_1.isql(switches=['-nod', '-x'])
meta_1 = act_1.stdout
act_1.reset()
# backup + restore _WITHOUT_ building indices:
backup = BytesIO()
with act_1.connect_server() as srv:
srv.database.local_backup(database=str(act_1.db.db_path), backup_stream=backup)
backup.seek(0)
srv.database.local_restore(backup_stream=backup, database=str(act_1.db.db_path),
flags=SrvRestoreFlag.DEACTIVATE_IDX | SrvRestoreFlag.REPLACE)
# Get FB log before validation, run validation and get FB log after it:
srv.info.get_log()
log_before = srv.readlines()
srv.database.repair(database=str(act_1.db.db_path), flags=SrvRepairFlag.CORRUPTION_CHECK)
srv.info.get_log()
log_after = srv.readlines()
# Extract metadata from restored DB
act_1.isql(switches=['-nod', '-x'])
meta_2 = act_1.stdout
act_1.reset()
# Restore with indices. This is necessary to drop the database safely otherwise connect
# to drop will fail in test treadown as connect trigger referes to index tat was not activated
with act_1.connect_server() as srv:
backup.seek(0)
srv.database.local_restore(backup_stream=backup, database=str(act_1.db.db_path),
flags=SrvRestoreFlag.REPLACE)
#
diff_meta = ''.join(unified_diff(meta_1.splitlines(), meta_2.splitlines()))
diff_log = [line for line in unified_diff(log_before, log_after) if line.startswith('+') and 'Validation finished:' in line]
# Checks
assert diff_meta == ''
assert diff_log == ['+\tValidation finished: 0 errors, 0 warnings, 0 fixed\n']