duartedenio / pk_fk Goto Github PK
View Code? Open in Web Editor NEWThis project forked from rogerioschmidt/pk_fk
Cópia do Projeto de BD II
This project forked from rogerioschmidt/pk_fk
Cópia do Projeto de BD II
O programa até então desenvolvido está com alguns vazamentos de memória, algo que poderia ser resolvido mantendo as funcionalidades do mesmo. O primeiro a ser resolvido será o da função leobjeto().
==2984== 20 bytes in 1 blocks are definitely lost in loss record 5 of 46
==2984== at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2984== by 0x8048845: leObjeto (in /home/gelinux/Área de Trabalho/PK_FK/prog)
==2984== by 0x804C2ED: abreTabela (in /home/gelinux/Área de Trabalho/PK_FK/prog)
==2984== by 0x804A0B9: finalizaInsert (in /home/gelinux/Área de Trabalho/PK_FK/prog)
==2984== by 0x804C636: main (in /home/gelinux/Área de Trabalho/PK_FK/prog)
O conteúdo das variáveis utilizadas na função leSchema não são liberadas antes de retornar algum resultado.
==4131==
==4131== 480 bytes in 1 blocks are definitely lost in loss record 23 of 42
==4131== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4131== by 0x40366B: procuraAtributoFK (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==4131== by 0x40256C: finalizaInsert (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==4131== by 0x404FE9: main (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==4131==
Dada as tabelas:
employe(id, name);//id = PK;
client(id, name); //id = PK;
invoice(id, eid, cid, value);//id = PK; eid = FK(employe(id)); cid = FK(client(id));
A função tem um erro onde obrigava que os atributos FK de uma tabela fossem iguais ao da sua tabela original.
então logo ao inserir uma tupla em invoice, quando ele verifica se eid da tabela employe tem o valor para que a chave não fique inconsistente, está falhando pois ele procura por 'eid' e na tabela employe o nome do atributo é 'id'
==5442== Syscall param write(buf) points to uninitialised byte(s)
==5442== at 0x41159D3: __write_nocancel (syscall-template.S:82)
==5442== by 0x40B977E: new_do_write (fileops.c:530)
==5442== by 0x40B9A95: _IO_do_write@@GLIBC_2.1 (fileops.c:503)
==5442== by 0x40BAFBF: _IO_file_close_it@@GLIBC_2.1 (fileops.c:170)
==5442== by 0x40AE3A7: fclose@@GLIBC_2.1 (iofclose.c:62)
==5442== by 0x8049DD3: finalizaTabela (buffend.c:474)
==5442== by 0x804C2F8: main (exemploMain.c:25)
==5442== Address 0x4030008 is not stack'd, malloc'd or (recently) free'd
==5442== Uninitialised value was created by a heap allocation
==5442== at 0x4028308: malloc (vg_replace_malloc.c:263)
==5442== by 0x8049B2C: adicionaCampo (buffend.c:408)
==5442== by 0x804C220: main (exemploMain.c:21)
Quando uma tabela com PK é deletada não é feita a verificação nas demais tabelas com FK's. Dessa maneira, se uma tabela com PK for deletada, as tabelas que possuírem FK's referenciando essa tabela ficarão inconsistentes pois continuarão referenciando valores que já não existem mais.
Funções de inserção e de verificação de chave primária leem direto do arquivo, desconsiderando o buffer.
==9345== Invalid read of size 4
==9345== at 0x804ADAD: getPage (buffend.c:837)
==9345== by 0x804BECF: existeAtributo (buffend.c:1224)
==9345== by 0x804C2BB: verificaChavePK (buffend.c:1341)
==9345== by 0x804A396: finalizaInsert (buffend.c:627)
==9345== by 0x804CB62: main (exemploMain.c:53)
==9345== Address 0x423a594 is 4 bytes after a block of size 536,576 alloc'd
==9345== at 0x4028308: malloc (vg_replace_malloc.c:263)
==9345== by 0x8048DDF: initbuffer (buffend.c:102)
==9345== by 0x804BD71: iniciaAtributos (buffend.c:1191)
==9345== by 0x804BDC9: existeAtributo (buffend.c:1217)
==9345== by 0x804C2BB: verificaChavePK (buffend.c:1341)
==9345== by 0x804A396: finalizaInsert (buffend.c:627)
==9345== by 0x804CB62: main (exemploMain.c:53)
==3255== 116 bytes in 1 blocks are definitely lost in loss record 14 of 40
==3255== at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==3255== by 0x804A2FB: finalizaInsert (in /home/gelinux/Área de Trabalho/PK_FK/prog)
==3255== by 0x804CB84: main (in /home/gelinux/Área de Trabalho/PK_FK/prog)
A função imprime() mostra lixo em alguns casos.
==6941== 20 bytes in 1 blocks are definitely lost in loss record 8 of 40
==6941== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==6941== by 0x4019B7: verificaNomeTabela (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==6941== by 0x400B49: leObjeto (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==6941== by 0x404075: iniciaAtributos (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==6941== by 0x404797: verificaChavePK (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==6941== by 0x402606: finalizaInsert (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==6941== by 0x405028: main (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==6941==
Falha na função, pois ela retorna que existe o arquivo quando o mesmo foi deletado por alguma função do programa. Função pouco desnecessária também, pois deverá haver alguma verificação para o nome da tabela e também se não existe o arquivo, ele é criado automaticamente.
Imprimindo conteúdo de apenas uma página do Buffer, por mais que existam tuplas em outras páginas.
Também informa o número de tuplas errado quando a quantidade de tuplas excede a capacidade de uma página do buffer.
==13053== Invalid write of size 1
==13053== at 0x4028AC5: strcpy (mc_replace_strmem.c:429)
==13053== by 0x8049FB2: insereValor (buffend.c:512)
==13053== by 0x804C788: main (exemploMain.c:74)
==13053== Address 0x444e062 is 6 bytes after a block of size 4 alloc'd
==13053== at 0x4028308: malloc (vg_replace_malloc.c:263)
==13053== by 0x8049F76: insereValor (buffend.c:509)
==13053== by 0x804C788: main (exemploMain.c:74)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.