PostgreSQL安装uuid-ossp

PostgreSQL安装uuid-ossp




postgres=# create extension "uuid-ossp" ;
ERROR:  could not open extension control file "/usr/local/pgsql/share/extension/uuid-ossp.control": No such file or directory


cd /usr/local/pgsql/contrib/uuid-ossp/
make && make install




make 报错
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I../../contrib/pgcrypto -I. -I. -I../../src/include  -D_GNU_SOURCE   -c -o uuid-ossp.o uuid-ossp.c
uuid-ossp.c:40:2: error: #error "please use configure's --with-uuid switch to select a UUID library"
 #error "please use configure's --with-uuid switch to select a UUID library"
  ^
uuid-ossp.c: In function ‘uuid_generate_internal’:
uuid-ossp.c:285:5: error: unknown type name ‘uuid_t’
     uuid_t  uu;
     ^
uuid-ossp.c:286:23: error: ‘uuid_s_ok’ undeclared (first use in this function)
     uint32_t status = uuid_s_ok;
 
解决办法:


yum -y install e2fsprogs-devel uuid-devel libuuid-devel


./configure --prefix=/usr/local/pgsql --with-uuid=ossp


cd /usr/local/pgsql/contrib/uuid-ossp/
make && make install




postgres=# create extension "uuid-ossp" ;
CREATE EXTENSION


安装扩展成功以后,就可以通过uuid_generate_v4()或uuid_generate_v1()查询 


postgres=# select uuid_generate_v4();
           uuid_generate_v4           
--------------------------------------
 9ebf8ab1-1246-4f0b-8777-2c7ee69b8368
(1 row)


postgres=# select uuid_generate_v1();
           uuid_generate_v1           
--------------------------------------
 70f03afa-533b-11e8-8778-005056894834
(1 row)





你可能感兴趣的:(PostgreSQL)