Não foi possível enviar o arquivo. Será algum problema com as permissões?
Diferenças

Diferenças

Aqui você vê as diferenças entre duas revisões dessa página.

Link para esta página de comparações

Ambos lados da revisão anterior Revisão anterior
software:art-dev:drivers [2008/11/22 18:11]
pedro
software:art-dev:drivers [2008/11/25 11:24] (atual)
pedro
Linha 11: Linha 11:
  
 =====Postgre===== =====Postgre=====
-  * all databasde operations (createDB, createLayer etc) are echoing messages such as:+ 
 +====Echoing Messages==== 
 +all databasde operations (createDB, createLayer etc) are echoing messages such as:
  
 <​code>​ <​code>​
Linha 24: Linha 26:
 </​code>​ </​code>​
 How to remove them? How to remove them?
 +
 +====Permissions====
 +
 +Henrique: drop user acho que vai funcionar sem problemas,
 +o conceito do addUser é que é diferente do MySQL, uma vez que é
 +necessário ter o usuário criado pelo CREATE USER antes de usar o GRAN
 +ALL, outro detalhe disto é que no GRANT ALL do pg é que ele
 +aparentemente não aceita o @'​localhost',​ @'​%',​ etc...
 +
 +O getPermission não vai funcionar porque está vinculado à tabelas do
 +MySQL se não me engano, no pg não tem todas as informa~ções de usuario
 +que tem no MySQL, podem ser visualizadas com "​SELECT * FROM pg_user"​.
 +
 +Ontem mexi um pouco no código do aRTconn.cpp,​ mas ainda falta algumas coisas.
 +
 +Coloquei um pouco de informação aqui:
 +http://​www.leg.ufpr.br/​doku.php/​dicas:​postgres
 +
 +Henrique: Segue em anexo, uma versão DropUser e do AddPermission,​ não tive como
 +testar ainda.
 +<​code>​
 +SEXP aRTconn::​DropUser(SEXP data)
 +{
 + string user      = GET_STRING_ELEMENT(data,​ "​user" ​    );
 + /*Drop user no postgres nao tem o '​@localhost',​ etc..
 + *bool remote ​     = GET_BOOL_ELEMENT ​ (data, "​remote" ​  );
 + *string host      = GET_STRING_ELEMENT(data,​ "​host" ​    );*/
 +
 + PrintSilent("​Dropping user \'​%s\'​ ... ", user.c_str());​
 + TeDatabase* db = NewTeDatabase();​
 +
 + if( !db -> connect(Host,​ User, Password, "",​ Port))
 + error("​Could not connect\n"​);​
 +
 + stringstream stream;
 + stream << "drop user " << user;
 +  switch(Type)
 + {
 + case aRTmySQL:
 + if(!remote && host == ""​) stream << "​@localhost";​
 + else if(host != ""​) ​      ​stream << "​@"​ << host;
 + else ​                     stream << "​@\'​%\'";​
 + }
 +
 + stream << ";";​
 +
 + string sql = StreamToChar(stream);​
 +
 +// cout << sql << endl;
 +
 + if( !db->​execute(sql) )
 + {
 + string err = db->​errorMessage();​
 + delete db;
 + error( err.c_str() );
 + }
 +
 + delete db;
 +    PrintSilentYes;​
 + return RNULL;
 +}
 +
 +SEXP aRTconn::​AddPermission(SEXP data)  // only works in MySQL!
 +{
 + string user      = GET_STRING_ELEMENT(data,​ "​user" ​    );
 + bool remote ​     = GET_BOOL_ELEMENT ​ (data, "​remote" ​  );
 + string host      = GET_STRING_ELEMENT(data,​ "​host" ​    );
 + string pass      = GET_STRING_ELEMENT(data,​ "​pass" ​    );
 + string database ​ = GET_STRING_ELEMENT(data,​ "​database"​ );
 + string previlege = GET_STRING_ELEMENT(data,​ "​previlege"​);​
 +
 + PrintSilent("​Adding permissions to user \'​%s\'​ ... ", user.c_str());​
 + TeDatabase* db = NewTeDatabase();​
 +
 + if( !db -> connect(Host,​ User, Password, "",​ Port))
 + error("​Could not connect\n"​);​
 +
 + stringstream stream;
 +
 + switch(Type)
 + {
 + case aRTmysql:
 + stream << "GRANT " <<​previlege << " ON " << database << " TO " << user;
 + if(!remote && host == ""​) stream << "​@localhost";​
 + else if(host != ""​) ​      ​stream << "​@"​ << host;
 + else ​                     stream << "​@\'​%\'";​
 + if(pass != ""​)
 + stream << " IDENTIFIED BY \'"​ << pass << "​\'";​
 + case aRTpostgres:​
 + stream << "​CREATE USER " << user << ";";​
 + stream << "grant " << previlege << " ON DATABASE " << database << " TO " << user;
 + }
 + stream << ";";​
 +
 + string sql = StreamToChar(stream);​
 +
 +// cout << sql << endl;
 +
 + if( !db->​execute(sql) )
 + {
 + string err = db->​errorMessage();​
 + delete db;
 + error( err.c_str() );
 + }
 +
 + delete db;
 +    PrintSilentYes;​
 + return RNULL;
 +}</​code>​

QR Code
QR Code software:art-dev:drivers (generated for current page)