Re: last_insert_id failing for table name with double quotes

Joseph Boakye <[email protected]> Wed, 10 Nov 2021 16:14:11 +0000
Newsgroups gmane.comp.db.postgresql.dbdpg
Message-ID <DM6PR04MB7097103409BED074947B8AB8BE939@DM6PR04MB7097.namprd04.prod.outlook.com>
--_000_DM6PR04MB7097103409BED074947B8AB8BE939DM6PR04MB7097namp_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


I made the change to my local copy of Pg.pm and that seems to have fixed it=
:

---snip
my $query_table =3D $table;


->$query_table =3D~ s/["]{2}/"/g;
->my @Args<https://github.com/Args> =3D ($query_table);



my $schemawhere;
if (length $schema) {
-- snip



Error:

INSERT into " public.best!Tab le@Ever2$%^&()_+{}:'""?/.>,<~ 4" (" (id)$mipu=
blic.lk'","""""''""""2--","not$%^&() _+{}:'""?/.>,<~nice","""""""""3'",""""=
"''""""++") VALUES (?, ?, ?, ?, ?)

DBD::Pg::db last_insert_id failed: Could not find the table " public.best!T=
ab le@Ever2$%^&*()_+{}\:'""?/.>,<~ `4" [for Statement "
SELECT i.indisprimary,
COALESCE(
-- this takes the table name as text, not regclass

--_000_DM6PR04MB7097103409BED074947B8AB8BE939DM6PR04MB7097namp_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none;"> P {margin-top:0;margin-bo=
ttom:0;} </style>
</head>
<body dir=3D"ltr">
<div><br>
</div>
<div>
<p dir=3D"auto">I made the change to my local copy of Pg.pm and that seems =
to have fixed it:</p>
<p dir=3D"auto">---snip<br>
my $query_table =3D $table;</p>
<p dir=3D"auto"><br>
</p>
<p dir=3D"auto">-&gt;$query_table =3D~ s/[&quot;]{2}/&quot;/g;<br>
-&gt;my <a class=3D"user-mention" data-hovercard-type=3D"user" data-hoverca=
rd-url=3D"/users/Args/hovercard" data-octo-click=3D"hovercard-link-click" d=
ata-octo-dimensions=3D"link_type:self" href=3D"https://github.com/Args">
@Args</a> =3D ($query_table);<br>
</p>
<p dir=3D"auto"><br>
</p>
<p dir=3D"auto"><br>
</p>
<p dir=3D"auto">my $schemawhere;<br>
if (length $schema) {<br>
-- snip</p>
<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Error:<br>
</div>
<div>
<div dir=3D"ltr">
<div style=3D"font-family:Calibri,Helvetica,sans-serif; font-size:12pt; col=
or:rgb(0,0,0)">
<p dir=3D"auto" style=3D"margin-top: 0px; margin-bottom: 0px;">INSERT into =
&quot; public.best!Tab le@Ever2$%^&amp;<em>()_+{}:'&quot;&quot;?/.&gt;,&lt;=
<code>~
</code>4&quot; (&quot; (id)<code>$mipublic.lk'&quot;,&quot;&quot;&quot;&quo=
t;&quot;</code>''&quot;&quot;&quot;&quot;2--&quot;,&quot;not$%^&amp;</em>()=
 _+{}:'&quot;&quot;?/.&gt;,&lt;<code>~nice&quot;,&quot;&quot;&quot;&quot;&q=
uot;</code>&quot;&quot;&quot;&quot;3'&quot;,&quot;&quot;&quot;&quot;&quot;<=
code>''&quot;&quot;&quot;&quot;++&quot;) VALUES (?, ?, ?, ?, ?)</code></p>
<p dir=3D"auto" style=3D"margin-top: 0px; margin-bottom: 0px;"><code>DBD::P=
g::db last_insert_id failed: Could not find the table &quot; public.best!Ta=
b le@Ever2$%^&amp;*()_+{}\:'&quot;&quot;?/.&gt;,&lt;</code>~ `4&quot; [for =
Statement &quot;<br>
SELECT i.indisprimary,<br>
COALESCE(<br>
-- this takes the table name as text, not regclass</p>
</div>
</div>
</div>
</body>
</html>

--_000_DM6PR04MB7097103409BED074947B8AB8BE939DM6PR04MB7097namp_--