pg>mysql>bit.sql
2021-09-24 16:25:41    38    0    0
ivan

mysqlcompat-0.0.7是网上开源的postgresql兼容包;

以下是写sql兼容的方式,兼容mysql函数,此种方式效率会是瓶颈;

因此尽量改成postgresql原生的函数或者底层源码兼容;

 

1 -- BIT_COUNT()

CREATE OR REPLACE FUNCTION bit_count(bigint)

RETURNS integer AS $$

  SELECT pg_catalog.length(pg_catalog.replace(pg_catalog.ltrim(pg_catalog.textin(pg_catalog.bit_out($1::bit(64))), '0'), '0', ''));

$$ IMMUTABLE STRICT LANGUAGE SQL;

Pre: pg>mysql>aggregate.sql

Next: pg>mysql>casts.sql

38
Sign in to leave a comment.
No Leanote account? Sign up now.
0 comments
Table of content