Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

Migrate to Postgres - Alias a Keyword?

已查看 5 次
跳至第一个未读帖子

Huan Ruan

未读,
2013年3月4日 18:17:532013/3/4
收件人
Hi All

We are migrating from Firebird to Postgres. We try to minimise changes required to the application code which has lots of SQLs in it. One of the incompatibilities between these two is the way to limit the number of rows returned by a SELECT query. 

In Postgres, SELECT * FROM TestTable LIMIT 10
In Firebird,   SELECT * FROM TestTable ROWS 10 

What I'm trying to do here is to get Postgres to accept ROWS as if it's LIMIT. Looks like this is possible by adding an alias in /src/include/parser/kwlist.h, although ROWS is already defined in it for other purpose. 

Does anyone has a suggestion on this? Can I achieve this without recompiling our own copy of Postgres?

Thanks
Huan
   

Torsten Zuehlsdorff

未读,
2013年3月5日 08:45:442013/3/5
收件人
Hi,

> We are migrating from Firebird to Postgres. We try to minimise changes
> required to the application code which has lots of SQLs in it. One of
> the incompatibilities between these two is the way to limit the number
> of rows returned by a SELECT query.
>
> In Postgres, /SELECT * FROM TestTable LIMIT 10/
> In Firebird, /SELECT * FROM TestTable ROWS 10/
>
> What I'm trying to do here is to get Postgres to accept ROWS as if it's
> LIMIT. Looks like this is possible by adding an alias
> in /src/include/parser/kwlist.h, although ROWS is already defined in it
> for other purpose.
>
> Does anyone has a suggestion on this? Can I achieve this without
> recompiling our own copy of Postgres?

i would hack the application, if there is database-layer in. For
problems like this i created the DDDBL (PHP, documentation in german,
sorry). It is a layer between application and database with full
controll over the queries and their result.

This is exactly the point to manipulate the SQL. There are many pitfalls
- like LIMIT as part of a relation, constant, etc - but it will work.

Greetings from Germany,
Torsten
0 个新帖子