再次看到这段代码,想起来以前随口在QQ群里提过,突然感觉还是记录一下比较好,所以专门开辟新博客分类,我们来看看 Postgresql 代码中都隐藏着什么秘密。
假如我们发起一条语句:
SELECTrolnameFROMpg_authid;
会发生什么事呢?其中一个步骤是确定表中是否有rolname
/*Trytoidentifyasanunqualifiedcolumn*/ node=colNametoVar(pstate,colname,false,cref->location); if(node==NULL) { ... /* *Trytofindthenameasarelation.Notethatonly *relationsalreadyenteredintotherangetablewillbe *recognized. * *Thisisahackforbackwardscompatibilitywith *PostQUEL-inspiredSyntax.ThepreferredformNowis *"rel.*". */ rte=refnameRangeTblEntry(pstate,NULL,cref->location,&levels_up); if(rte) node=transformWholeRowRef(pstate,rte,cref->location);
最后一段很奇怪,好在有说明,测试一下确实可用,但是这是我以前从来不知道的用法。
postgres=#SELECTpg_authidFROMpg_authid; pg_authid ----------------------------- (quanzl,t,-1,) (1row) postgres=#
粗略查看了一下 9.4.5 文档,似乎没有关于这个的说明,应该是一个废弃已久的用法。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。