Issue Details (XML | Word | Printable)

Key: CORE-1694
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Adriano dos Santos Fernandes
Reporter: Sviridov Sergey
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Bug in create/alter Database trigger (with Russian comment)

Created: 15/Jan/08 04:58 AM   Updated: 18/Nov/08 01:36 PM
Component/s: Engine
Affects Version/s: 2.1 Beta 1, 2.1 Beta 2, 2.1 RC1
Fix Version/s: 2.1 RC2, 2.5 Alpha 1

Time Tracking:
Not Specified

File Attachments: 1. File BUG_TEST.FDB (784 kB)
2. Zip Archive ibtestunicode.zip (7 kB)

Environment: Windows XP SP2, Firebird 2.1.0.15999 Beta 1, fbclient 2.1.0.15999


 Description  « Hide
Bug in create/alter Database trigger

If execute statment

alter TRIGGER DBTRIGGER_COPY ACTIVE ON CONNECT POSITION 0
AS
/* дескрипшн переменной триггера БД
дескрипшн переменной триггера БД строка 2
database trigger description
database trigger description string 2 */
DECLARE VARIABLE NEW_VAR SMALLINT DEFAULT 4;
/* дескрипшн переменной триггера БД
дескрипшн переменной триггера БД строка 2
database trigger description
database trigger description string 2 */
DECLARE VARIABLE NEW_VAR1 VARCHAR(30) CHARACTER SET UTF8 COLLATE UTF8 DEFAULT 'Дефолт Default';
DECLARE VARIABLE EFWEF TYPE OF VARCHAR_DOMAIN2;
/* дескрипшн переменной триггера БД
дескрипшн переменной триггера БД строка 2
database trigger description
database trigger description string 2 */
DECLARE VARIABLE NEW_VAR2 TYPE OF VARCHAR_DOMAIN DEFAULT 'Дефолт Default';
/* дескрипшн переменной триггера БД
дескрипшн переменной триггера БД
database trigger description
database trigger description string 2 */
DECLARE VARIABLE NEW_VAR3 TYPE OF SMALLINT_DOMAIN DEFAULT 3;
BEGIN
  /* Database Trigger body */
END

It will cause a mistake
"This operation is not defined for system tables.Unsuccessful metadata update.
Create metadata BLOB failed.
Cannot transliterate character between character sets."

But if change domain type variable EFWEF to VARCHAR_DOMAIN, or change
...
DECLARE VARIABLE NEW_VAR2 TYPE OF VARCHAR_DOMAIN DEFAULT 'Дефолт Default';
/* дескрипшн переменной триггера БД
дескрипшн переменной триггера БД
database trigger description
database trigger description string 2 */
DECLARE VARIABLE NEW_VAR3 TYPE OF SMALLINT_DOMAIN DEFAULT 3;
...

to

...
DECLARE VARIABLE NEW_VAR2 TYPE OF VARCHAR_DOMAIN DEFAULT 'Дефолт Default';
/* дескрипшн переменной триггера БД
дескрипшн
database trigger description
database trigger description string 2 */
DECLARE VARIABLE NEW_VAR3 TYPE OF SMALLINT_DOMAIN DEFAULT 3;
...

that the inquiry will be executed successfully

Domain statements(Identical):
CREATE DOMAIN VARCHAR_DOMAIN AS
  VARCHAR(30) CHARACTER SET UTF8
  COLLATE UTF8;
  
 CREATE DOMAIN VARCHAR_DOMAIN2 AS
  VARCHAR(30) CHARACTER SET UTF8
  COLLATE UTF8;

 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Adriano dos Santos Fernandes added a comment - 15/Jan/08 03:03 PM
This is WIN1251 text, correct?

I can't reproduce the problem...

What tool you used? Can the error be reproducible with SQL?

Can you also test with a more recent snapshot?

Sviridov Sergey added a comment - 16/Jan/08 11:40 PM
This is database on which the bug reproduce

Sviridov Sergey added a comment - 16/Jan/08 11:42 PM
On server FB 2.1 beta 2 too reproduce

Adriano dos Santos Fernandes added a comment - 17/Jan/08 02:52 PM
I tested with ISQL in Win32 Beta1 (15999) and Linux x86 RC1 and there is no problem.

There is only a minor problem, when you try to alter a non existent trigger:
Statement failed, SQLCODE = -902
Dynamic SQL Error
-Invalid command
-Database trigger type can't be changed
After line 0 in file r.sql

Sviridov Sergey added a comment - 18/Jan/08 08:58 AM - edited
If use client connection "utf8" that reproduce

Example code
...
static const char *szClientCharset = "UTF8";

//with Descr BUG
static const wchar_t *szAlterDBTriggerW = L"ALTER TRIGGER DBTRIGGER ACTIVE\r\nON CONNECT POSITION 0\r\nAS\r\n/* дескрипшн переменной триггера БД\r\nдескрипшн переменной триггера БД строка 2\r\ndatabase trigger description\r\ndatabase trigger description string 2 */\r\nDECLARE VARIABLE NEW_VAR SMALLINT DEFAULT 4;\r\n/* дескрипшн переменной триггера БД\r\nдескрипшн переменной триггера БД строка 2\r\ndatabase trigger description\r\ndatabase trigger description string 2 */\r\nDECLARE VARIABLE NEW_VAR1 VARCHAR(30) CHARACTER SET UTF8 COLLATE UTF8 DEFAULT 'Дефолт Default';\r\nDECLARE VARIABLE EFWEF TYPE OF VARCHAR_DOMAIN2;\r\n/* дескрипшн переменной триггера БД\r\nдескрипшн переменной триггера БД строка 2\r\ndatabase trigger description\r\ndatabase trigger description string 2 */\r\nDECLARE VARIABLE NEW_VAR2 TYPE OF VARCHAR_DOMAIN DEFAULT 'Дефолт Default';\r\n/* дескрипшн переменной триггера БД\r\nдескрипшн переменной триггера БД\r\ndatabase trigger description\r\ndatabase trigger description string 2 */\r\nDECLARE VARIABLE NEW_VAR3 TYPE OF SMALLINT_DOMAIN DEFAULT 3;\r\nBEGIN\r\n /* Database Trigger body */\r\nEND;";
...
                          Len = WideCharToMultiByte(CP_UTF8, 0, szAlterDBTriggerW, wcslen(szAlterDBTriggerW), NULL, 0, NULL, false);
szNonUnicode = new char[Len+1];
ZeroMemory(szNonUnicode, (Len+1)*sizeof(char));
WideCharToMultiByte(CP_UTF8, 0, szAlterDBTriggerW, wcslen(szAlterDBTriggerW), szNonUnicode, Len, NULL, false);
...
isc_dsql_execute_immediate(sv, &tmpDbHandle, &tmpTrHandle, wcslen(FSqlTextW), (char*)FSqlTextW,3,NULL) // <- Return non zero value

Sviridov Sergey added a comment - 18/Jan/08 09:10 AM
Examle to execute