Parameterized limit throws an error
See original GitHub issueDriver version
2.0.874
Redshift version
PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.24019
Client Operating System
Ubuntu 20.04
Python version
3.8.5
Table schema
The error should be reproducible on any non-system table.
Problem description
- Expected behaviour: Results are printed when a parameterized limit is used
- Actual behaviour: An error is thrown
- Error message/stack trace:
> python3 test.py
Traceback (most recent call last):
File "test.py", line 13, in <module>
cursor.execute("SELECT id FROM mydb.accounts WHERE id = %s LIMIT %s", [1, 10])
File ".../lib/python3.8/site-packages/redshift_connector/cursor.py", line 162, in execute
self._c.execute(self, operation, args)
File ".../lib/python3.8/site-packages/redshift_connector/core.py", line 1097, in execute
self.handle_messages(cursor)
File ".../lib/python3.8/site-packages/redshift_connector/core.py", line 1172, in handle_messages
raise self.error
redshift_connector.error.ProgrammingError: {'S': 'ERROR', 'C': 'XX000', 'M': 'Not implemented', 'D': "\n -----------------------------------------------\n error: Not implemented\n code: 1001\n context: 'IsA(cons, Const)' - \n query: 527758\n location: pg_utils.cpp:5702\n process: padbmaster [pid=27215]\n -----------------------------------------------\n", 'F': '/home/ec2-user/padb/src/sys/xen_execute.cpp', 'L': '9226', 'R': 'pg_throw'}
- Any other details that can be helpful: the test code works when the limit parameter is hardcoded, that is, when the appropriate line is replaced with
cursor.execute("SELECT id FROM mydb.accounts WHERE id = %s LIMIT 10", [1])
.
Python Driver trace logs
N/A
Reproduction code
test.py
:
import os
import redshift_connector
conn = redshift_connector.connect(
host=os.getenv("REDSHIFT_HOSTNAME"),
database=os.getenv("REDSHIFT_DATABASE"),
user=os.getenv("REDSHIFT_USERNAME"),
password=os.getenv("REDSHIFT_PASSWORD"),
)
cursor = conn.cursor()
cursor.execute("SELECT id FROM mydb.accounts WHERE id = %s LIMIT %s", [1, 10])
print(cursor.fetchall())
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
PHP PDO bug when trying to parameterize SQL LIMIT :offset
Based on Update 2 in the question, where execution stops after the execute statement, it looks like the query is failing.
Read more >Error with parameterized LIMIT using BigInt · Issue #37 - GitHub
I can reproduce via setObject(paramIndex, BigInteger.valueof(100)). As such server throws the above error when driver tries to bind as Numeric ...
Read more >SP does not accept variables in LIMIT clause - MySQL Bugs
SPs don't accept variables in the LIMIT clause. If such a SP is created, the error message ERROR 1064 (42000): You have an...
Read more >filter limit expression references a parameter with the wrong type
Error: filter limit expression references a parameter with the wrong type. So I ran into the following error message Error.JPG.
Read more >Problem using limit offset in Doctrine_Query - Google Groups
Doctrine thrown this exception error into getSql call: SQLSTATE[42000]: Syntax error or access ... This query doesn't have any limit/offset clause.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @GergelyKalmar ,
Apologies for the confusion, when using a regular table I am able to reproduced the behavior you detailed above. I’ll continue investigating this and provide an update with my findings shortly.
Hey @GergelyKalmar ,
Thanks for reaching out regarding this issue. The team will take a look into this and follow up shortly with findings.