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

lpad and rpad with two columns not working [CORE1346] #1765

Closed
firebird-automations opened this issue Jul 5, 2007 · 19 comments
Closed

lpad and rpad with two columns not working [CORE1346] #1765

firebird-automations opened this issue Jul 5, 2007 · 19 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Robert Lakis (rlakis)

Is duplicated by CORE2597
Is related to QA242
Is duplicated by CORE1360

Check this:
select lpad('xxx', 8, '0') one, lpad('yyy', 8, '0') two from rdb$database

gives:
can't format message 13:796 -- message system code -4.
Dynamic SQL Error.
SQL error code = -204.
Implementation limit exceeded.
block size exceeds implementation restriction.

Commits: d2ec0ea 3915bcf

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

Unfortunatelly, this is as designed!
We don't support return strings of variable length, it needs a maximum size.

When you use two LPAD, another FB limit is reached.

@firebird-automations
Copy link
Collaborator Author

Commented by: Robert Lakis (rlakis)

this example is working:

select lpad('123', 8, '0') || ' string ' || lpad('1240', 8, '0') col from rdb$database

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

In theory, we can know the size, when it's constant.
But actually, this violates complete the layering, and is not supported with current code.

Workaround is to cast the result to a varchar of know size:
select cast(lpad('xxx', 8, '0') as varchar(8)) one, cast(lpad('yyy', 8, '0') as varchar(8)) two from rdb$database;

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Link: This issue is duplicated by CORE1360 [ CORE1360 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Adriano, should we consider SUBSTRING as also violating the layering? :-)

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

Here is what I've replied to Claudio:

> Hello, I read your explanation here
> CORE1346
> In theory, we can know the size, when it's constant.
> But actually, this violates complete the layering, and is not supported with
> current code.
>
> Won't substring violate the layering, too? It works with the size of the
> field. Initially, I made it to adjust the result to the length parameter,
> but this was against the standard.
And I supposed it was removed?

> However, I don't remember any technical
> problem to make it work with the field and the constant length. The problem
> was simply the logic was not in the SQL specification.
When things go to DataTypeUtil and SysFunction, we don't have access to the constant.
My idea when creating these files was to make code compatible with DSQL and JRD.

But the problem with PAD is that it can return strings with greater length than the original one, different from SUBSTRING.

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

summary: lpad with two columns not working => lpad and rpad with two columns not working

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

Link: This issue block progress on CORE1360 [ CORE1360 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue block progress on CORE1360 [ CORE1360 ] =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Workflow: jira [ 12511 ] => Firebird [ 15217 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

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

resolution: Fixed [ 1 ]

Fix Version: 2.5 RC1 [ 10300 ]

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

Backported to 2.1.4.

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

Version: 2.1.2 [ 10270 ]

Version: 2.1.1 [ 10223 ]

Version: 2.1.0 [ 10041 ]

Version: 2.1.3 [ 10302 ]

Fix Version: 2.1.4 [ 10361 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

Link: This issue is duplicated by CORE2597 [ CORE2597 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA242 [ QA242 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @pcisar

QA test added.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

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

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test => Done successfully

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