如何在Postgresql 9.x版本中运行Postgresql 8.3查询

时间:2017-11-25 09:08:35

标签: php postgresql

我使用PHP 5.2.3和Postgresql 8.2.3开发了我们的ERP应用程序。工作正常,我想升级PostgreSql 9.3但9.3版本中不支持部分查询。我的问题是为什么新版本的postgresql不支持向后兼容性??? Postgresql配置中是否有任何设置???

请检查我的以下查询Postgresql 8.2.3

SELECT #(std.quantity) AS quantity,
       round(std.area,2) AS area,
       std.stock_id,
       COALESCE(selection_value,' ') AS selection_value,
       COALESCE(getorigin_detail(std.stock_id),' ') as origin_desc,
       COALESCE(getlot_ref_no(std.stock_id),' ') as internal_receipt_item_no,
       COALESCE(ma.account_name,' ') AS account_name,
       COALESCE (getbatch_internal_no(std.stock_id),' ') as jcno,
       man.animal_name AS species ,
       COALESCE(buyer_reference||' '||odi.order_id||'-'||odi.item_id,' ') AS buyer_reference,
       sid.shipment_date,
       COALESCE(mm1.company_name,' ') AS customer,
       mm2.company_name AS unit,
       COALESCE(mp.product_desc,' ') AS product_desc,
       COALESCE(odi.colour_name,' ') AS colour,
       COALESCE(odi.thickness,' ') AS thickness,
       odi.size_range AS size,
       odi.internal_order_no AS pono,
       to_char(shipment_time,'HH12:MI:am') AS time
FROM stock_transaction_detail_106 std
   JOIN stock_details_106 sdpc ON std.stock_id=sdpc.stock_id
   JOIN stock_details sd ON std.stock_id=sd.stock_id
   LEFT JOIN master_account ma ON sd.account_id=ma.account_id
   JOIN shipment_items si ON std.reference_detail=si.shipment_item_id
   JOIN shipment_details sid ON si.shipment_id=sid.shipment_id
   JOIN order_details_shipments ods ON si.shipment_item_id=ods.shipment_item_id
   JOIN order_details_items odi ON odi.order_id=ods.order_id AND odi.item_id=ods.item_id
   JOIN order_details od ON odi.order_id=od.order_id
   JOIN relationships r1 ON od.relationship_id=r1.relationship_id
   JOIN master_member mm1 ON r1.partner_id=mm1.member_id
   JOIN relationships r2 ON od.agent_id=r2.relationship_id
   JOIN master_member mm2 ON r2.partner_id=mm2.member_id
   LEFT JOIN sys_master_selection_106 sms106 ON sms106.selection_id = sdpc.selection_id
   JOIN master_product mp ON odi.product_id=mp.product_id
   JOIN master_colour mc ON odi.colour_id=mc.colour_id
   LEFT JOIN master_thickness mt ON mt.thickness_id = odi.thickness_id
   LEFT JOIN master_size ms ON ms.size_id = odi.size_id
   JOIN master_animal man ON man.animal_id=mp.animal_id
WHERE std.reference_detail=80285
  and std.stock_reference_type_id IN (6,21);

1 个答案:

答案 0 :(得分:0)

如果要比较数字和字符串,请在查询中引入类型转换。

没有理由不及时了解近10年前的行为变化。

禁用这些自动类型转换是PostgreSQL最近历史上最大的兼容性突破,但它有一些很好的理由(虽然我不知道开发人员是否会这样做,如果他们知道会有什么困难原因)。

如果您想继续承担必须修改升级的每个新版PostgreSQL的负担,可以使用script from Peter Eisentraut重新引入缺少的类型转换。这可能会导致针对同一数据库运行的其他应用程序出现问题,因为功能和运算符类型解析会更加模糊。