Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive Query bug in FB2.1 [CORE1122] #1543

Closed
firebird-automations opened this issue Feb 7, 2007 · 15 comments
Closed

Recursive Query bug in FB2.1 [CORE1122] #1543

firebird-automations opened this issue Feb 7, 2007 · 15 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Montri Patchaiyo (k1)

Is related to QA65

When recusive query containts a fields with type blob that have a values existed,
Firebird gave error message: "Error writing data to the connection'"

There are no error if all rows of blob fields in result set is null,

BTW, there are also no error for simple CTE with blob fields that have a values.

Montri.

Commits: 0ac7d12

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

Please post a sample to allow for the case to be confirmed. Otherwise, this case will be closed as not-reproducible.

@firebird-automations
Copy link
Collaborator Author

Commented by: Montri Patchaiyo (k1)

This is a simple test case:

First:
CREATE TABLE TB_MENUS (
RECORD_ID INTEGER,
PARENT_ID INTEGER,
ORDER_ITEM INTEGER NOT NULL,
MENU_NAME VARCHAR(120),
APP_NAME VARCHAR(80),
MENU_ICON BLOB SUB_TYPE 0 SEGMENT SIZE 80
);

Second:
INSERT INTO TB_MENUS (0, NULL, 1, 'M1', NULL, NULL);
INSERT INTO TB_MENUS (1, 0, 1, 'M1 - Sub1', 'APP1.EXE', NULL);
INSERT INTO TB_MENUS (2, 0, 1, 'M1 - Sub2', 'APP2.EXE', NULL);

Last: execute following statement
WITH RECURSIVE
MENUS_LIST AS (
SELECT
PARENT_ID,
RECORD_ID,
ORDER_ITEM,
MENU_NAME,
APP_NAME,
MENU_ICON,
CAST('' AS VARCHAR(255)) IDENT
FROM
TB_MENUS
WHERE
(PARENT_ID IS NULL)

UNION ALL

SELECT
  M\.PARENT\_ID,
  M\.RECORD\_ID,
  M\.ORDER\_ITEM,
  M\.MENU\_NAME,
  M\.APP\_NAME,
  MENU\_ICON,
  H\.IDENT \|\| '    ' IDENT
FROM
  TB\_MENUS M INNER JOIN MENUS\_LIST H
  ON \(M\.PARENT\_ID = H\.RECORD\_ID\)

)
SELECT
PARENT_ID,
RECORD_ID,
ORDER_ITEM,
(IDENT || MENU_NAME) "Menu Name",
APP_NAME,
MENU_ICON,
FROM
MENUS_LIST

Even if you try to update or insert any values for MENU_ICON fields, the error was occured with message "Error writing data to the connection".
The error is occured if table is still has a values for a BLOB fields and has effected only for recursive one.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Vlad Horsun [ hvlad ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

The bug is not related with CTE. It can be reproduced much simpler :

SELECT MENU_ICON
FROM TB_MENUS

UNION ALL

SELECT MENU_ICON
FROM TB_MENUS

this also leads to AV in BLB_move. But it is worked well in FB 2.0

I think bug was introduced in FB 2.1 when text operations on blobs was implemented. Look at EXE_assignment :

in 2.0 it does

#⁠ifndef VMS
if (DTYPE_IS_BLOB(to_desc->dsc_dtype))
#⁠else
if (DTYPE_IS_BLOB(to_desc->dsc_dtype)
&& to_desc->dsc_dtype != dtype_d_float)
#⁠endif
BLB_move(tdbb, from_desc, to_desc, to);

	else if \(\!DSC\_EQUIV\(from\_desc, to\_desc, false\)\)
		MOV\_move\(from\_desc, to\_desc\);

in 2.1 it does

	if \(DTYPE\_IS\_BLOB\_OR\_QUAD\(from\_desc\-\>dsc\_dtype\) \|\|
		DTYPE\_IS\_BLOB\_OR\_QUAD\(to\_desc\-\>dsc\_dtype\)\)
	\{
		BLB\_move\(tdbb, from\_desc, to\_desc, to\);
	\}

Note - we have source type dtype_blob and target type dtype_quad as we want to assign blob_id (not to create new blob!)

So - FB 2.0 call MOV_move but FB 2.1 call BLB_move which failed getting target record relation (which is NULL in this case of course)

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

assignee: Vlad Horsun [ hvlad ] => Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.1 [ 10041 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @pcisar

Test added, but can't confirm the fix for 2.1 Alpha 1. Test fails with lost connection to the database. I suppose it's because it was fixed after Alpha 1, but then you need to assign correct fix version.

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Pavel, some tests can fail due to a bug in the "lazy packet send" implementation of Alpha 1. It shows itself as a lost connection without crashes on any side. It affects TCP and NetBEUI connections only, so you could try writing the test using a local connection string. Or just use a fresh snapshot build :-)

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Version: 2.1 Initial [ 10160 ]

Version: 2.1.0 [ 10041 ] =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Fix Version: 2.1 Alpha 1 [ 10150 ]

Fix Version: 2.1.0 [ 10041 ] =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA65 [ QA65 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @pcisar

Fix verified, test added.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Workflow: jira [ 11580 ] => Firebird [ 14981 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Closed [ 6 ] => Closed [ 6 ]

QA Status: Done successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants